Commit Graph

84786 Commits

Author SHA1 Message Date
memoryruins
b041a79f26 Add test for issue #52240
Closes #52240
2018-10-12 13:08:44 -04:00
Andy Russell
0e268d9e89
add test for #24421
Fixes #24421.
2018-10-12 13:07:39 -04:00
memoryruins
146fbc6a96 Add test for issue #54966
Closes #54966
2018-10-12 12:42:33 -04:00
Andy Russell
3855af5734
add test for #23189
Fixes #23189.
2018-10-12 12:21:22 -04:00
bors
945372d268 Auto merge of #55012 - kennytm:rollup, r=kennytm
Rollup of 16 pull requests

Successful merges:

 - #54755 (Documents reference equality by address (#54197))
 - #54811 (During rustc bootstrap, make default for `optimize` independent of `debug`)
 - #54825 (NLL says "borrowed content" instead of more precise "dereference of raw pointer")
 - #54860 (Add doc comments about safest way to initialize a vector of zeros)
 - #54869 (Fix mobile docs)
 - #54891 (Fix tracking issue for Once::is_completed)
 - #54913 (doc fix: it's auto traits that make for automatic implementations)
 - #54920 (Fix handling of #[must_use] on unit and uninhabited types)
 - #54932 (A handful of random string-related improvements)
 - #54936 (impl Eq+Hash for TyLayout)
 - #54950 (std: Synchronize global allocator on wasm32)
 - #54956 ("(using ..." doesn't have the matching ")")
 - #54958 (add a macro for static (compile-time) assertions)
 - #54967 (Remove incorrect span for second label inner macro invocation)
 - #54983 (Fix slice's benchmarks)
 - #54989 (Fix spelling in the documentation to htmldocck.py)

Failed merges:

r? @ghost
2018-10-12 15:00:24 +00:00
kennytm
d64c77a671
Rollup merge of #54989 - Munksgaard:fix-htmldocck-typos, r=tmandry
Fix spelling in the documentation to htmldocck.py

I was reading through htmldocck.py, and decided to attempt to clean it up a little bit. Let me know if you disagree with my edits.
2018-10-12 22:04:19 +08:00
kennytm
9eae552a44
Rollup merge of #54983 - kzys:rand-bench, r=tmandry
Fix slice's benchmarks

Fixes #54013.
2018-10-12 22:04:18 +08:00
kennytm
644dbf99ed
Rollup merge of #54967 - holmgr:master, r=estebank
Remove incorrect span for second label inner macro invocation

A fix for issue #54841
2018-10-12 22:04:16 +08:00
kennytm
0187e81da9
Rollup merge of #54958 - RalfJung:static-assert, r=oli-obk
add a macro for static (compile-time) assertions

Cc @oli-obk
2018-10-12 22:04:15 +08:00
kennytm
8e3f189180
Rollup merge of #54956 - kzys:close-paren, r=varkor
"(using ..." doesn't have the matching ")"

Fixes #54948.
2018-10-12 22:04:14 +08:00
kennytm
8d3d96f08a
Rollup merge of #54950 - alexcrichton:wasm-sync-allocator, r=sfackler
std: Synchronize global allocator on wasm32

We originally didn't have threads, and now we're starting to add them!
Make sure we properly synchronize access to dlmalloc when the `atomics`
feature is enabled for `wasm32-unknown-unknown`.
2018-10-12 22:04:13 +08:00
kennytm
4f1a618e5d
Rollup merge of #54936 - RalfJung:layout-hash, r=oli-obk
impl Eq+Hash for TyLayout

As proposed by @eddyb at https://github.com/rust-lang/rust/pull/53671#pullrequestreview-159761136.

I have an upcoming PR that would also significantly benefit from this.
2018-10-12 22:04:12 +08:00
kennytm
fcb3ce4f53
Rollup merge of #54932 - ljedrz:a_handful_of_string_improvements, r=alexcrichton
A handful of random string-related improvements

- remove a few allocations in `errors/diagnostic`
- make `build_helper::gnu_target` return `Cow<str>`
2018-10-12 22:04:10 +08:00
kennytm
b39535d157
Rollup merge of #54920 - varkor:must_use-unit, r=estebank
Fix handling of #[must_use] on unit and uninhabited types

Fixes https://github.com/rust-lang/rust/issues/54828.
2018-10-12 22:04:09 +08:00
kennytm
80ee322a20
Rollup merge of #54913 - RalfJung:unwind-safe, r=alexcrichton
doc fix: it's auto traits that make for automatic implementations

Being a marker trait is not good enough (that just means "no items in the trait").

r? @alexcrichton who [originally wrote these docs](0a13f1abaf).
2018-10-12 22:04:08 +08:00
kennytm
ef7f77d53d
Rollup merge of #54891 - rust-lang:SimonSapin-patch-1, r=nagisa
Fix tracking issue for Once::is_completed

https://github.com/rust-lang/rust/pull/53027 was merged without a tracking issue. I just filed https://github.com/rust-lang/rust/issues/54890. CC @matklad
2018-10-12 22:04:07 +08:00
kennytm
8d85b893d8
Rollup merge of #54869 - GuillaumeGomez:fix-mobile-docs, r=QuietMisdreavus
Fix mobile docs

Fixes #54836.

<img width="1440" alt="screen shot 2018-10-06 at 18 53 19" src="https://user-images.githubusercontent.com/3050060/46573683-1b4cd700-c999-11e8-9e6b-86a23b332e22.png">

r? @QuietMisdreavus
2018-10-12 22:04:05 +08:00
kennytm
365d4c94f6
Rollup merge of #54860 - mandeep:vec-initialize, r=alexcrichton
Add doc comments about safest way to initialize a vector of zeros

This adds more information about the vec! macro as discussed in #54628. I think this is a good starting point, but I think additional detail is needed so that we can explain why vec! is safer than the alternatives.
2018-10-12 22:04:04 +08:00
kennytm
44a527a27a
Rollup merge of #54825 - davidtwco:issue-52663-deref-raw-pointer, r=pnkfelix
NLL says "borrowed content" instead of more precise "dereference of raw pointer"

Part of #52663.

Previously, move errors involving the dereference of a raw pointer would
say "borrowed content". This commit changes it to say "dereference of
raw pointer".

r? @nikomatsakis
cc @pnkfelix
2018-10-12 22:04:03 +08:00
kennytm
e03db2301e
Rollup merge of #54811 - pnkfelix:issue-24840-separate-bootstrap-default-for-optimize-from-debug-setting, r=nikomatsakis
During rustc bootstrap, make default for `optimize` independent of `debug`

It may have taken me three and a half years, but I'm following through on my ["threat"](https://github.com/rust-lang/rust/issues/24840#issuecomment-97911700)

Fix #24840
2018-10-12 22:04:01 +08:00
kennytm
8455468d0d
Rollup merge of #54755 - lucasloisp:document-reference-address-eq, r=QuietMisdreavus
Documents reference equality by address (#54197)

Clarification of the use of `ptr::eq` to test equality of references via address by pointer coercion,  regarding issue #54197 .

The same example as in `ptr::eq` docs is shown here to clarify that
`PartialEq` compares values pointed-to instead of via address (which can be desired in some cases)
2018-10-12 22:04:00 +08:00
ljedrz
39753c8973 rustc/driver: improve macro calls 2018-10-12 14:01:25 +02:00
bors
e9e27e6a62 Auto merge of #54715 - oli-obk:nll_deref_promotion, r=RalfJung
Fix #54224 (const promotion regression)

r? @eddyb
2018-10-12 12:00:50 +00:00
ljedrz
5bfe08fc71 rustc/driver: simplify profile::trace::cons 2018-10-12 13:55:35 +02:00
bors
849a0e9c40 Auto merge of #53933 - GuillaumeGomez:codeblock-error-display, r=QuietMisdreavus
Improve error display for codeblocks in rustdoc

Part of #53919.

r? @QuietMisdreavus
2018-10-12 09:23:10 +00:00
Oliver Scherer
76f8a90d53 Add comments explaining why some operations are not constant inside normal functions 2018-10-12 09:30:28 +02:00
bors
8dc554a325 Auto merge of #54534 - nagisa:align-offset-simplification, r=alexcrichton
Simplify implementation of align_offset slightly
2018-10-12 06:38:11 +00:00
Zack M. Davis
a5de379b55 structured suggestion for E0223 ambiguous associated type
It looks like we tend to use angle-brackets around the placeholder in
the few other places we use `Applicability::HasPlaceholders`, but that
would be confusing here, so ...
2018-10-11 21:10:35 -07:00
bors
567557f630 Auto merge of #54924 - RalfJung:use-maybe-uninit2, r=cramertj
Use MaybeUninit in liballoc

All code by @japaric. This is a re-submission of a part of https://github.com/rust-lang/rust/pull/53508 that hopefully does not regress performance.
2018-10-12 02:14:47 +00:00
Guillaume Gomez
c5a025aae6 Fix mobile doc display 2018-10-11 22:23:39 +02:00
bors
77af314083 Auto merge of #54592 - GabrielMajeri:no-plt, r=nagisa
Support for disabling PLT for better function call performance

This PR gives `rustc` the ability to skip the PLT when generating function calls into shared libraries. This can improve performance by reducing branch indirection.

AFAIK, the only advantage of using the PLT is to allow for ELF lazy binding. However, since Rust already [enables full relro for security](https://github.com/rust-lang/rust/pull/43170), lazy binding was disabled anyway.

This is a little known feature which is supported by [GCC](https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html) and [Clang](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fplt) as `-fno-plt` (some Linux distros [enable it by default](https://git.archlinux.org/svntogit/packages.git/tree/trunk/makepkg.conf?h=packages/pacman#n40) for all builds).

Implementation inspired by [this patch](https://reviews.llvm.org/D39079#change-YvkpNDlMs_LT) which adds `-fno-plt` support to Clang.

## Performance

I didn't run a lot of benchmarks, but these are the results on my machine for a `clap` [benchmark](https://github.com/clap-rs/clap/blob/master/benches/05_ripgrep.rs):

```
 name              control ns/iter  no-plt ns/iter  diff ns/iter  diff %  speedup
 build_app_long    11,097           10,733                  -364  -3.28%   x 1.03
 build_app_short   11,089           10,742                  -347  -3.13%   x 1.03
 build_help_long   186,835          182,713               -4,122  -2.21%   x 1.02
 build_help_short  80,949           78,455                -2,494  -3.08%   x 1.03
 parse_clean       12,385           12,044                  -341  -2.75%   x 1.03
 parse_complex     19,438           19,017                  -421  -2.17%   x 1.02
 parse_lots        431,493          421,421              -10,072  -2.33%   x 1.02
```

A small performance improvement across the board, with no downsides. It's likely binaries which make a lot of function calls into dynamic libraries could see even more improvements. [This comment](https://patchwork.ozlabs.org/patch/468993/#1028255) suggests that, in some cases, `-fno-plt` could improve PIC/PIE code performance by 10%.

## Security benefits

**Bonus**: some of the speculative execution attacks rely on the PLT, by disabling it we reduce a big attack surface and reduce the need for [`retpoline`](https://reviews.llvm.org/D41723).

## Remaining PLT calls

The compiled binaries still have plenty of PLT calls, coming from C/C++ libraries. Building dependencies with `CFLAGS=-fno-plt CXXFLAGS=-fno-plt` removes them.
2018-10-11 19:38:15 +00:00
Guillaume Gomez
ca517a6ee9 Update minifier version 2018-10-11 21:37:04 +02:00
Gabriel Majeri
6009da0794 Support for disabling the PLT on ELF targets
Disable the PLT where possible to improve performance
for indirect calls into shared libraries.

This optimization is enabled by default where possible.

- Add the `NonLazyBind` attribute to `rustllvm`:
  This attribute informs LLVM to skip PLT calls in codegen.

- Disable PLT unconditionally:
  Apply the `NonLazyBind` attribute on every function.

- Only enable no-plt when full relro is enabled:
  Ensures we only enable it when we have linker support.

- Add `-Z plt` as a compiler option
2018-10-11 21:11:00 +03:00
David Wood
2ecce7ccc5
Extend lang items to assert correct target.
This commit extends the existing lang items functionality to assert
that the `#[lang_item]` attribute is only found on the appropriate item
for any given lang item. That is, language items representing traits
must only ever have their corresponding attribute placed on a trait, for
example.
2018-10-11 19:36:51 +02:00
Alex Crichton
cbe9f33b8b std: Implement TLS for wasm32-unknown-unknown
This adds an implementation of thread local storage for the
`wasm32-unknown-unknown` target when the `atomics` feature is
implemented. This, however, comes with a notable caveat of that it
requires a new feature of the standard library, `wasm-bindgen-threads`,
to be enabled.

Thread local storage for wasm (when `atomics` are enabled and there's
actually more than one thread) is powered by the assumption that an
external entity can fill in some information for us. It's not currently
clear who will fill in this information nor whose responsibility it
should be long-term. In the meantime there's a strategy being gamed out
in the `wasm-bindgen` project specifically, and the hope is that we can
continue to test and iterate on the standard library without committing
to a particular strategy yet.

As to the details of `wasm-bindgen`'s strategy, LLVM doesn't currently
have the ability to emit custom `global` values (thread locals in a
`WebAssembly.Module`) so we leverage the `wasm-bindgen` CLI tool to do
it for us. To that end we have a few intrinsics, assuming two global values:

* `__wbindgen_current_id` - gets the current thread id as a 32-bit
  integer. It's `wasm-bindgen`'s responsibility to initialize this
  per-thread and then inform libstd of the id. Currently `wasm-bindgen`
  performs this initialization as part of the `start` function.
* `__wbindgen_tcb_{get,set}` - in addition to a thread id it's assumed
  that there's a global available for simply storing a pointer's worth
  of information (a thread control block, which currently only contains
  thread local storage). This would ideally be a native `global`
  injected by LLVM, but we don't have a great way to support that right
  now.

To reiterate, this is all intended to be unstable and purely intended
for testing out Rust on the web with threads. The story is very likely
to change in the future and we want to make sure that we're able to do
that!
2018-10-11 09:57:55 -07:00
Philip Munksgaard
1de8f51849 Include rustdoc tests that have been fixed by #33133
There was an issue (#33025) which caused these tests to not work. The issue has
since been fixed in #33133, and so we can now include them.
2018-10-11 18:25:55 +02:00
Philip Munksgaard
6c7eb1406d Fix spelling in the documentation to htmldocck.py 2018-10-11 14:37:56 +02:00
bors
b8b4150c04 Auto merge of #54911 - ljedrz:cleanup_codegen_llvm_top, r=michaelwoerister
Cleanup top-level codegen_llvm

- improve allocations
- improve common patterns
- remove explicit returns
- fix spelling & grammatical errors
- whitespace & formatting improvements
2018-10-11 11:57:06 +00:00
Ralf Jung
99db3e9bce impl Eq+Hash for TyLayout 2018-10-11 12:51:53 +02:00
bors
a534216fa6 Auto merge of #54850 - mcr431:fix-54707-trait-function-from-macro, r=nikomatsakis
Fix #54707 - parse_trait_item_ now handles interpolated blocks as function body decls

Fix #54707 - parse_trait_item_ now handles interpolated blocks as function body decls

Previously parsing trait items only handled opening brace token and semicolon, I added a branch to the match statement that will also handle interpolated blocks.
2018-10-11 09:19:23 +00:00
bors
cb6eeddd4d Auto merge of #54969 - Manishearth:rollup, r=Manishearth
Rollup of 9 pull requests

Successful merges:

 - #54747 (codegen_llvm: verify that inline assembly operands are scalars)
 - #54848 (Better Diagnostic for Trait Object Capture)
 - #54850 (Fix #54707 - parse_trait_item_ now handles interpolated blocks as function body decls)
 - #54858 (second round of refactorings for universes)
 - #54862 (Implement RFC 2539: cfg_attr with multiple attributes)
 - #54869 (Fix mobile docs)
 - #54870 (Stabilize tool lints)
 - #54893 (Fix internal compiler error on malformed match arm pattern.)
 - #54904 (Stabilize the `Option::replace` method)

Failed merges:

 - #54909 ( Add chalk rules related to associated type defs)

r? @ghost
2018-10-11 06:26:03 +00:00
Kazuyoshi Kato
f930087159 Fix slice's benchmarks
Fixes #54013.
2018-10-10 22:55:12 -07:00
bors
9746a2d40d Auto merge of #54848 - davidtwco:issue-52663-trait-object, r=nikomatsakis
Better Diagnostic for Trait Object Capture

Part of #52663.

This commit enhances `LaterUseKind` detection to identify when a borrow
is captured by a trait object which helps explain why there is a borrow
error.

r? @nikomatsakis
cc @pnkfelix
2018-10-11 03:32:12 +00:00
Manish Goregaokar
be64bf3b9d Rollup merge of #54909 - scalexm:finish-rules, r=nikomatsakis
Fixes #47311.
r? @nrc
2018-10-10 15:59:25 -07:00
Manish Goregaokar
ff3e4d9f1c Rollup merge of #54904 - Kerollmops:stabilize-option-replace, r=Centril
Fixes #47311.
r? @nrc
2018-10-10 15:59:23 -07:00
Manish Goregaokar
e1e628ec87 Rollup merge of #54893 - dsciarra:issue-54379, r=pnkfelix
Fixes #47311.
r? @nrc
2018-10-10 15:59:21 -07:00
Manish Goregaokar
50e410c240 Rollup merge of #54870 - flip1995:stabilize_tool_lints, r=Manishearth
Fixes #47311.
r? @nrc
2018-10-10 15:59:20 -07:00
Manish Goregaokar
8ebc6d6dbb Rollup merge of #54862 - Havvy:cfg_attr_multi, r=petrochenkov
Fixes #47311.
r? @nrc
2018-10-10 15:58:40 -07:00
Manish Goregaokar
a267b3a9ff Rollup merge of #54848 - davidtwco:issue-52663-trait-object, r=nikomatsakis
Fixes #47311.
r? @nrc
2018-10-10 15:58:38 -07:00
bors
f42c510f2f Auto merge of #54747 - levex:inline-asm-bad-operands, r=nagisa
codegen_llvm: verify that inline assembly operands are scalars

Another set of inline assembly fixes. This time let's emit an error message when the operand value cannot be coerced into the operand constraint.

Two questions:

1) Should I reuse `E0668` which was introduced in #54568 or just use `E0669` as it stands because they do mean different things, but maybe that's not too user-friendly. Just a thought.
2) The `try_fold` returns the operand which failed to be converted into a scalar value, any suggestions on how to use that in the error message?

Thanks!
2018-10-10 22:24:48 +00:00