Commit Graph

70212 Commits

Author SHA1 Message Date
Ariel Ben-Yehuda
617b413e18 limit packed copy-out to non-generic Copy structs 2017-11-26 16:12:43 +02:00
Ariel Ben-Yehuda
dee8a71cd5 fix #[derive] implementation for repr(packed) structs
Fix the derive implementation for repr(packed) structs to move the
fields out instead of calling functions on references to each subfield.

That's it, `#[derive(PartialEq)]` on a packed struct now does:
```Rust
fn eq(&self, other: &Self) {
    let field_0 = self.0;
    let other_field_0 = other.0;
    &field_0 == &other_field_0
}
```

Instead of
```Rust
fn eq(&self, other: &Self) {
    let ref field_0 = self.0;
    let ref other_field_0 = other.0;
    &*field_0 == &*other_field_0
}
```

Taking (unaligned) references to each subfield is undefined, unsound and
is an error with MIR effectck, so it had to be prevented. This causes
a borrowck error when a `repr(packed)` struct has a non-Copy field (and
therefore is a [breaking-change]), but I don't see a sound way to avoid
that error.
2017-11-26 16:12:43 +02:00
Ariel Ben-Yehuda
1a2d443f55 make accessing packed fields a future-compat warning 2017-11-26 16:12:42 +02:00
Ariel Ben-Yehuda
06eb5a6645 fix codegen of drops of fields of packed structs 2017-11-26 16:12:42 +02:00
Ariel Ben-Yehuda
3801c0594c update Cargo.lock & rustdoc
This is required because the old version depended on tendril 0.3.1,
which used `repr(packed)` incorrectly - see
https://github.com/kuchiki-rs/kuchiki/pull/38
2017-11-26 16:12:42 +02:00
Ariel Ben-Yehuda
bdb72edb5c make accesses to fields of packed structs unsafe
To handle packed structs with destructors (which you'll think are a rare
case, but the `#[repr(packed)] struct Packed<T>(T);` pattern is
ever-popular, which requires handling packed structs with destructors to
avoid monomorphization-time errors), drops of subfields of packed
structs should drop a local move of the field instead of the original
one.

cc #27060 - this should deal with that issue after codegen of drop glue
is updated.

The new errors need to be changed to future-compatibility warnings, but
I'll rather do a crater run first with them as errors to assess the
impact.
2017-11-26 16:12:42 +02:00
Ariel Ben-Yehuda
c48650ec25 fix treatment of local types in "remote coherence" mode 2017-11-26 16:12:42 +02:00
bors
2ca00a9489 Auto merge of #46100 - KiChjang:mass-dead-check, r=nikomatsakis
Kill the storage for all locals on returning terminators

Fixes #45704.
2017-11-26 11:43:19 +00:00
bors
2c115551c4 Auto merge of #46272 - kennytm:rollup, r=kennytm
Rollup of 7 pull requests

- Successful merges: #46201, #46224, #46234, #46252, #46259, #46264, #46269
- Failed merges:
2017-11-26 09:15:06 +00:00
kennytm
0d664f9d80 Rollup merge of #46269 - udoprog:check-links, r=KodrAus
Check tail node in check_links
2017-11-26 15:01:40 +08:00
kennytm
1aa4dd028d Rollup merge of #46264 - scottmcm:mir-array-len, r=arielb1
InstCombine Len([_; N]) => const N in MIR

A small opportunity I noticed in passing.

Not super exciting on its own, but opens the door for a const propagation pass that could completely remove const bounds checks from arrays at MIR time, for example.
2017-11-26 15:01:39 +08:00
kennytm
788fed8158 Rollup merge of #46259 - bjorn3:display_lang_item, r=nagisa
Derive Debug for LangItem
2017-11-26 15:01:38 +08:00
kennytm
f95011bd0e Rollup merge of #46252 - zilbuz:msvc-doc, r=kennytm
Update MSVC compilation instructions regarding path length on Windows

Fix #46214
2017-11-26 15:01:37 +08:00
kennytm
fbfedc7e5a Rollup merge of #46234 - lucasem:core-marker-typo, r=frewsxcv
core::marker fix typo
2017-11-26 15:01:36 +08:00
kennytm
4c8cddb11b Rollup merge of #46224 - GuillaumeGomez:io-missing-link, r=QuietMisdreavus
Remove invalid doc link

r? @rust-lang/docs
2017-11-26 15:01:35 +08:00
kennytm
2cac14e2f9 Rollup merge of #46201 - davidalber:eprint-in-fmt-doc, r=frewsxcv
Adding `eprint*!` to the list of macros in the `format!` family

The `eprint!` and `eprintln!` macros were added in 7612727. The `std::fmt` documentation does not mention these macros next to `print!` and `println!` in the [Related macros](https://doc.rust-lang.org/std/fmt/#related-macros) section, and I did not find evidence that this omission was deliberate. This PR adds such documentation.

The first modification is to add `eprint!` and `eprintln!` to the list of related macros in the `format!` family. This is how it appears with this change:

![image](https://user-images.githubusercontent.com/933552/33159527-67056caa-cfc8-11e7-8b7d-4224ef2fce4e.png)

The second modification adds a sub-section for `eprint!` and `eprintln!`. Here is how the new section appears:

![image](https://user-images.githubusercontent.com/933552/33159541-97d03bee-cfc8-11e7-8b95-4d3632b5ab7b.png)
2017-11-26 15:01:34 +08:00
bors
d4dc289f4b Auto merge of #45990 - murarth:rc-from-strs, r=alexcrichton
Implement `Rc`/`Arc` conversions for string-like types

Provides the following conversion implementations:

* `From<`{`CString`,`&CStr`}`>` for {`Arc`,`Rc`}`<CStr>`
* `From<`{`OsString`,`&OsStr`}`>` for {`Arc`,`Rc`}`<OsStr>`
* `From<`{`PathBuf`,`&Path`}`>` for {`Arc`,`Rc`}`<Path>`

Closes #45008
2017-11-26 06:49:43 +00:00
Murarth
1bbc776446 Implement Rc/Arc conversions for string-like types
Provides the following conversion implementations:

* `From<`{`CString`,`&CStr`}`>` for {`Arc`,`Rc`}`<CStr>`
* `From<`{`OsString`,`&OsStr`}`>` for {`Arc`,`Rc`}`<OsStr>`
* `From<`{`PathBuf`,`&Path`}`>` for {`Arc`,`Rc`}`<Path>`
2017-11-25 22:13:11 -07:00
bors
2f84fb5cc1 Auto merge of #46033 - sinkuu:const-enum-match-check, r=arielb1
Do match-check for consts

Fixes #43195 (ICE caused by building MIR that contains non-exausitive match)
2017-11-26 04:26:19 +00:00
bors
693bb0dae2 Auto merge of #45947 - estebank:match_default_bindings-arg-hint, r=arielb1
Be more obvious when suggesting dereference

Include `&` span when suggesting dereference on a span that is already a reference:

```
error: non-reference pattern used to match a reference (see issue #42640)
  --> dont-suggest-dereference-on-arg.rs:16:19
   |
16 |         .filter(|&(ref a, _)| foo(a))
   |                  ^^^^^^^^^^^ help: consider using: `&&(ref k, _)`
   |
   = help: add #![feature(match_default_bindings)] to the crate attributes to enable
```

Fix #45925.
2017-11-26 01:05:56 +00:00
John-John Tedro
4e4f8ab712 Check tail node in check_links 2017-11-26 00:30:33 +01:00
bors
128b40fadc Auto merge of #45367 - alexcrichton:simd-llvm-changes, r=eddyb
rustc: Add support for some more x86 SIMD ops

This commit adds compiler support for two basic operations needed for binding
SIMD on x86 platforms:

* First, a `nontemporal_store` intrinsic was added for the `_mm_stream_ps`, seen
  in rust-lang-nursery/stdsimd#114. This was relatively straightforward and is
  quite similar to the volatile store intrinsic.

* Next, and much more intrusively, a new type to the backend was added. The
  `x86_mmx` type is used in LLVM for a 64-bit vector register and is used in
  various intrinsics like `_mm_abs_pi8` as seen in rust-lang-nursery/stdsimd#74.
  This new type was added as a new layout option as well as having support added
  to the trans backend. The type is enabled with the `#[repr(x86_mmx)]`
  attribute which is intended to just be an implementation detail of SIMD in
  Rust.

I'm not 100% certain about how the `x86_mmx` type was added, so any extra eyes
or thoughts on that would be greatly appreciated!
2017-11-25 22:38:47 +00:00
Keith Yeung
efa3ed216e Disable region-liveness-drop-no-may-dangle.rs 2017-11-25 13:57:51 -08:00
Scott McMurray
62391c8c86 InstCombine Len([_; N]) => const N in MIR 2017-11-25 11:59:16 -08:00
Alex Crichton
fe53a8106d rustc: Add support for some more x86 SIMD ops
This commit adds compiler support for two basic operations needed for binding
SIMD on x86 platforms:

* First, a `nontemporal_store` intrinsic was added for the `_mm_stream_ps`, seen
  in rust-lang-nursery/stdsimd#114. This was relatively straightforward and is
  quite similar to the volatile store intrinsic.

* Next, and much more intrusively, a new type to the backend was added. The
  `x86_mmx` type is used in LLVM for a 64-bit vector register and is used in
  various intrinsics like `_mm_abs_pi8` as seen in rust-lang-nursery/stdsimd#74.
  This new type was added as a new layout option as well as having support added
  to the trans backend. The type is enabled with the `#[repr(x86_mmx)]`
  attribute which is intended to just be an implementation detail of SIMD in
  Rust.

I'm not 100% certain about how the `x86_mmx` type was added, so any extra eyes
or thoughts on that would be greatly appreciated!
2017-11-25 11:03:13 -08:00
bors
e97ba83287 Auto merge of #46115 - alexcrichton:add-wasm-target, r=kennytm
rustbuild: Enable WebAssembly backend by default

This commit alters how we compile LLVM by default enabling the WebAssembly
backend. This then also adds the wasm32-unknown-unknown target to get compiled
on the `cross` builder and distributed through rustup. Tests are not yet enabled
for this target but that should hopefully be coming soon!
2017-11-25 19:00:45 +00:00
Esteban Küber
15dfd7eb61 Fix test 2017-11-25 10:15:36 -08:00
bjorn3
0854bfbac9
Derive Debug for LangItem 2017-11-25 17:33:47 +01:00
Alex Crichton
48996f9e75 rustbuild: Enable WebAssembly backend by default
This commit alters how we compile LLVM by default enabling the WebAssembly
backend. This then also adds the wasm32-unknown-unknown target to get compiled
on the `cross` builder and distributed through rustup. Tests are not yet enabled
for this target but that should hopefully be coming soon!
2017-11-25 06:44:35 -08:00
bors
2f47a9eb80 Auto merge of #46191 - eddyb:better-late-than-never, r=nikomatsakis
rustc: don't mark lifetimes as early-bound in the presence of impl Trait.

This hack from the original implementation shouldn't be needed anymore, thanks to @cramertj.

r? @nikomatsakis
2017-11-25 14:28:20 +00:00
Shotaro Yamada
62cb74af3c Conform names 2017-11-25 23:27:16 +09:00
Basile Desloges
513910e321 Update MSVC compilation instructions regarding path length on Windows 2017-11-25 11:38:10 +01:00
bors
cc6b88ccb2 Auto merge of #46129 - kennytm:fix-46098-rustdoc-reexport-extern-type, r=GuillaumeGomez
Properly handle reexport of foreign items.

Handles `pub use` of `extern { fn, static, type }`. Also plug in some more `match` arms where handling `extern type` is reasonable.

Fixed #46098.
2017-11-25 08:38:42 +00:00
bors
59bf09d4d4 Auto merge of #46117 - SimonSapin:min-align, r=alexcrichton
allocators: don’t assume MIN_ALIGN for small sizes

See individual commit messages.
2017-11-25 06:16:19 +00:00
bors
ca8ef26293 Auto merge of #46081 - GuillaumeGomez:fix-path-search, r=QuietMisdreavus
Fix path search

Fixes #46015.

r? @QuietMisdreavus
2017-11-25 02:43:48 +00:00
bors
db162922f7 Auto merge of #46008 - alexcrichton:update-llvm, r=Mark-Simulacrum
rustbuild: Update LLVM and enable ThinLTO

This commit updates LLVM to fix #45511 (https://reviews.llvm.org/D39981) and
also reenables ThinLTO for libtest now that we shouldn't hit #45768. This also
opportunistically enables ThinLTO for libstd which was previously blocked
(#45661) on test failures related to debuginfo with a presumed cause of #45511.

Closes #45511
2017-11-25 00:17:03 +00:00
Alex Crichton
95e9609b9d std: Flag Windows TLS dtor symbol as #[used]
Turns out ThinLTO was internalizing this symbol and eliminating it. Worse yet if
you compiled with LTO turns out no TLS destructors would run on Windows! The
`#[used]` annotation should be a more bulletproof implementation (in the face of
LTO) of preserving this symbol all the way through in LLVM and ensuring it makes
it all the way to the linker which will take care of it.
2017-11-24 14:28:12 -08:00
bors
a550f2d3b3 Auto merge of #46111 - michaelwoerister:promote-green, r=nikomatsakis
incr.comp.: Make sure we don't lose unused green results from the query cache.

In its current implementation, the query result cache works by bulk-writing the results of all cacheable queries into a monolithic binary file on disk. Prior to this PR, we would potentially lose query results during this process because only results that had already been loaded into memory were serialized. In contrast, results that were not needed during the given compilation session were not serialized again.

This PR will do one pass over all green `DepNodes` that represent a cacheable query and execute the corresponding query in order to make sure that the query result gets loaded into memory before cache serialization.

In the future we might want to look into a serialization format the can be updated in-place so that we don't have to load unchanged results just for immediately storing them again.

r? @nikomatsakis
2017-11-24 21:50:09 +00:00
Keith Yeung
0996bb0901 Kill the storage for all locals on returning terminators 2017-11-24 12:00:59 -08:00
Esteban Küber
2461b7a264 Use get_parent_node instead of using spans 2017-11-24 08:26:45 -08:00
Esteban Küber
7c2526a9d7 Be more obvious when suggesting dereference
Include enclosing span when suggesting dereference on a span that is
already a reference:

```
error: non-reference pattern used to match a reference (see issue #42640)
  --> dont-suggest-dereference-on-arg.rs:16:19
   |
16 |         .filter(|&(ref a, _)| foo(a))
   |                  ^^^^^^^^^^^ help: consider using: `&&(ref k, _)`
   |
   = help: add #![feature(match_default_bindings)] to the crate attributes to enable
```
2017-11-24 08:26:01 -08:00
bors
5f44c653cf Auto merge of #46093 - scottmcm:lower-128-mir, r=nagisa
Add a MIR pass to lower 128-bit operators to lang item calls

Runs only with `-Z lower_128bit_ops` since it's not hooked into targets yet.

This isn't really useful on its own, but the declarations for the lang items need to be in the compiler before compiler-builtins can be updated to define them, so this is part 1 of at least 3.

cc https://github.com/rust-lang/rust/issues/45676 @est31 @nagisa
2017-11-24 15:11:11 +00:00
Alex Crichton
47498dea09 rustbuild: Update LLVM and enable ThinLTO
This commit updates LLVM to fix #45511 (https://reviews.llvm.org/D39981) and
also reenables ThinLTO for libtest now that we shouldn't hit #45768. This also
opportunistically enables ThinLTO for libstd which was previously blocked
(#45661) on test failures related to debuginfo with a presumed cause of #45511.

Closes #45511
2017-11-24 06:55:38 -08:00
bors
71da1c21eb Auto merge of #46116 - oli-obk:json_ui, r=nikomatsakis
Check //~ERROR comments in ui tests

r? @nikomatsakis

cc #44844 @Phlosioneer @estebank @petrochenkov

this depends on https://github.com/rust-lang/rust/pull/46052 getting merged first (the commits are included in here)

The relevant changes of this PR are c2f0af7 and 979269b
2017-11-24 12:38:11 +00:00
Oliver Schneider
8937d6a6cf
Merge cfail and ui tests into ui tests 2017-11-24 11:32:35 +01:00
bors
85d50ce1c7 Auto merge of #46012 - Gankro:float-conv-transmute, r=sfackler
Make float::from_bits transmute

See commit message for details.

See also this discussion here: https://github.com/rust-lang/rust/issues/40470#issuecomment-343803381

(may require libs team discussion before merging)
2017-11-24 10:06:09 +00:00
Lucas Morales
a1ad729a81
core::marker fix typo 2017-11-24 03:04:57 -06:00
Oliver Schneider
36066d8925
UI tests extract the regular output from the 'rendered' field in json 2017-11-24 08:06:43 +01:00
Oliver Schneider
f7361a8870
This method of once-diagnostics doesn't allow nesting 2017-11-24 08:06:43 +01:00
Oliver Schneider
7e07fd3e8d
Simplify an Iterator::fold to Iterator::any 2017-11-24 08:06:43 +01:00