]> git.lizzy.rs Git - rust.git/log
rust.git
5 years agoresolve: Scale back hard-coded extern prelude additions
Vadim Petrochenkov [Sat, 13 Oct 2018 18:24:50 +0000 (21:24 +0300)]
resolve: Scale back hard-coded extern prelude additions

5 years agoCopy extern prelude from resolver to global context
Vadim Petrochenkov [Sat, 13 Oct 2018 18:21:08 +0000 (21:21 +0300)]
Copy extern prelude from resolver to global context

5 years agoRevert "rustc_resolve: move extern_prelude from Resolver to Session."
Vadim Petrochenkov [Sat, 13 Oct 2018 16:07:17 +0000 (19:07 +0300)]
Revert "rustc_resolve: move extern_prelude from Resolver to Session."

This reverts commit e90985acdec9928da9f6d157cfeb64f0ee98bffe.

5 years agoAuto merge of #54951 - alexcrichton:more-wasm-threads, r=sfackler
bors [Sat, 13 Oct 2018 14:28:48 +0000 (14:28 +0000)]
Auto merge of #54951 - alexcrichton:more-wasm-threads, r=sfackler

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!

5 years agoAuto merge of #54997 - davidtwco:issue-54896, r=nagisa
bors [Sat, 13 Oct 2018 11:52:49 +0000 (11:52 +0000)]
Auto merge of #54997 - davidtwco:issue-54896, r=nagisa

The #[panic_handler] attribute can be applied to non-functions

Fixes #54896.

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.

r? @nagisa

5 years agoAuto merge of #54955 - RalfJung:miri-validate2, r=oli-obk
bors [Sat, 13 Oct 2018 09:20:48 +0000 (09:20 +0000)]
Auto merge of #54955 - RalfJung:miri-validate2, r=oli-obk

miri engine: Fix run-time validation

This fixes all false positives that came up when actually enabling this in miri.

r? @oli-obk

5 years agoupdate miri
Ralf Jung [Thu, 11 Oct 2018 08:18:31 +0000 (10:18 +0200)]
update miri

5 years agorun-time validation: accept undef in int arrays, as we do for ints
Ralf Jung [Fri, 12 Oct 2018 08:56:47 +0000 (10:56 +0200)]
run-time validation: accept undef in int arrays, as we do for ints

5 years agoaddress nits
Ralf Jung [Thu, 11 Oct 2018 11:13:14 +0000 (13:13 +0200)]
address nits

5 years agovalidation: accept pointers in integer arrays
Ralf Jung [Thu, 11 Oct 2018 09:15:30 +0000 (11:15 +0200)]
validation: accept pointers in integer arrays

5 years agoFix and test upvar name printing for validity
Ralf Jung [Thu, 11 Oct 2018 08:16:51 +0000 (10:16 +0200)]
Fix and test upvar name printing for validity

5 years agomake ENFORCE_VALIDITY a function
Ralf Jung [Thu, 11 Oct 2018 06:48:15 +0000 (08:48 +0200)]
make ENFORCE_VALIDITY a function

miri needs this extra flexibility

5 years agoforeign types: use size and align from layout
Ralf Jung [Wed, 10 Oct 2018 07:11:38 +0000 (09:11 +0200)]
foreign types: use size and align from layout

5 years agoseems like for generators we cannot access the freevars
Ralf Jung [Tue, 9 Oct 2018 20:44:20 +0000 (22:44 +0200)]
seems like for generators we cannot access the freevars

5 years agosize_and_align_of can return no result for extern types
Ralf Jung [Tue, 9 Oct 2018 20:41:41 +0000 (22:41 +0200)]
size_and_align_of can return no result for extern types

5 years agovalidate return value on stack pop
Ralf Jung [Tue, 9 Oct 2018 19:05:53 +0000 (21:05 +0200)]
validate return value on stack pop

5 years agocheck return type even for uninhabited case
Ralf Jung [Tue, 9 Oct 2018 16:16:27 +0000 (18:16 +0200)]
check return type even for uninhabited case

5 years agofix validation around transmuting copy_op
Ralf Jung [Tue, 9 Oct 2018 15:06:57 +0000 (17:06 +0200)]
fix validation around transmuting copy_op

5 years agoAuto merge of #54980 - zackmdavis:and_the_case_of_the_universal_call, r=oli-obk
bors [Sat, 13 Oct 2018 06:48:17 +0000 (06:48 +0000)]
Auto merge of #54980 - zackmdavis:and_the_case_of_the_universal_call, r=oli-obk

structured suggestion for E0223 ambiguous associated type

(routine (and when are we going to be done finding these, anyway?) but something that stuck out to me while glancing at #54970)

r? @estebank

5 years agoAuto merge of #54945 - estebank:asm-span, r=petrochenkov
bors [Sat, 13 Oct 2018 00:56:30 +0000 (00:56 +0000)]
Auto merge of #54945 - estebank:asm-span, r=petrochenkov

Point to variable in `asm!` macro when failing borrowck

Fix #34940.

5 years agoAuto merge of #54942 - matthewjasper:wf-type-annotations, r=nikomatsakis
bors [Fri, 12 Oct 2018 21:28:42 +0000 (21:28 +0000)]
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

5 years agoAuto merge of #55012 - kennytm:rollup, r=kennytm
bors [Fri, 12 Oct 2018 15:00:24 +0000 (15:00 +0000)]
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

5 years agoRollup merge of #54989 - Munksgaard:fix-htmldocck-typos, r=tmandry
kennytm [Fri, 12 Oct 2018 14:04:19 +0000 (22:04 +0800)]
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.

5 years agoRollup merge of #54983 - kzys:rand-bench, r=tmandry
kennytm [Fri, 12 Oct 2018 14:04:18 +0000 (22:04 +0800)]
Rollup merge of #54983 - kzys:rand-bench, r=tmandry

Fix slice's benchmarks

Fixes #54013.

5 years agoRollup merge of #54967 - holmgr:master, r=estebank
kennytm [Fri, 12 Oct 2018 14:04:16 +0000 (22:04 +0800)]
Rollup merge of #54967 - holmgr:master, r=estebank

Remove incorrect span for second label inner macro invocation

A fix for issue #54841

5 years agoRollup merge of #54958 - RalfJung:static-assert, r=oli-obk
kennytm [Fri, 12 Oct 2018 14:04:15 +0000 (22:04 +0800)]
Rollup merge of #54958 - RalfJung:static-assert, r=oli-obk

add a macro for static (compile-time) assertions

Cc @oli-obk

5 years agoRollup merge of #54956 - kzys:close-paren, r=varkor
kennytm [Fri, 12 Oct 2018 14:04:14 +0000 (22:04 +0800)]
Rollup merge of #54956 - kzys:close-paren, r=varkor

"(using ..." doesn't have the matching ")"

Fixes #54948.

5 years agoRollup merge of #54950 - alexcrichton:wasm-sync-allocator, r=sfackler
kennytm [Fri, 12 Oct 2018 14:04:13 +0000 (22:04 +0800)]
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`.

5 years agoRollup merge of #54936 - RalfJung:layout-hash, r=oli-obk
kennytm [Fri, 12 Oct 2018 14:04:12 +0000 (22:04 +0800)]
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.

5 years agoRollup merge of #54932 - ljedrz:a_handful_of_string_improvements, r=alexcrichton
kennytm [Fri, 12 Oct 2018 14:04:10 +0000 (22:04 +0800)]
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>`

5 years agoRollup merge of #54920 - varkor:must_use-unit, r=estebank
kennytm [Fri, 12 Oct 2018 14:04:09 +0000 (22:04 +0800)]
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.

5 years agoRollup merge of #54913 - RalfJung:unwind-safe, r=alexcrichton
kennytm [Fri, 12 Oct 2018 14:04:08 +0000 (22:04 +0800)]
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](https://github.com/RalfJung/rust/commit/0a13f1abafe70cddf34bf2b2ba3946c418ed6241).

5 years agoRollup merge of #54891 - rust-lang:SimonSapin-patch-1, r=nagisa
kennytm [Fri, 12 Oct 2018 14:04:07 +0000 (22:04 +0800)]
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

5 years agoRollup merge of #54869 - GuillaumeGomez:fix-mobile-docs, r=QuietMisdreavus
kennytm [Fri, 12 Oct 2018 14:04:05 +0000 (22:04 +0800)]
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

5 years agoRollup merge of #54860 - mandeep:vec-initialize, r=alexcrichton
kennytm [Fri, 12 Oct 2018 14:04:04 +0000 (22:04 +0800)]
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.

5 years agoRollup merge of #54825 - davidtwco:issue-52663-deref-raw-pointer, r=pnkfelix
kennytm [Fri, 12 Oct 2018 14:04:03 +0000 (22:04 +0800)]
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

5 years agoRollup merge of #54811 - pnkfelix:issue-24840-separate-bootstrap-default-for-optimize...
kennytm [Fri, 12 Oct 2018 14:04:01 +0000 (22:04 +0800)]
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

5 years agoRollup merge of #54755 - lucasloisp:document-reference-address-eq, r=QuietMisdreavus
kennytm [Fri, 12 Oct 2018 14:04:00 +0000 (22:04 +0800)]
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)

5 years agoAuto merge of #54715 - oli-obk:nll_deref_promotion, r=RalfJung
bors [Fri, 12 Oct 2018 12:00:50 +0000 (12:00 +0000)]
Auto merge of #54715 - oli-obk:nll_deref_promotion, r=RalfJung

Fix #54224 (const promotion regression)

r? @eddyb

5 years agoAuto merge of #53933 - GuillaumeGomez:codeblock-error-display, r=QuietMisdreavus
bors [Fri, 12 Oct 2018 09:23:10 +0000 (09:23 +0000)]
Auto merge of #53933 - GuillaumeGomez:codeblock-error-display, r=QuietMisdreavus

Improve error display for codeblocks in rustdoc

Part of #53919.

r? @QuietMisdreavus

5 years agoAdd comments explaining why some operations are not constant inside normal functions
Oliver Scherer [Fri, 12 Oct 2018 07:30:28 +0000 (09:30 +0200)]
Add comments explaining why some operations are not constant inside normal functions

5 years agoAuto merge of #54534 - nagisa:align-offset-simplification, r=alexcrichton
bors [Fri, 12 Oct 2018 06:38:11 +0000 (06:38 +0000)]
Auto merge of #54534 - nagisa:align-offset-simplification, r=alexcrichton

Simplify implementation of align_offset slightly

5 years agostructured suggestion for E0223 ambiguous associated type
Zack M. Davis [Thu, 11 Oct 2018 03:49:45 +0000 (20:49 -0700)]
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 ...

5 years agoAuto merge of #54924 - RalfJung:use-maybe-uninit2, r=cramertj
bors [Fri, 12 Oct 2018 02:14:47 +0000 (02:14 +0000)]
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.

5 years agoFix mobile doc display
Guillaume Gomez [Sat, 6 Oct 2018 16:51:56 +0000 (18:51 +0200)]
Fix mobile doc display

5 years agoAuto merge of #54592 - GabrielMajeri:no-plt, r=nagisa
bors [Thu, 11 Oct 2018 19:38:15 +0000 (19:38 +0000)]
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.

5 years agoUpdate minifier version
Guillaume Gomez [Sat, 6 Oct 2018 16:48:31 +0000 (18:48 +0200)]
Update minifier version

5 years agoSupport for disabling the PLT on ELF targets
Gabriel Majeri [Wed, 26 Sep 2018 16:19:55 +0000 (19:19 +0300)]
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

5 years agoExtend lang items to assert correct target.
David Wood [Thu, 11 Oct 2018 17:36:51 +0000 (19:36 +0200)]
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.

5 years agostd: Implement TLS for wasm32-unknown-unknown
Alex Crichton [Wed, 10 Oct 2018 06:10:25 +0000 (23:10 -0700)]
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!

5 years agoInclude rustdoc tests that have been fixed by #33133
Philip Munksgaard [Thu, 11 Oct 2018 16:18:32 +0000 (18:18 +0200)]
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.

5 years agoFix spelling in the documentation to htmldocck.py
Philip Munksgaard [Thu, 11 Oct 2018 12:34:43 +0000 (14:34 +0200)]
Fix spelling in the documentation to htmldocck.py

5 years agoAuto merge of #54911 - ljedrz:cleanup_codegen_llvm_top, r=michaelwoerister
bors [Thu, 11 Oct 2018 11:57:06 +0000 (11:57 +0000)]
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

5 years agoimpl Eq+Hash for TyLayout
Ralf Jung [Tue, 9 Oct 2018 16:48:44 +0000 (18:48 +0200)]
impl Eq+Hash for TyLayout

5 years agoAuto merge of #54850 - mcr431:fix-54707-trait-function-from-macro, r=nikomatsakis
bors [Thu, 11 Oct 2018 09:19:23 +0000 (09:19 +0000)]
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.

5 years agoAuto merge of #54969 - Manishearth:rollup, r=Manishearth
bors [Thu, 11 Oct 2018 06:26:03 +0000 (06:26 +0000)]
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

5 years agoFix slice's benchmarks
Kazuyoshi Kato [Thu, 11 Oct 2018 05:54:04 +0000 (22:54 -0700)]
Fix slice's benchmarks

Fixes #54013.

5 years agoAuto merge of #54848 - davidtwco:issue-52663-trait-object, r=nikomatsakis
bors [Thu, 11 Oct 2018 03:32:12 +0000 (03:32 +0000)]
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

5 years agoRollup merge of #54909 - scalexm:finish-rules, r=nikomatsakis
Manish Goregaokar [Wed, 10 Oct 2018 22:59:25 +0000 (15:59 -0700)]
Rollup merge of #54909 - scalexm:finish-rules, r=nikomatsakis

Fixes #47311.
r? @nrc

5 years agoRollup merge of #54904 - Kerollmops:stabilize-option-replace, r=Centril
Manish Goregaokar [Wed, 10 Oct 2018 22:59:23 +0000 (15:59 -0700)]
Rollup merge of #54904 - Kerollmops:stabilize-option-replace, r=Centril

Fixes #47311.
r? @nrc

5 years agoRollup merge of #54893 - dsciarra:issue-54379, r=pnkfelix
Manish Goregaokar [Wed, 10 Oct 2018 22:59:21 +0000 (15:59 -0700)]
Rollup merge of #54893 - dsciarra:issue-54379, r=pnkfelix

Fixes #47311.
r? @nrc

5 years agoRollup merge of #54870 - flip1995:stabilize_tool_lints, r=Manishearth
Manish Goregaokar [Wed, 10 Oct 2018 22:59:20 +0000 (15:59 -0700)]
Rollup merge of #54870 - flip1995:stabilize_tool_lints, r=Manishearth

Fixes #47311.
r? @nrc

5 years agoRollup merge of #54862 - Havvy:cfg_attr_multi, r=petrochenkov
Manish Goregaokar [Wed, 10 Oct 2018 22:58:40 +0000 (15:58 -0700)]
Rollup merge of #54862 - Havvy:cfg_attr_multi, r=petrochenkov

Fixes #47311.
r? @nrc

5 years agoRollup merge of #54848 - davidtwco:issue-52663-trait-object, r=nikomatsakis
Manish Goregaokar [Wed, 10 Oct 2018 22:58:38 +0000 (15:58 -0700)]
Rollup merge of #54848 - davidtwco:issue-52663-trait-object, r=nikomatsakis

Fixes #47311.
r? @nrc

5 years agoAuto merge of #54747 - levex:inline-asm-bad-operands, r=nagisa
bors [Wed, 10 Oct 2018 22:24:48 +0000 (22:24 +0000)]
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!

5 years agoAuto merge of #54732 - cramertj:waker, r=aturon
bors [Wed, 10 Oct 2018 18:28:30 +0000 (18:28 +0000)]
Auto merge of #54732 - cramertj:waker, r=aturon

LocalWaker and Waker cleanups

r? @aturon

5 years agoRemove incorrect span for second label inner macro invocation
holmgr [Wed, 10 Oct 2018 13:34:06 +0000 (15:34 +0200)]
Remove incorrect span for second label inner macro invocation

5 years agoCheck user types are well-formed in MIR borrow check
Matthew Jasper [Wed, 10 Oct 2018 07:38:17 +0000 (08:38 +0100)]
Check user types are well-formed in MIR borrow check

Also update some tests so that they don't have user types on `_` in
unreachable code.

5 years agoAuto merge of #54802 - davidtwco:issue-53040, r=pnkfelix
bors [Wed, 10 Oct 2018 14:51:01 +0000 (14:51 +0000)]
Auto merge of #54802 - davidtwco:issue-53040, r=pnkfelix

[nll] better error message when returning refs to upvars

Fixes #53040.

r? @nikomatsakis

5 years agoAuto merge of #54461 - RalfJung:pointer-provenance, r=oli-obk
bors [Wed, 10 Oct 2018 12:13:03 +0000 (12:13 +0000)]
Auto merge of #54461 - RalfJung:pointer-provenance, r=oli-obk

miri engine: basic support for pointer provenance tracking

This enriches pointers with a new member, `tag`, that can be used to do provenance tracking. This is a new type parameter that propagates up through everything. It defaults to `()` (no tag), which is also the value used by CTFE -- but miri will use another type.

The only actually interesting piece here, I think, is what I had to do in the memory's `get`. The problem is that `tcx` (storing the allocations for statics) uses `()` for provenance information. But the machine might need another tag. The machine has a function to do the conversion, but if a conversion actually happened, we need to store the result of this *somewhere* -- we cannot return a pointer into `tcx` as we usually would.
So I introduced `MonoHashMap` which uses `RefCell` to be able to insert new entries even when we just have a shared ref. However, it is important that we can also return shared refs into the map without holding the `RefCell` opan. This is achieved by boxing the values stored in the map, so their addresses remain stable even when the map's table gets reallocated. This is all implemented in `mono_hash_map.rs`.

NOTE: This PR also contains the commits from https://github.com/rust-lang/rust/pull/54380#issuecomment-423130753. Only the [last two commits](https://github.com/rust-lang/rust/pull/54461/files/8e74ee0998a5b11f28d61600dbb881c7168a4a40..HEAD) are new.

5 years agoUse the span of the user type for `AscribeUserType`
Matthew Jasper [Tue, 9 Oct 2018 21:59:46 +0000 (22:59 +0100)]
Use the span of the user type for `AscribeUserType`

Also change the order of the fake read for let and the AscribeUserType,
so that we use the better span and message from the fake read in errors.

5 years agotidy up
Ralf Jung [Wed, 10 Oct 2018 09:31:31 +0000 (11:31 +0200)]
tidy up

5 years agoadd a macro for static assertions
Ralf Jung [Wed, 10 Oct 2018 09:03:58 +0000 (11:03 +0200)]
add a macro for static assertions

5 years agoA handful of random string-related improvements
ljedrz [Tue, 9 Oct 2018 12:30:14 +0000 (14:30 +0200)]
A handful of random string-related improvements

5 years agovtables are not leaks
Ralf Jung [Fri, 5 Oct 2018 16:08:36 +0000 (18:08 +0200)]
vtables are not leaks

5 years agomore comments for these sublte games we are playing with allocations in the miri...
Ralf Jung [Fri, 5 Oct 2018 14:49:51 +0000 (16:49 +0200)]
more comments for these sublte games we are playing with allocations in the miri engine

5 years ago"(using ..." doesn't have the matching ")"
Kazuyoshi Kato [Wed, 10 Oct 2018 08:09:18 +0000 (01:09 -0700)]
"(using ..." doesn't have the matching ")"

Fixes #54948.

5 years agoabstract mono_hash_map through a trait, only miri actually needs the fancy one
Ralf Jung [Fri, 5 Oct 2018 13:13:59 +0000 (15:13 +0200)]
abstract mono_hash_map through a trait, only miri actually needs the fancy one

5 years agotypos and spaces
Ralf Jung [Fri, 5 Oct 2018 08:28:33 +0000 (10:28 +0200)]
typos and spaces

5 years agoclarify alloc_map description
Ralf Jung [Fri, 5 Oct 2018 08:23:39 +0000 (10:23 +0200)]
clarify alloc_map description

5 years agofix typos
Ralf Jung [Thu, 4 Oct 2018 16:53:16 +0000 (18:53 +0200)]
fix typos

5 years agoexpand safety comment in memory.rs
Ralf Jung [Tue, 2 Oct 2018 12:45:41 +0000 (14:45 +0200)]
expand safety comment in memory.rs

5 years agorename extra -> meta in place
Ralf Jung [Sat, 29 Sep 2018 19:35:20 +0000 (21:35 +0200)]
rename extra -> meta in place

5 years agoexpand comment
Ralf Jung [Sat, 29 Sep 2018 07:51:38 +0000 (09:51 +0200)]
expand comment

5 years agotidy, oh tidy
Ralf Jung [Sat, 22 Sep 2018 11:36:46 +0000 (13:36 +0200)]
tidy, oh tidy

5 years agomiri engine: basic support for pointer provenance tracking
Ralf Jung [Fri, 21 Sep 2018 21:32:59 +0000 (23:32 +0200)]
miri engine: basic support for pointer provenance tracking

5 years agoremove a now outdated comment
Ralf Jung [Wed, 10 Oct 2018 07:16:05 +0000 (09:16 +0200)]
remove a now outdated comment

5 years agoAuto merge of #54831 - davidtwco:issue-52663-struct-field-suggestion, r=nikomatsakis
bors [Wed, 10 Oct 2018 06:36:11 +0000 (06:36 +0000)]
Auto merge of #54831 - davidtwco:issue-52663-struct-field-suggestion, r=nikomatsakis

NLL is missing struct field suggestion

Part of #52663.

This commit adds suggestions to change the definitions of fields in
struct definitions from immutable references to mutable references.

r? @nikomatsakis
cc @pnkfelix

5 years agostd: Synchronize global allocator on wasm32
Alex Crichton [Wed, 10 Oct 2018 03:18:10 +0000 (20:18 -0700)]
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`.

5 years agoAuto merge of #54764 - tromey:test-rust-lldb, r=alexcrichton
bors [Wed, 10 Oct 2018 02:08:23 +0000 (02:08 +0000)]
Auto merge of #54764 - tromey:test-rust-lldb, r=alexcrichton

Run debuginfo tests against rust-enabled lldb, when possible

If the rust-enabled lldb was built, then use it when running the
debuginfo tests.  Updating the lldb submodule was necessary as this
needed a way to differentiate the rust-enabled lldb, so I added a line
to the --version output.

This adds compiletest commands to differentiate between the
rust-enabled and non-rust-enabled lldb, as is already done for gdb.  A
new "rust-lldb" header directive is also added, but not used in this
patch; I plan to use it in #54004.

This updates all the tests.

5 years agoRemove nightly check for tool_lints warning
flip1995 [Tue, 2 Oct 2018 16:15:13 +0000 (18:15 +0200)]
Remove nightly check for tool_lints warning

5 years agoRemove unstable-book documentation
flip1995 [Tue, 2 Oct 2018 09:19:38 +0000 (11:19 +0200)]
Remove unstable-book documentation

5 years agoRemove feature-gate code
flip1995 [Tue, 2 Oct 2018 08:59:41 +0000 (10:59 +0200)]
Remove feature-gate code

5 years agoRemove feature-gate tests
flip1995 [Tue, 2 Oct 2018 08:51:12 +0000 (10:51 +0200)]
Remove feature-gate tests

5 years agoRemove `feature(tool_lints)` from tests
flip1995 [Tue, 2 Oct 2018 08:44:49 +0000 (10:44 +0200)]
Remove `feature(tool_lints)` from tests

5 years agoUpdate feature-gate listing
flip1995 [Tue, 2 Oct 2018 08:37:56 +0000 (10:37 +0200)]
Update feature-gate listing

5 years agoPoint to variable in `asm!` macro when failing borrowck
Esteban Küber [Tue, 9 Oct 2018 22:53:37 +0000 (15:53 -0700)]
Point to variable in `asm!` macro when failing borrowck

5 years agoAuto merge of #54734 - pawroman:fix_range_borrowing_suggestion, r=varkor
bors [Tue, 9 Oct 2018 22:36:14 +0000 (22:36 +0000)]
Auto merge of #54734 - pawroman:fix_range_borrowing_suggestion, r=varkor

Fix range literals borrowing suggestions

Fixes #54505. The compiler issued incorrect range borrowing suggestions (missing `()` around borrows of range literals). This was not correct syntax (see the issue for an example).

With changes in this PR, this is fixed for all types of `Range` literals.

Thanks again to @varkor and @estebank for their invaluable help and guidance.

r? @varkor

5 years agoAuto merge of #54613 - matthiaskrgr:string_from_inline_53681, r=nagisa
bors [Tue, 9 Oct 2018 19:57:55 +0000 (19:57 +0000)]
Auto merge of #54613 - matthiaskrgr:string_from_inline_53681, r=nagisa

liballoc: mark str.to_owned() and String::from(&str) as #[inline].

Fixes #53681

5 years agoAuto merge of #54762 - RalfJung:miri-validate, r=oli-obk
bors [Tue, 9 Oct 2018 17:19:56 +0000 (17:19 +0000)]
Auto merge of #54762 - RalfJung:miri-validate, r=oli-obk

Prepare miri engine for enforcing validity invariant during execution

In particular, make recursive checking of references optional, and add a `const_mode` parameter that says whether `usize` is allowed to contain a pointer. Also refactor validation a bit to be type-driven at the "leafs" (primitive types), and separately validate scalar layout to catch `NonNull` violations (which it did not properly validate before).

Fixes https://github.com/rust-lang/rust/issues/53826
Also fixes https://github.com/rust-lang/rust/issues/54751

r? @oli-obk