Commit Graph

84626 Commits

Author SHA1 Message Date
Ralf Jung c96eb706f0 Fix and test upvar name printing for validity 2018-10-13 09:09:03 +02:00
Ralf Jung 69576fcdee make ENFORCE_VALIDITY a function
miri needs this extra flexibility
2018-10-13 09:09:03 +02:00
Ralf Jung 3272c9845c foreign types: use size and align from layout 2018-10-13 09:09:03 +02:00
Ralf Jung d0c585c525 seems like for generators we cannot access the freevars 2018-10-13 09:09:03 +02:00
Ralf Jung 93f53e5113 size_and_align_of can return no result for extern types 2018-10-13 09:09:03 +02:00
Ralf Jung f79a22c3d5 validate return value on stack pop 2018-10-13 09:09:02 +02:00
Ralf Jung a05914e2dc check return type even for uninhabited case 2018-10-13 09:09:02 +02:00
Ralf Jung 5b75ec0a91 fix validation around transmuting copy_op 2018-10-13 09:09:02 +02:00
bors c47785f6be Auto merge of #54945 - estebank:asm-span, r=petrochenkov
Point to variable in `asm!` macro when failing borrowck

Fix #34940.
2018-10-13 00:56:30 +00:00
bors 2c2e2c57dc Auto merge of #54942 - matthewjasper:wf-type-annotations, r=nikomatsakis
[NLL] Check user types are well-formed

Also contains a change of span for AscribeUserType.
I'm not quite sure if this was what @nikomatsakis was thinking.

Closes #54620

r? @nikomatsakis
2018-10-12 21:28:42 +00: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
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
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
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
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