Commit Graph

83437 Commits

Author SHA1 Message Date
Niko Matsakis
5c5741bf76 add some comments 2018-09-09 14:14:41 -04:00
Niko Matsakis
d6a98db7cb factor out lookup_bound_region 2018-09-09 14:14:41 -04:00
Niko Matsakis
09f4172bed remove extra lifetime bound 2018-09-09 14:14:41 -04:00
Niko Matsakis
fa1f564426 document the purpose of ScopeInstantiator 2018-09-09 14:14:41 -04:00
Oliver Middleton
d3e56854e1 rustdoc: Remove generated blanket impls from trait pages 2018-09-09 18:27:05 +01:00
David Tolnay
7acd4b12da
Remove documentation about proc_macro being bare-bones 2018-09-09 09:56:14 -07:00
bors
f50b7758f4 Auto merge of #54057 - matthiaskrgr:stabilize-edition-plus-clippy, r=Mark-Simulacrum
Stabilize edition 2018; also updates Clippy, RLS and Cargo

Supersedes https://github.com/rust-lang/rust/pull/53999 , https://github.com/rust-lang/rust/pull/53935
Clippy build was failing there because crate_visibility_modifier feature was taken out of edition 2018 and clippy used it.
The clippy update enables the corresponding feature explicitly.

r? @Mark-Simulacrum
2018-09-09 16:09:39 +00:00
Jorge Aparicio
f4148a6adb remove #[used] from the unstable book
it'll be documented in the reference
2018-09-09 15:55:59 +02:00
Jorge Aparicio
2fb5d5df89 stabilize #[used]
closes #40289
2018-09-09 15:43:28 +02:00
bors
40fc8ba5f9 Auto merge of #53902 - dtolnay:group, r=petrochenkov
proc_macro::Group::span_open and span_close

Before this addition, every delimited group like `(`...`)` `[`...`]` `{`...`}` has only a single Span that covers the full source location from opening delimiter to closing delimiter. This makes it impossible for a procedural macro to trigger an error pointing to just the opening or closing delimiter. The Rust compiler does not seem to have the same limitation:

```rust
mod m {
    type T =
}
```

```console
error: expected type, found `}`
 --> src/main.rs:3:1
  |
3 | }
  | ^
```

On that same input, a procedural macro would be forced to trigger the error on the last token inside the block, on the entire block, or on the next token after the block, none of which is really what you want for an error like above.

This commit adds `group.span_open()` and `group.span_close()` which access the Span associated with just the opening delimiter and just the closing delimiter of the group. Relevant to Syn as we implement real error messages for when parsing fails in a procedural macro: https://github.com/dtolnay/syn/issues/476.

```diff
  impl Group {
      fn span(&self) -> Span;
+     fn span_open(&self) -> Span;
+     fn span_close(&self) -> Span;
  }
```

Fixes #48187
r? @alexcrichton
2018-09-09 13:27:44 +00:00
Eric Huss
60be0686e0 merge cargo changes done by https://github.com/rust-lang/rust/pull/53935/
(done by matthiaskrgr, but I authored ehuss)
2018-09-09 12:42:43 +02:00
bors
df6ba0c4ac Auto merge of #53998 - eddyb:issue-53728, r=oli-obk
rustc_codegen_llvm: don't assume offsets are always aligned.

Fixes #53728 by taking into account not just overall type alignment and the field's alignment when determining whether a field is aligned or not ("packed"), but also the field's offset within the type.

Previously, rustc assumed that the offset was always at least as aligned as `min(struct.align, field.align)`. However, there's no real reason to have that assumption, and it obviously can't always be true after we implement `#[repr(align(N), pack(K))]`. There's also a case today where that assumption is not true, involving niche discriminants in enums:

Suppose that we have the code in #53728:
```Rust
#[repr(u16)]
enum DeviceKind {
    Nil = 0,
}

#[repr(packed)]
struct DeviceInfo {
    endianness: u8,
    device_kind: DeviceKind,
}

struct Wrapper {
    device_info: DeviceInfo,
    data: u32
}
```

Observe the layout of `Option<Wrapper>`. It has an alignment of 4 because of the `u32`. `device_info.device_kind` is a good niche field to use, which means the enum ends up with this layout:
```
size = 8
align = 4
fields = [
    { offset=1, type=u16 } // discriminant, .<Some>.device_info.device_kind
]
```

And here we have an discriminant with alignment 2 (`u16`) but offset 1.
2018-09-09 08:54:29 +00:00
Ralf Jung
3cb736af75 miri loop detector hashing: fix enum hashing to also consider discriminant; do not hash extra machine state
standalone miri is not interested in loop detection
2018-09-09 10:53:36 +02:00
David Tolnay
57d6ada91d
Rename sp_lo to sp_open 2018-09-08 23:47:42 -07:00
bors
3d2fc456a9 Auto merge of #53988 - eddyb:issue-53770, r=petrochenkov
rustc_resolve: only prepend CrateRoot to a non-keyword segment.

Fixes #53770 by treating `use` paths as absolute in a finer-grained manner, specifically:
```rust
use {a, crate::b, self::c, super::d};
```
Used to be interpreted as if it were (when `uniform_paths` is not enabled):
```rust
use ::{a, crate::b, self::c, super::d};
```
With this PR, the `CrateRoot` pseudo-keyword indicating an absolute path is only inserted when the first path segment is found (if it's not a keyword), i.e. the example behaves like:
```rust
use {::a, crate::b, self::c, super::d};
```
This should (finally) make `use {path};` fully equivalent to `use path;`.

r? @petrochenkov cc @cramertj @joshtriplett @nikomatsakis
2018-09-09 06:25:13 +00:00
Behnam Esfahbod
88fe8acd89 docs: Use dollar sign for all bash prompts
Making it consistent across the board, as most of them already use `$`.

Also split one continues bash run into two, to make it easier see
different runs: one with warning and another with error.
2018-09-08 21:22:00 -07:00
toidiu
7eb0ef0497 simplify ordering for Kind 2018-09-09 00:16:57 -04:00
bors
dac76020a5 Auto merge of #53960 - estebank:issue-51303, r=nagisa
Fix incorrect outer function type parameter message

Fix #51303.
2018-09-09 04:00:21 +00:00
Rusty Blitzerr
7f6b608995 Stabilization change for mod.rs
This change is in response to https://github.com/rust-lang/rust/issues/53125.
The patch makes the feature accepted and removes the tests that tested the
non-accepted status of the feature.
2018-09-08 19:41:46 -07:00
David Tolnay
a1dd39e724
Track distinct spans for open and close delimiter 2018-09-08 19:01:48 -07:00
bors
004bc5a33c Auto merge of #53949 - estebank:unclosed-delim, r=nikomatsakis
Improve messages for un-closed delimiter errors
2018-09-09 01:36:58 +00:00
Matthias Krüger
3387f80ce3 submodules: update clippy, rls with crate visibility patches, also update cargo 2018-09-09 03:00:00 +02:00
Mark Rousskov
5af06768a9 Remove crate_visibility_modifier from 2018 edition 2018-09-09 02:28:13 +02:00
Mark Rousskov
4d1ec81811 Stabilize the 2018 edition 2018-09-09 02:28:13 +02:00
Félix Saparelli
e25e2abe48
Add Error::description soft-deprecation to RELEASES 2018-09-09 10:36:17 +12:00
bors
0198a1ea45 Auto merge of #53909 - mikhail-m1:53643, r=nikomatsakis
Skip a shared borrow of a immutable local variables

issue #53643

r? @nikomatsakis
2018-09-08 19:57:14 +00:00
Martin Pool
597c06544d Document .0 to unpack the value from Wrapping 2018-09-08 11:35:02 -07:00
bors
968d95e940 Auto merge of #53903 - GabrielMajeri:opt-miri-array-slice, r=oli-obk
Optimize miri checking of integer array/slices

This pull request implements the optimization described in #53845 (the  `E-easy` part of that issue, not the refactoring). Instead of checking every element of an integral array, we can check the whole memory range at once.

r? @RalfJung
2018-09-08 17:36:09 +00:00
Simonas Kazlauskas
0ec351d528 &CStr, not CStr, is the counterpart of &str 2018-09-08 20:01:41 +03:00
Pramod Bisht
21ba03e2b9 Fixed 53359: E0432 unresolved import on the same line is now emiting one diagnostic
Addressed estebank's comments for 53359
2018-09-08 15:11:04 +00:00
bors
b24330fb7d Auto merge of #53705 - ms2300:tmp, r=oli-obk
#53576 Renaming TyAnon -> TyOpaque

Fixes #53576
2018-09-08 14:16:37 +00:00
bors
05cb29e96f Auto merge of #54051 - kennytm:rollup, r=kennytm
Rollup of 10 pull requests

Successful merges:

 - #53315 (use `NonZeroU32` in `newtype_index!`macro, change syntax)
 - #53932 ([NLL] Remove base_place)
 - #53942 (Rewrite `precompute_borrows_out_of_scope` for fewer hash table lookups.)
 - #53973 (Have rust-lldb look for the rust-enabled lldb)
 - #53981 (Implement initializer() for FileDesc)
 - #53987 (rustbuild: allow configuring llvm version suffix)
 - #53993 (rustc_resolve: don't record uniform_paths canaries as reexports.)
 - #54007 (crates that provide a `panic_handler` are exempt from the `unused_extern_crates` lint)
 - #54040 (update books for next release)
 - #54050 (Update `petgraph` dependency to 0.4.13 to fix build with nightly)
2018-09-08 11:53:21 +00:00
Vadim Petrochenkov
2dce3779bb resolve: More precise spans for ambiguous resolution errors
Add labels to ambiguous resolution errors
2018-09-08 14:15:11 +03:00
Vadim Petrochenkov
9beb5c3ef3 Add checks for expected macro output in restricted shadowing tests 2018-09-08 14:15:11 +03:00
Vadim Petrochenkov
ae2e5aa1c7 resolve: Further simplify legacy scopes, add comments 2018-09-08 14:15:11 +03:00
Vadim Petrochenkov
e00993a1ab Add test cases for possible restricted shadowing configurations
Whitelist `#[rustc_transparent_macro]` so it's not interpreted as a potential attribute macro
2018-09-08 14:15:11 +03:00
Vadim Petrochenkov
d26ae20507 resolve: Rename some fields related to legacy macro scopes 2018-09-08 14:15:11 +03:00
Vadim Petrochenkov
c057d579ab resolve: Relax shadowing restriction on macro-expanded macros
... for both legacy and modern macros.
Fix previously introduced regressions, add tests.
2018-09-08 14:15:11 +03:00
Vadim Petrochenkov
27235698f5 resolve: Introduce "may appear after" abstraction for macro path resolutions 2018-09-08 14:15:11 +03:00
Vadim Petrochenkov
9a539ade9f resolve: Cleanup two main macro resolution functions, tweak some comments 2018-09-08 14:15:11 +03:00
Vadim Petrochenkov
f34ac26114 resolve: Model shadowing restriction for macro_rules after modern macros
This is a regression for legacy macros that will be fixed in the next commit
2018-09-08 14:15:10 +03:00
Vadim Petrochenkov
83a51deef5 resolve: Model resolve_legacy_scope after resolve_lexical_macro_path_segment 2018-09-08 14:15:10 +03:00
Vadim Petrochenkov
4e5e045459 resolve: Partially unify bindings from macro_rules and from other items 2018-09-08 14:15:10 +03:00
kennytm
51c387931e
Rollup merge of #53315 - nikomatsakis:newtype-index, r=Mark-Simulacrum
use `NonZeroU32` in `newtype_index!`macro, change syntax

Various improvements to the `newtype_index!` macro:

- Use `NonZeroU32` so that `Option<T>` is cheap
- More ergonomic helper method, no need to import `Idx` trait all the time
- Improve syntax to use `struct` keyword so that ripgrep works to find type def'n

Fixes https://github.com/rust-lang/rust/issues/50337

I'm curious to see if this passes tests =)
2018-09-08 18:28:13 +08:00
kennytm
b1ef2b81b9
Rollup merge of #54050 - GabrielMajeri:fix-build-with-nightly, r=alexcrichton
Update `petgraph` dependency to 0.4.13 to fix build with nightly

I wanted to build Rust from source using a local nightly compiler, but I was unable to get `bootstrap` to compile due to a naming conflict with the `find_map` function.

This PR updates the `petgraph` dependency of `bootstrap` to 0.4.13, fixing the issue.
2018-09-08 18:27:28 +08:00
kennytm
0b58d2d4e1
Rollup merge of #54040 - steveklabnik:update-books, r=Mark-Simulacrum
update books for next release
2018-09-08 18:27:15 +08:00
kennytm
1a86a9379e
Rollup merge of #54007 - japaric:gh53964, r=cramertj
crates that provide a `panic_handler` are exempt from the `unused_extern_crates` lint

fixes the *first* false positive reported in #53964
2018-09-08 18:26:59 +08:00
kennytm
407da0a8a2
Rollup merge of #53993 - eddyb:issue-53691, r=petrochenkov
rustc_resolve: don't record uniform_paths canaries as reexports.

Fixes #53691, fixes #53484.
2018-09-08 18:26:44 +08:00
kennytm
e2e3608a4b
Rollup merge of #53987 - Keruspe:llvm-suffix, r=alexcrichton
rustbuild: allow configuring llvm version suffix

Fixes #53852 by allowing user to install different versions of rust to the same sysroot.
2018-09-08 18:26:41 +08:00
kennytm
14c21a11b3
Rollup merge of #53981 - fbernier:patch-1, r=sfackler
Implement initializer() for FileDesc

Here was my initial issue:

```rust
use std::process::{Command};

fn main() {
    let output = Command::new("curl").arg("-s").arg("http://ovh.net/files/100Mio.dat").output();
    println!("{:?}", output.unwrap().stdout.len());
}
```
```
~/stuff ❯❯❯ time ./dwl
104857600
./dwl  16.22s user 1.80s system 23% cpu 1:15.24 total
```

```rust
use std::process::{Command, Stdio};

fn main() {
    let child = Command::new("curl").arg("-s").arg("http://ovh.net/files/100Mio.dat").stdout(Stdio::piped()).spawn();
    let output = child.unwrap().wait_with_output().unwrap();
    println!("{:?}", output.stdout.len());
}
```

```
~/stuff ❯❯❯ time ./dwl2
104857600
./dwl2  0.64s user 2.18s system 5% cpu 53.072 total
```

As you can see the first version is spending much more time in userland and also uses more cpu. With the help of @programble, @talchas and @habnabit  on the rust IRC, we discovered that the slow version uses two pipes, one for `stdin` and one for `stderr` and in that case it polls when going through [this function](https://github.com/rust-lang/rust/blob/master/src/libstd/sys/unix/pipe.rs#L82). The polling calls `read_to_end` on the pipes repetitively and this results in zeroing its internal buffer each time. To avoid this zeroing, `FileDesc` needs to implement `initializer`. We see no reason why it [wouldn't work with uninitialized memory](https://doc.rust-lang.org/1.26.1/src/std/io/mod.rs.html#534) so this PR fixes that.

Here is some tracing of the slow program:
![image](https://user-images.githubusercontent.com/147585/45133180-ed8a2d80-b161-11e8-9ec7-09979ec96145.png)

versus the fast program:
![image](https://user-images.githubusercontent.com/147585/45133216-0c88bf80-b162-11e8-908e-ff81d59239fb.png)

I have not tested the change yet but will try to build it tomorrow.
2018-09-08 18:26:39 +08:00