]> git.lizzy.rs Git - rust.git/log
rust.git
5 years agoRollup merge of #56114 - varkor:nonexhaustive-backticks, r=nikomatsakis
Guillaume Gomez [Thu, 29 Nov 2018 12:10:33 +0000 (13:10 +0100)]
Rollup merge of #56114 - varkor:nonexhaustive-backticks, r=nikomatsakis

Enclose type in backticks for "non-exhaustive patterns" error

This makes the error style consistent with the convention in error messages.

5 years agoRollup merge of #56080 - mark-i-m:patch-2, r=steveklabnik
Guillaume Gomez [Thu, 29 Nov 2018 12:10:31 +0000 (13:10 +0100)]
Rollup merge of #56080 - mark-i-m:patch-2, r=steveklabnik

Reduce the amount of bold text at doc.rlo

Currently, all of the text is either huge or small. IMHO this is hard to read, so I propose that we make the second-level headings smaller, without making them any less prominent.

# Before:

![image](https://user-images.githubusercontent.com/8827840/48737315-50447e80-ec13-11e8-8243-6211dbba1aa1.png)

# After:

![image](https://user-images.githubusercontent.com/8827840/48737258-32771980-ec13-11e8-814e-e7851954c05a.png)

5 years agoRollup merge of #56023 - vorner:doc/atomic-ordering-strip, r=@stjepang
Guillaume Gomez [Thu, 29 Nov 2018 12:10:30 +0000 (13:10 +0100)]
Rollup merge of #56023 - vorner:doc/atomic-ordering-strip, r=@stjepang

atomic::Ordering: Get rid of misleading parts of intro

Remove the parts of atomic::Ordering's intro that wrongly claimed that
SeqCst prevents all reorderings around it.

Closes #55196

This is a (minimal) alternative to #55233.

I also wonder if it would be worth adding at least some warnings that atomics are often a footgun/hard to use correctly, similarly like `mem::transmute` or other functions have.

5 years agoRollup merge of #56021 - RalfJung:track-features, r=oli-obk
Guillaume Gomez [Thu, 29 Nov 2018 12:10:28 +0000 (13:10 +0100)]
Rollup merge of #56021 - RalfJung:track-features, r=oli-obk

avoid features_untracked

The docs say to not use `features_untracked` when we have a tcx.

@oli-obk any particular reason why the untracked version is used all over const qualification?

5 years agoRollup merge of #55391 - matthiaskrgr:bootstrap_cleanup, r=TimNN
Guillaume Gomez [Thu, 29 Nov 2018 12:10:27 +0000 (13:10 +0100)]
Rollup merge of #55391 - matthiaskrgr:bootstrap_cleanup, r=TimNN

bootstrap: clean up a few clippy findings

remove useless format!()s
remove redundant field names in a few struct initializations
pass slice instead of a vector to a function
use is_empty() instead of comparisons to .len()

No functional change intended.

5 years agoAuto merge of #56245 - mark-i-m:stabilize_ques_kleene, r=alexcrichton
bors [Thu, 29 Nov 2018 06:44:12 +0000 (06:44 +0000)]
Auto merge of #56245 - mark-i-m:stabilize_ques_kleene, r=alexcrichton

Stabilize feature `macro_at_most_once_rep`

a.k.a. `?` Kleene operator :tada:

cc #48075

r? @Centril

5 years agoAuto merge of #56329 - eddyb:load-operand-overaligned, r=nikomatsakis
bors [Thu, 29 Nov 2018 02:56:24 +0000 (02:56 +0000)]
Auto merge of #56329 - eddyb:load-operand-overaligned, r=nikomatsakis

rustc_codegen_llvm: don't overalign loads of pair operands.

Counterpart to #56300, but for loads instead of stores.

5 years agoAuto merge of #56300 - nikic:issue-56267, r=eddyb
bors [Thu, 29 Nov 2018 00:06:20 +0000 (00:06 +0000)]
Auto merge of #56300 - nikic:issue-56267, r=eddyb

Fix alignment of stores to scalar pair

The alignment for the second element of a scalar pair is not the same as for the first element, make sure it is calculated correctly. This fixes #56267.

r? @eddyb

5 years agorustc_codegen_llvm: don't overalign loads of pair operands.
Eduard-Mihai Burtescu [Wed, 28 Nov 2018 22:37:38 +0000 (00:37 +0200)]
rustc_codegen_llvm: don't overalign loads of pair operands.

5 years agofix test
Mark Mansi [Wed, 28 Nov 2018 00:21:10 +0000 (18:21 -0600)]
fix test

5 years agoFix alignment of stores to scalar pair
Nikita Popov [Tue, 27 Nov 2018 23:25:40 +0000 (00:25 +0100)]
Fix alignment of stores to scalar pair

The alignment for the second element of a scalar pair is not the
same as for the first element. Make sure it is computed correctly
based on the element size.

5 years agoAuto merge of #56293 - matthiaskrgr:clippy, r=oli-obk
bors [Tue, 27 Nov 2018 21:54:39 +0000 (21:54 +0000)]
Auto merge of #56293 - matthiaskrgr:clippy, r=oli-obk

submodules: update clippy from 754b4c07 to b2601beb

Changes:
````
Fix NAIVE_BYTECOUNT applicability
Fix dogfood error
Change Applicability of MISTYPED_LITERAL_SUFFIX
Add applicability level to (nearly) every span_lint_and_sugg function
Update stderr file
Fix bugs and improve documentation
Add Applicability::Unspecified to span_lint_and_sugg functions
Introduce snippet_with_applicability and hir_with_applicability functions
readme: tell how to install clippy on travis from git if it is not shipped with a nightly.
constants: add u128 i128 builtin types and fix outdated url
Update lints
Lint only the first statment/expression after alloc
Fix some warnings related to Self
Rename some symbols
Split lint into slow and unsafe vector initalization
Add unsafe set_len initialization
Add slow zero-filled vector initialization lint
Travis: Remove `sudo: false`
Downgrade needless_pass_by_value to allow by default
````

5 years agosubmodules: update clippy from 754b4c07 to b2601beb
Matthias Krüger [Tue, 27 Nov 2018 20:21:57 +0000 (21:21 +0100)]
submodules: update clippy from 754b4c07 to b2601beb

Changes:
````
Fix NAIVE_BYTECOUNT applicability
Fix dogfood error
Change Applicability of MISTYPED_LITERAL_SUFFIX
Add applicability level to (nearly) every span_lint_and_sugg function
Update stderr file
Fix bugs and improve documentation
Add Applicability::Unspecified to span_lint_and_sugg functions
Introduce snippet_with_applicability and hir_with_applicability functions
readme: tell how to install clippy on travis from git if it is not shipped with a nightly.
constants: add u128 i128 builtin types and fix outdated url
Update lints
Lint only the first statment/expression after alloc
Fix some warnings related to Self
Rename some symbols
Split lint into slow and unsafe vector initalization
Add unsafe set_len initialization
Add slow zero-filled vector initialization lint
Travis: Remove `sudo: false`
Downgrade needless_pass_by_value to allow by default
````

5 years agofix test
Mark Mansi [Sun, 25 Nov 2018 00:40:03 +0000 (18:40 -0600)]
fix test

5 years agoremove uses of feature gate
Mark Mansi [Sat, 24 Nov 2018 23:26:15 +0000 (17:26 -0600)]
remove uses of feature gate

5 years agoremove unstable book entry
Mark Mansi [Sat, 24 Nov 2018 22:29:43 +0000 (16:29 -0600)]
remove unstable book entry

5 years agoupdate tests
Mark Mansi [Sat, 24 Nov 2018 22:27:13 +0000 (16:27 -0600)]
update tests

5 years agoremove some unused vars
Mark Mansi [Sat, 24 Nov 2018 22:20:25 +0000 (16:20 -0600)]
remove some unused vars

5 years agoremove feature gate
Mark Mansi [Sat, 24 Nov 2018 22:12:16 +0000 (16:12 -0600)]
remove feature gate

5 years agomove feature gate to accepted
Mark Mansi [Sat, 24 Nov 2018 22:09:37 +0000 (16:09 -0600)]
move feature gate to accepted

5 years agoAuto merge of #56264 - petrochenkov:typonly, r=nikomatsakis
bors [Tue, 27 Nov 2018 19:04:44 +0000 (19:04 +0000)]
Auto merge of #56264 - petrochenkov:typonly, r=nikomatsakis

resolve: Extern prelude is for type namespace only

Fixes https://github.com/rust-lang/rust/issues/56263 (stable-to-beta regression)

5 years agoAuto merge of #56251 - scalexm:root-universe, r=nikomatsakis
bors [Tue, 27 Nov 2018 15:54:21 +0000 (15:54 +0000)]
Auto merge of #56251 - scalexm:root-universe, r=nikomatsakis

Put all existential ty vars in the `ROOT` universe

r? @nikomatsakis

5 years agoavoid features_untracked
Ralf Jung [Sat, 17 Nov 2018 12:57:53 +0000 (13:57 +0100)]
avoid features_untracked

5 years agoAuto merge of #55402 - estebank:macro-eof-2, r=nikomatsakis
bors [Tue, 27 Nov 2018 12:31:45 +0000 (12:31 +0000)]
Auto merge of #55402 - estebank:macro-eof-2, r=nikomatsakis

Point at end of macro arm when encountering EOF

Fix #52866.

5 years agoresolve: Extern prelude is for type namespace only
Vadim Petrochenkov [Tue, 27 Nov 2018 00:26:37 +0000 (03:26 +0300)]
resolve: Extern prelude is for type namespace only

5 years agoAuto merge of #56094 - RalfJung:memory-data-revived, r=oli-obk
bors [Tue, 27 Nov 2018 09:30:15 +0000 (09:30 +0000)]
Auto merge of #56094 - RalfJung:memory-data-revived, r=oli-obk

miri: Memory data revived, Hooks for stack frame push/pop

r? @oli-obk

5 years agoAuto merge of #56262 - petrochenkov:nabsedihyg, r=petrochenkov
bors [Tue, 27 Nov 2018 01:02:37 +0000 (01:02 +0000)]
Auto merge of #56262 - petrochenkov:nabsedihyg, r=petrochenkov

[master] resolve: Implement edition hygiene for imports and absolute paths

Forward-port of https://github.com/rust-lang/rust/pull/56053 to master.

r? @ghost

5 years agoAuto merge of #54668 - RalfJung:use-maybe-uninit, r=SimonSapin
bors [Mon, 26 Nov 2018 22:20:20 +0000 (22:20 +0000)]
Auto merge of #54668 - RalfJung:use-maybe-uninit, r=SimonSapin

Use MaybeUninit in libcore

All code by @japaric. This re-submits the second half of https://github.com/rust-lang/rust/pull/53508 (the first half is at https://github.com/rust-lang/rust/pull/54667). This is likely the one containing the perf regression.

5 years agoresolve: Suggest `crate::` for resolving ambiguities when appropriate
Vadim Petrochenkov [Sun, 25 Nov 2018 13:08:43 +0000 (16:08 +0300)]
resolve: Suggest `crate::` for resolving ambiguities when appropriate

More precise spans for ambiguities from macros

5 years agoresolve: Fallback to extern prelude in 2015 imports used from global 2018 edition
Vadim Petrochenkov [Sat, 24 Nov 2018 21:25:03 +0000 (00:25 +0300)]
resolve: Fallback to extern prelude in 2015 imports used from global 2018 edition

5 years agoresolve: Generalize `early_resolve_ident_in_lexical_scope` slightly
Vadim Petrochenkov [Sat, 24 Nov 2018 16:14:05 +0000 (19:14 +0300)]
resolve: Generalize `early_resolve_ident_in_lexical_scope` slightly

Flatten `ModuleOrUniformRoot` variants

5 years agoresolve: Fallback to uniform paths in 2015 imports used from global 2018 edition
Vadim Petrochenkov [Sat, 24 Nov 2018 12:07:03 +0000 (15:07 +0300)]
resolve: Fallback to uniform paths in 2015 imports used from global 2018 edition

5 years agoresolve: Implement edition hygiene for imports and absolute paths
Vadim Petrochenkov [Sun, 18 Nov 2018 00:25:59 +0000 (03:25 +0300)]
resolve: Implement edition hygiene for imports and absolute paths

Use per-span hygiene in a few other places in resolve
Prefer `rust_2015`/`rust_2018` helpers to comparing editions

5 years agoRemove duplicate tests for uniform paths
Vadim Petrochenkov [Thu, 22 Nov 2018 21:50:15 +0000 (00:50 +0300)]
Remove duplicate tests for uniform paths

5 years agoPut all existential ty vars in the `ROOT` universe
scalexm [Mon, 26 Nov 2018 19:37:43 +0000 (20:37 +0100)]
Put all existential ty vars in the `ROOT` universe

5 years agoAuto merge of #55835 - alexcrichton:llvm-upgrade, r=nikomatsakis
bors [Mon, 26 Nov 2018 12:14:13 +0000 (12:14 +0000)]
Auto merge of #55835 - alexcrichton:llvm-upgrade, r=nikomatsakis

Upgrade LLVM to trunk, still version 8

This commit upgrades the LLVM/LLD/compiler-rt submodules used to the current trunk versions in upstream. Some activity has happened on the wasm SIMD side of things as well as LLD which we'd like to pick up!

5 years agoAuto merge of #56070 - oli-obk:const_let, r=eddyb
bors [Mon, 26 Nov 2018 08:17:36 +0000 (08:17 +0000)]
Auto merge of #56070 - oli-obk:const_let, r=eddyb

Allow assignments in const contexts

fixes https://github.com/rust-lang/rust/issues/54098
fixes https://github.com/rust-lang/rust/issues/51251
fixes https://github.com/rust-lang/rust/issues/52613

5 years agoTemporarily disable LLDB
Alex Crichton [Mon, 26 Nov 2018 04:28:26 +0000 (20:28 -0800)]
Temporarily disable LLDB

5 years agoPass `--export-dynamic` to LLD for wasm
Alex Crichton [Sat, 10 Nov 2018 18:04:17 +0000 (10:04 -0800)]
Pass `--export-dynamic` to LLD for wasm

This should handle recent symbol visibility changes happening, although
we'll likely want to tweak this in the future!

5 years agowasm: Pass `--no-demangle` to LLD
Alex Crichton [Fri, 9 Nov 2018 21:51:00 +0000 (13:51 -0800)]
wasm: Pass `--no-demangle` to LLD

Our mangling scheme is not C++'s, so tell LLD to not demangle anything
so we can handle Rust-specific demangling ourselves.

5 years agoConditionally compile in only the extra argument.
Edd Barrett [Wed, 7 Nov 2018 12:34:43 +0000 (12:34 +0000)]
Conditionally compile in only the extra argument.

5 years agoMake Rustc build with LLVM trunk.
Edd Barrett [Wed, 7 Nov 2018 12:05:54 +0000 (12:05 +0000)]
Make Rustc build with LLVM trunk.

5 years agoHandle some renamed ThinLTO functions
Alex Crichton [Fri, 9 Nov 2018 21:09:32 +0000 (13:09 -0800)]
Handle some renamed ThinLTO functions

5 years agoUpgrade to LLVM trunk
Alex Crichton [Fri, 9 Nov 2018 20:54:04 +0000 (12:54 -0800)]
Upgrade to LLVM trunk

5 years agoAuto merge of #55705 - ethanboxx:master, r=SimonSapin
bors [Mon, 26 Nov 2018 01:46:18 +0000 (01:46 +0000)]
Auto merge of #55705 - ethanboxx:master, r=SimonSapin

Make `ParseIntError` and `IntErrorKind` fully public

Why would you write nice error types if I can't read them?

# Why

It can be useful to use `match` with errors produced when parsing strings to int. This would be useful for the `.err_match()` function in my [new crate](https://crates.io/crates/read_input).

---
I could also do this for `ParseFloatError` if people think it is a good idea.
I am new around hear so please tell me if I am getting anything wrong.

5 years agoAuto merge of #56194 - eddyb:top-unhack, r=alexcrichton
bors [Sun, 25 Nov 2018 22:00:08 +0000 (22:00 +0000)]
Auto merge of #56194 - eddyb:top-unhack, r=alexcrichton

Try to make top-level Cargo.toml work without __CARGO_TEST_ROOT.

The last failures I noticed before adding the `__CARGO_TEST_ROOT` hack were in `src/test/run-make/thumb-none-{cortex-m,qemu}`, and had to do with the fact that the top-level `Cargo.toml` uses nightly Cargo features.

If that's the only problem, this PR should work, and we can figure out how to unbreak RLS.

5 years agoHACK(eddyb) Cargo.toml: also exclude the `obj` directory from the workspace.
Eduard-Mihai Burtescu [Sun, 25 Nov 2018 21:15:20 +0000 (23:15 +0200)]
HACK(eddyb) Cargo.toml: also exclude the `obj` directory from the workspace.

5 years agoCargo.toml: exclude the `build` directory from the workspace.
Eduard-Mihai Burtescu [Sun, 25 Nov 2018 12:59:52 +0000 (14:59 +0200)]
Cargo.toml: exclude the `build` directory from the workspace.

5 years agoTry to make top-level Cargo.toml work without __CARGO_TEST_ROOT.
Eduard-Mihai Burtescu [Sat, 24 Nov 2018 07:31:01 +0000 (09:31 +0200)]
Try to make top-level Cargo.toml work without __CARGO_TEST_ROOT.

5 years agofix missing borrow
Ethan Brierley [Sun, 25 Nov 2018 19:44:09 +0000 (19:44 +0000)]
fix missing borrow

5 years agoUse a reference rather than take ownership
Ethan Brierley [Sun, 25 Nov 2018 19:31:35 +0000 (19:31 +0000)]
Use a reference rather than take ownership

5 years agoAuto merge of #55527 - sgeisler:time-checked-add, r=sfackler
bors [Sun, 25 Nov 2018 19:01:35 +0000 (19:01 +0000)]
Auto merge of #55527 - sgeisler:time-checked-add, r=sfackler

Implement checked_add_duration for SystemTime

[Original discussion on the rust user forum](https://users.rust-lang.org/t/std-systemtime-misses-a-checked-add-function/21785)

Since `SystemTime` is opaque there is no way to check if the result of an addition will be in bounds. That makes the `Add<Duration>` trait completely unusable with untrusted data. This is a big problem because adding a `Duration` to `UNIX_EPOCH` is the standard way of constructing a `SystemTime` from a unix timestamp.

This PR implements `checked_add_duration(&self, &Duration) -> Option<SystemTime>` for `std::time::SystemTime` and as a prerequisite also for all platform specific time structs. This also led to the refactoring of many `add_duration(&self, &Duration) -> SystemTime` functions to avoid redundancy (they now unwrap the result of `checked_add_duration`).

Some basic unit tests for the newly introduced function were added too.

I wasn't sure which stabilization attribute to add to the newly introduced function, so I just chose `#[stable(feature = "time_checked_add", since = "1.32.0")]` for now to make it compile. Please let me know how I should change it or if I violated any other conventions.

P.S.: I could only test on Linux so far, so I don't necessarily expect it to compile for all platforms.

5 years agoAuto merge of #56215 - pietroalbini:rollup, r=pietroalbini
bors [Sun, 25 Nov 2018 16:08:01 +0000 (16:08 +0000)]
Auto merge of #56215 - pietroalbini:rollup, r=pietroalbini

Rollup of 14 pull requests

Successful merges:

 - #56024 (Don't auto-inline const functions)
 - #56045 (Check arg/ret sizedness at ExprKind::Path)
 - #56072 (Stabilize macro_literal_matcher)
 - #56075 (Encode a custom "producers" section in wasm files)
 - #56100 (generator fields are not necessarily initialized)
 - #56101 (Incorporate `dyn` into more comments and docs.)
 - #56144 (Fix BTreeSet and BTreeMap gdb pretty-printers)
 - #56151 (Move a flaky process test out of libstd)
 - #56170 (Fix self profiler ICE on Windows)
 - #56176 (Panic setup msg)
 - #56204 (Suggest correct enum variant on typo)
 - #56207 (Stabilize the int_to_from_bytes feature)
 - #56210 (read_c_str should call the AllocationExtra hooks)
 - #56211 ([master] Forward-ports from beta)

Failed merges:

r? @ghost

5 years agoRollup merge of #56211 - petrochenkov:fwd, r=petrochenkov
Pietro Albini [Sun, 25 Nov 2018 16:05:12 +0000 (17:05 +0100)]
Rollup merge of #56211 - petrochenkov:fwd, r=petrochenkov

[master] Forward-ports from beta

https://github.com/rust-lang/rust/pull/56206 + one commit from https://github.com/rust-lang/rust/pull/55884 that was accidentally missing in https://github.com/rust-lang/rust/pull/56042 due to an off-by-one mistake in commit ranges

r? @ghost

5 years agoRollup merge of #56210 - RalfJung:c_str, r=oli-obk
Pietro Albini [Sun, 25 Nov 2018 16:05:11 +0000 (17:05 +0100)]
Rollup merge of #56210 - RalfJung:c_str, r=oli-obk

read_c_str should call the AllocationExtra hooks

I just hope we do not have other methods that bypass `get_bytes`/`get_bytes_mut`... (looking over the file, I could not find any)

r? @oli-obk

5 years agoRollup merge of #56207 - SimonSapin:int_to_from_bytes, r=nagisa
Pietro Albini [Sun, 25 Nov 2018 16:05:10 +0000 (17:05 +0100)]
Rollup merge of #56207 - SimonSapin:int_to_from_bytes, r=nagisa

Stabilize the int_to_from_bytes feature

Fixes #52963

FCP to merge completed: https://github.com/rust-lang/rust/issues/52963#issuecomment-416548327

5 years agoRollup merge of #56204 - estebank:suggest-variant, r=zackmdavis
Pietro Albini [Sun, 25 Nov 2018 16:05:09 +0000 (17:05 +0100)]
Rollup merge of #56204 - estebank:suggest-variant, r=zackmdavis

Suggest correct enum variant on typo

Fix #37992.

5 years agoRollup merge of #56176 - GuillaumeGomez:panic-setup-msg, r=nagisa
Pietro Albini [Sun, 25 Nov 2018 16:05:08 +0000 (17:05 +0100)]
Rollup merge of #56176 - GuillaumeGomez:panic-setup-msg, r=nagisa

Panic setup msg

Fixes #56088.

5 years agoRollup merge of #56170 - wesleywiser:fix_self_profiler_windows, r=estebank
Pietro Albini [Sun, 25 Nov 2018 16:05:07 +0000 (17:05 +0100)]
Rollup merge of #56170 - wesleywiser:fix_self_profiler_windows, r=estebank

Fix self profiler ICE on Windows

Fixes #51648

5 years agoRollup merge of #56151 - alexcrichton:move-out-flaky-test, r=nagisa
Pietro Albini [Sun, 25 Nov 2018 16:05:05 +0000 (17:05 +0100)]
Rollup merge of #56151 - alexcrichton:move-out-flaky-test, r=nagisa

Move a flaky process test out of libstd

This test ensures that everything in `env::vars()` is inherited but
that's not actually true because other tests may add env vars after we
spawn the process, causing the test to be flaky! This commit moves the
test to a run-pass test where it can execute in isolation.

Along the way this removes a lot of the platform specificity of the
test, using iteslf to print the environment instead of a foreign process.

5 years agoRollup merge of #56144 - tromey:Bug-55771-btreemap, r=alexcrichton
Pietro Albini [Sun, 25 Nov 2018 16:05:04 +0000 (17:05 +0100)]
Rollup merge of #56144 - tromey:Bug-55771-btreemap, r=alexcrichton

Fix BTreeSet and BTreeMap gdb pretty-printers

The BTreeSet and BTreeMap gdb pretty-printers did not take the node
structure into account, and consequently only worked for shallow sets.
This fixes the problem by iterating over child nodes when needed.

This patch avoids the current approach of implementing some of the
value manipulations in debugger-indepdendent code.  This was done for
convenience: a type lookup was needed for the first time, and there
currently are no lldb formatters for these types.

Closes #55771

5 years agoRollup merge of #56101 - frewsxcv:frewsxcv-dyn, r=steveklabnik
Pietro Albini [Sun, 25 Nov 2018 16:05:03 +0000 (17:05 +0100)]
Rollup merge of #56101 - frewsxcv:frewsxcv-dyn, r=steveklabnik

Incorporate `dyn` into more comments and docs.

r? @rust-lang/docs

5 years agoRollup merge of #56100 - RalfJung:visiting-generators, r=oli-obk
Pietro Albini [Sun, 25 Nov 2018 16:05:02 +0000 (17:05 +0100)]
Rollup merge of #56100 - RalfJung:visiting-generators, r=oli-obk

generator fields are not necessarily initialized

Looking at the MIR we generate for generators, I think we deliberately leave fields of the generator uninitialized in ways that would be illegal if this was a normal struct (or rather, one would have to use `MaybeUninit`). Consider [this example](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=417b4a2950421b726dd7b307e9ee3bec):
```rust
#![feature(generators, generator_trait)]

fn main() {
    let generator = || {
        let mut x = Box::new(5);
        {
            let y = &mut *x;
            *y = 5;
            yield *y;
            *y = 10;
        }
        *x
    };
    let _gen = generator;
}
```

It generates the MIR
```
fn main() -> (){
    let mut _0: ();                      // return place
    scope 1 {
        scope 3 {
        }
        scope 4 {
            let _2: [generator@src/main.rs:4:21: 13:6 for<'r> {std::boxed::Box<i32>, i32, &'r mut i32, ()}]; // "_gen" in scope 4 at src/main.rs:14:9: 14:13
        }
    }
    scope 2 {
        let _1: [generator@src/main.rs:4:21: 13:6 for<'r> {std::boxed::Box<i32>, i32, &'r mut i32, ()}]; // "generator" in scope 2 at src/main.rs:4:9: 4:18
    }

    bb0: {
        StorageLive(_1);                 // bb0[0]: scope 0 at src/main.rs:4:9: 4:18
        (_1.0: u32) = const 0u32;        // bb0[1]: scope 0 at src/main.rs:4:21: 13:6
                                         // ty::Const
                                         // + ty: u32
                                         // + val: Scalar(Bits { size: 4, bits: 0 })
                                         // mir::Constant
                                         // + span: src/main.rs:4:21: 13:6
                                         // + ty: u32
                                         // + literal: Const { ty: u32, val: Scalar(Bits { size: 4, bits: 0 }) }
        StorageLive(_2);                 // bb0[2]: scope 1 at src/main.rs:14:9: 14:13
        _2 = move _1;                    // bb0[3]: scope 1 at src/main.rs:14:16: 14:25
        drop(_2) -> bb1;                 // bb0[4]: scope 1 at src/main.rs:15:1: 15:2
    }

    bb1: {
        StorageDead(_2);                 // bb1[0]: scope 1 at src/main.rs:15:1: 15:2
        StorageDead(_1);                 // bb1[1]: scope 0 at src/main.rs:15:1: 15:2
        return;                          // bb1[2]: scope 0 at src/main.rs:15:2: 15:2
    }
}
```
Notice how we only initialize the first field of `_1` (even though it contains a `Box`!), and then assign it to `_2`. This violates the rule "on assignment, all data must satisfy the validity invariant", and hence miri complains about this code.

What this PR effectively does is to change the validity invariant for generators such that it says nothing about the fields of the generator. We behave as if every field of the generator was wrapped in a `MaybeUninit`.

r? @oli-obk

Cc @nikomatsakis @eddyb @cramertj @withoutboats @Zoxc

5 years agoRollup merge of #56075 - alexcrichton:wasm-producer-section, r=estebank
Pietro Albini [Sun, 25 Nov 2018 16:05:01 +0000 (17:05 +0100)]
Rollup merge of #56075 - alexcrichton:wasm-producer-section, r=estebank

Encode a custom "producers" section in wasm files

This commit implements WebAssembly/tool-conventions#65 for wasm files
produced by the Rust compiler. This adds a bit of metadata to wasm
modules to indicate that the file's language includes Rust and the
file's "processed-by" tools includes rustc.

The thinking with this section is to eventually have telemetry in
browsers tracking all this.

5 years agoRollup merge of #56072 - da-x:stabilize-literal-matcher, r=petrochenkov
Pietro Albini [Sun, 25 Nov 2018 16:05:00 +0000 (17:05 +0100)]
Rollup merge of #56072 - da-x:stabilize-literal-matcher, r=petrochenkov

Stabilize macro_literal_matcher

This followed FCP in #35625.

Closes #35625

5 years agoRollup merge of #56045 - qnighy:additional-sizedness, r=cramertj
Pietro Albini [Sun, 25 Nov 2018 16:04:58 +0000 (17:04 +0100)]
Rollup merge of #56045 - qnighy:additional-sizedness, r=cramertj

Check arg/ret sizedness at ExprKind::Path

This PR solves three problems:

- #50940: ICE on casting unsized tuple struct constructors
- Unsized tuple struct constructors were callable in presence of `unsized_locals`.
- https://github.com/rust-lang/rust/issues/48055#issuecomment-437178966: we cannot relax `Sized` bounds on stable functions because of fn ptr casting

These are caused by lack of `Sized`ness checks for arguments/retvals at **reference sites of `FnDef` items** (not call sites of the functions). Therefore we can basically add more `Sized` obligations on typeck. However, adding `Sized` obligations arbitrarily breaks type inference; to prevent that I added a new method `require_type_is_sized_deferred` which doesn't interfere usual type inference.

5 years agoRollup merge of #56024 - oli-obk:const_fn_collect_inner, r=michaelwoerister
Pietro Albini [Sun, 25 Nov 2018 16:04:57 +0000 (17:04 +0100)]
Rollup merge of #56024 - oli-obk:const_fn_collect_inner, r=michaelwoerister

Don't auto-inline const functions

fixes #53451

5 years agoresolve: Fix some more asserts in import validation
Vadim Petrochenkov [Sun, 25 Nov 2018 02:45:43 +0000 (05:45 +0300)]
resolve: Fix some more asserts in import validation

5 years agoresolve: Fix bad span arithmetics in import conflict diagnostics
Vadim Petrochenkov [Sun, 25 Nov 2018 01:25:59 +0000 (04:25 +0300)]
resolve: Fix bad span arithmetics in import conflict diagnostics

5 years agoresolve: Prohibit relative paths in visibilities on 2018 edition
Vadim Petrochenkov [Tue, 30 Oct 2018 21:22:19 +0000 (00:22 +0300)]
resolve: Prohibit relative paths in visibilities on 2018 edition

5 years agoTypo
Oliver S̶c̶h̶n̶e̶i̶d̶e̶r Scherer [Sun, 25 Nov 2018 13:21:34 +0000 (14:21 +0100)]
Typo

Co-Authored-By: RalfJung <post@ralfj.de>
5 years agoAuto merge of #55906 - nnethercote:rm-OpenSnapshot-CommittedSnapshot, r=nikomatsakis
bors [Sun, 25 Nov 2018 12:20:18 +0000 (12:20 +0000)]
Auto merge of #55906 - nnethercote:rm-OpenSnapshot-CommittedSnapshot, r=nikomatsakis

Clean up and streamline snapshot data structures

These commits clean up the snapshot structures a bit, so they are more consistent with each other and with the `ena` crate.

They also remove the `OpenSnapshot` and `CommittedSnapshot` entries in the undo log, just like I did for the `ena` crate in https://github.com/rust-lang-nursery/ena/pull/14. This PR in combination with that `ena` PR reduces instruction counts by up to 6% on benchmarks.

r? @nikomatsakis. Note that this isn't quite ready for landing, because the `ena` dependency in the first commit needs to be updated once https://github.com/rust-lang-nursery/ena/pull/14 lands. But otherwise it should be good.

5 years agofix length of slice returned from read_c_str
Ralf Jung [Sun, 25 Nov 2018 11:07:20 +0000 (12:07 +0100)]
fix length of slice returned from read_c_str

5 years agoyay for NLL
Ralf Jung [Sun, 25 Nov 2018 10:23:21 +0000 (11:23 +0100)]
yay for NLL

5 years agoread_c_str should call the AllocationExtra hooks
Ralf Jung [Sun, 25 Nov 2018 09:56:10 +0000 (10:56 +0100)]
read_c_str should call the AllocationExtra hooks

5 years agoTypo
Oliver S̶c̶h̶n̶e̶i̶d̶e̶r Scherer [Tue, 20 Nov 2018 08:47:36 +0000 (09:47 +0100)]
Typo

Co-Authored-By: RalfJung <post@ralfj.de>
5 years agoaccept undef in raw pointers, for consistency with integers
Ralf Jung [Sat, 17 Nov 2018 13:05:00 +0000 (14:05 +0100)]
accept undef in raw pointers, for consistency with integers

5 years agomachine hooks for stack push and pop, frame machine data
Ralf Jung [Thu, 15 Nov 2018 16:14:53 +0000 (17:14 +0100)]
machine hooks for stack push and pop, frame machine data

5 years agomake memory allocation hook infallible
Ralf Jung [Thu, 15 Nov 2018 12:25:22 +0000 (13:25 +0100)]
make memory allocation hook infallible

5 years agopass MemoryExtra to find_foreign_static and adjust_static_allocation; they might...
Ralf Jung [Thu, 15 Nov 2018 11:03:38 +0000 (12:03 +0100)]
pass MemoryExtra to find_foreign_static and adjust_static_allocation; they might have to create allocations

5 years agobring back MemoryExtra
Ralf Jung [Wed, 14 Nov 2018 15:00:52 +0000 (16:00 +0100)]
bring back MemoryExtra

5 years agoStabilize the int_to_from_bytes feature
Simon Sapin [Sun, 25 Nov 2018 07:26:22 +0000 (08:26 +0100)]
Stabilize the int_to_from_bytes feature

Fixes #52963

5 years agoRemove `OpenSnapshot` and `CommittedSnapshot` markers from `RegionConstraintCollector`.
Nicholas Nethercote [Mon, 5 Nov 2018 01:21:54 +0000 (12:21 +1100)]
Remove `OpenSnapshot` and `CommittedSnapshot` markers from `RegionConstraintCollector`.

They're not strictly necessary, and they result in the `Vec` being
allocated even for the trivial (and common) case where a
`start_snapshot` is immediately followed by a `commit` or `rollback_to`.

The commit also removes a now-unnecessary argument of
`pop_placeholders()`.

5 years agoRemove `OpenSnapshot` and `CommittedSnapshot` markers from `SnapshotMap`.
Nicholas Nethercote [Sun, 4 Nov 2018 23:59:33 +0000 (10:59 +1100)]
Remove `OpenSnapshot` and `CommittedSnapshot` markers from `SnapshotMap`.

They're not strictly necessary, and they result in the `Vec` being
allocated even for the trivial (and common) case where a
`start_snapshot` is immediately followed by a `commit` or `rollback_to`.

5 years agoIntroduce `in_snapshot` and `assert_open_snapshot` methods.
Nicholas Nethercote [Sun, 4 Nov 2018 23:44:52 +0000 (10:44 +1100)]
Introduce `in_snapshot` and `assert_open_snapshot` methods.

This makes the two snapshot implementations more consistent with each
other and with crate `ena`.

5 years agoMake `commit` and `rollback_to` methods take ownership of the snapshots.
Nicholas Nethercote [Sun, 4 Nov 2018 23:37:23 +0000 (10:37 +1100)]
Make `commit` and `rollback_to` methods take ownership of the snapshots.

Because they shouldn't be reused. This provides consistency with the
`ena` crate.

5 years agoReplace a `.truncate(0)` call with `.clear()`.
Nicholas Nethercote [Sun, 4 Nov 2018 22:35:28 +0000 (09:35 +1100)]
Replace a `.truncate(0)` call with `.clear()`.

5 years agoRename `UndoLogEntry` as `UndoLog`.
Nicholas Nethercote [Sun, 4 Nov 2018 22:34:37 +0000 (09:34 +1100)]
Rename `UndoLogEntry` as `UndoLog`.

So that it matches `librustc_data_structures/snapshot_map/mod.rs` and
the `ena` crate.

5 years agoRemove `insert_noop`.
Nicholas Nethercote [Sun, 4 Nov 2018 22:28:12 +0000 (09:28 +1100)]
Remove `insert_noop`.

Because it's as useless as its name suggests.

This commit also renames `UndoLog::Noop` as `UndoLog::Purged`, because
(a) that's a more descriptive name and (b) it matches the name used in
similar code in `librustc/infer/region_constraints/mod.rs`.

5 years agoUpdate to `ena` 0.11.0.
Nicholas Nethercote [Fri, 2 Nov 2018 08:46:59 +0000 (19:46 +1100)]
Update to `ena` 0.11.0.

This version has some significant speed-ups relating to snapshotting.

5 years agoAuto merge of #55921 - scalexm:placeholders, r=nikomatsakis
bors [Sun, 25 Nov 2018 06:48:21 +0000 (06:48 +0000)]
Auto merge of #55921 - scalexm:placeholders, r=nikomatsakis

Add placeholder types

Fixes #48696 (handle universes in canonicalization of type inference vars), and fixes #55098.

5 years agoAuto merge of #55959 - matthewjasper:remove-end-region, r=nikomatsakis
bors [Sun, 25 Nov 2018 03:00:30 +0000 (03:00 +0000)]
Auto merge of #55959 - matthewjasper:remove-end-region, r=nikomatsakis

Cleanup from lexical MIR borrowck removal

Lexical MIR borrowck was removed months ago now, and `EndRegion`s are no longer used for MIRI verification.

* Remove `rustc::mir::StatementKind::EndRegion` and the `-Zemit_end_regions` flag
* Use `RegionVid` instead of `Region` in BorrowSet
* Rewrite drop generation to create fewer goto terminators.

r? @nikomatsakis

5 years ago[Windows] Work around non-monotonic clocks in the self-profiler
Wesley Wiser [Thu, 22 Nov 2018 18:05:25 +0000 (13:05 -0500)]
[Windows] Work around non-monotonic clocks in the self-profiler

On Windows, the high-resolution timestamp api doesn't seem to always be
monotonic. This can cause panics when the self-profiler uses the
`Instant` api to find elapsed time.

Work around this by detecting the case where now is less than the start
time and just use 0 elapsed ticks as the measurement.

Fixes #51648

5 years agoSuggest correct enum variant on typo
Esteban Küber [Sun, 25 Nov 2018 00:23:11 +0000 (16:23 -0800)]
Suggest correct enum variant on typo

5 years agoAuto merge of #55915 - oli-obk:miri_engine_refactoring, r=RalfJung
bors [Sun, 25 Nov 2018 00:00:17 +0000 (00:00 +0000)]
Auto merge of #55915 - oli-obk:miri_engine_refactoring, r=RalfJung

Miri engine refactoring

next small step of https://github.com/rust-lang/rust/pull/55293

r? @RalfJung

5 years agoTry to work around #53332 in `src/test/run-pass/rustc-rust-log.rs`
scalexm [Sat, 24 Nov 2018 22:34:44 +0000 (23:34 +0100)]
Try to work around #53332 in `src/test/run-pass/rustc-rust-log.rs`

5 years agoAuto merge of #56201 - kennytm:revert-55935, r=alexcrichton
bors [Sat, 24 Nov 2018 20:08:57 +0000 (20:08 +0000)]
Auto merge of #56201 - kennytm:revert-55935, r=alexcrichton

Revert "appveyor: Use VS2017 for all our images"

This reverts commit 008e5dcbd55cd751717ffd35a51dd65cd40011d4 (#55935)

We suspect this causes the spurious failure in https://github.com/rust-lang/rust/pull/55906#issuecomment-441365922 and https://github.com/rust-lang/rust/pull/55915#issuecomment-441377543.

r? @alexcrichton

5 years agoRevert "appveyor: Use VS2017 for all our images"
kennytm [Sat, 24 Nov 2018 16:25:29 +0000 (00:25 +0800)]
Revert "appveyor: Use VS2017 for all our images"

This reverts commit 008e5dcbd55cd751717ffd35a51dd65cd40011d4.

5 years agoRebase fallout
Oliver Scherer [Tue, 20 Nov 2018 10:04:07 +0000 (11:04 +0100)]
Rebase fallout

5 years agoupdate miri submodule
Oliver Scherer [Sat, 17 Nov 2018 16:52:25 +0000 (17:52 +0100)]
update miri submodule