]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoUpdate cargo
flip1995 [Mon, 19 Aug 2019 11:55:35 +0000 (13:55 +0200)]
Update cargo

4 years agoUpdate Clippy
flip1995 [Thu, 15 Aug 2019 14:04:30 +0000 (16:04 +0200)]
Update Clippy

4 years agoAuto merge of #62727 - SimonSapin:plugins-tls-dylib, r=petrochenkov
bors [Tue, 20 Aug 2019 00:31:13 +0000 (00:31 +0000)]
Auto merge of #62727 - SimonSapin:plugins-tls-dylib, r=petrochenkov

Deprecate using rustc_plugin without the rustc_driver dylib.

CC https://github.com/rust-lang/rust/pull/59800, https://github.com/rust-lang/rust/commit/7198687bb2df13a3298ef1e8f594753073d6b9e8

Fix https://github.com/rust-lang/rust/issues/62717

4 years agoDeprecate using rustc_plugin without the rustc_driver dylib.
Simon Sapin [Tue, 16 Jul 2019 17:08:32 +0000 (19:08 +0200)]
Deprecate using rustc_plugin without the rustc_driver dylib.

CC https://github.com/rust-lang/rust/pull/59800
https://github.com/rust-lang/rust/commit/7198687bb2df13a3298ef1e8f594753073d6b9e8

Fix https://github.com/rust-lang/rust/issues/62717

4 years agoAuto merge of #63715 - Centril:rollup-dga8qtp, r=Centril
bors [Mon, 19 Aug 2019 20:49:39 +0000 (20:49 +0000)]
Auto merge of #63715 - Centril:rollup-dga8qtp, r=Centril

Rollup of 5 pull requests

Successful merges:

 - #63252 (Remove recommendation about idiomatic syntax for Arc::clone)
 - #63376 (use different lifetime name for object-lifetime-default elision)
 - #63620 (Use constraint span when lowering associated types)
 - #63699 (Fix suggestion from incorrect `move async` to `async move`.)
 - #63704 ( Fixed: error: unnecessary trailing semicolon)

Failed merges:

r? @ghost

4 years agoRollup merge of #63704 - Wind-River:master, r=Centril
Mazdak Farrokhzad [Mon, 19 Aug 2019 20:48:59 +0000 (22:48 +0200)]
Rollup merge of #63704 - Wind-River:master, r=Centril

 Fixed: error: unnecessary trailing semicolon

4 years agoRollup merge of #63699 - gilescope:async-move-diagnostic, r=estebank
Mazdak Farrokhzad [Mon, 19 Aug 2019 20:48:57 +0000 (22:48 +0200)]
Rollup merge of #63699 - gilescope:async-move-diagnostic, r=estebank

Fix suggestion from incorrect `move async` to `async move`.

PR for #61920. Happy with the test. There must be a better implementation though - possibly a MIR visitor to estabilsh a span that doesn't include the `async` keyword?

4 years agoRollup merge of #63620 - estebank:assoc-type-span, r=Centril
Mazdak Farrokhzad [Mon, 19 Aug 2019 20:48:55 +0000 (22:48 +0200)]
Rollup merge of #63620 - estebank:assoc-type-span, r=Centril

Use constraint span when lowering associated types

Fix #63594.

r? @Centril

4 years agoRollup merge of #63376 - nikomatsakis:async-await-issue-62517, r=cramertj
Mazdak Farrokhzad [Mon, 19 Aug 2019 20:48:54 +0000 (22:48 +0200)]
Rollup merge of #63376 - nikomatsakis:async-await-issue-62517, r=cramertj

use different lifetime name for object-lifetime-default elision

Introduce a distinct value for `LifetimeName` to use when this is a object-lifetime-default elision. This allows us to avoid creating incorrect lifetime parameters for the opaque types that result. We really need to overhaul this setup at some point! It's getting increasingly byzantine. But this seems like a relatively... surgical fix.

r? @cramertj

Fixes #62517

4 years agoRollup merge of #63252 - nrc:arc-doc, r=alexcrichton
Mazdak Farrokhzad [Mon, 19 Aug 2019 20:48:52 +0000 (22:48 +0200)]
Rollup merge of #63252 - nrc:arc-doc, r=alexcrichton

Remove recommendation about idiomatic syntax for Arc::clone

I believe we should not make this recommendation. I don't want to argue that `Arc::clone` is less idiomatic than `arc.clone`, but that the choice is not clear cut and that we should not be making this kind of call in the docs.

The `.clone()` form has advantages too: it is more succinct, it is more likely to be understood by beginners, and it is more uniform with other `clone` calls, indeed with most other method calls.

Whichever approach is better, I think that this discussion belongs in a style guide or textbook, rather than the library docs. We don't talk much about idiomatic code in the docs, this place is pretty exceptional.

The recommendation is also not followed in this repo. It is hard to figure out how many calls there are of the `.clone()` form, but there are 1550 uses of `Arc` and only 65 uses of `Arc::clone`. The recommendation has existed for over two years.

The recommendation was added in https://github.com/rust-lang/rust/pull/42137, as a result of https://github.com/rust-lang/rfcs/pull/1954. However, note that that RFC was closed because it was not necessary to change the docs (the original RFC proposed a new function instead). So I don't think an RFC is necessary here (and I'm not trying to re-litigate the discussion on that RFC (which favoured `Arc::clone` as idiomatic) in any case).

cc @nical (who added the docs in the first place; sorry :-) )

r? @alexcrichton (or someone else on @rust-lang/libs )

4 years agoreview comments
Esteban Küber [Mon, 19 Aug 2019 19:24:06 +0000 (12:24 -0700)]
review comments

4 years agoUse constraint span when lowering associated types
Esteban Küber [Thu, 15 Aug 2019 23:40:12 +0000 (16:40 -0700)]
Use constraint span when lowering associated types

4 years agoadjust test to be check-pass
Niko Matsakis [Mon, 19 Aug 2019 17:53:06 +0000 (13:53 -0400)]
adjust test to be check-pass

4 years agouse static as object-lifetime default for type XX in `Foo<Item=XX>`
Niko Matsakis [Mon, 12 Aug 2019 14:41:05 +0000 (10:41 -0400)]
use static as object-lifetime default for type XX in `Foo<Item=XX>`

Currently the default is "inherited" from context, so e.g.  `&impl
Foo<Item = dyn Bar>` would default to `&'x impl Foo<Item = dyn Bar +
'x>`, but this triggers an ICE and is not very consistent.

This patch doesn't implement what I expect would be the correct
semantics, because those are likely too complex. Instead, it handles
what I'd expect to be the common case -- where the trait has no
lifetime parameters.

4 years agodistinguish object-lifetime-default elision from other elision
Niko Matsakis [Thu, 8 Aug 2019 07:36:24 +0000 (03:36 -0400)]
distinguish object-lifetime-default elision from other elision

Object-lifetime-default elision is distinct from other forms of
elision; it always refers to some enclosing lifetime *present in the
surrounding type* (e.g., `&dyn Bar` expands to `&'a (dyn Bar + 'a)`.
If there is no enclosing lifetime, then it expands to `'static`.

Therefore, in an `impl Trait<Item = dyn Bar>` setting, we don't expand
to create a lifetime parameter for the `dyn Bar + 'X` bound.  It will
just be resolved to `'static`.

Annoyingly, the responsibility for this resolution is spread across
multiple bits of code right now (`middle::resolve_lifetimes`,
`lowering`). The lowering code knows that the default is for an object
lifetime, but it doesn't know what the correct result would be.
Probably this should be fixed, but what we do now is a surgical fix:
we have it generate a different result for elided lifetimes in a
object context, and then we can ignore those results when figuring out
the lifetimes that are captured in the opaque type.

4 years agoadd debug logs
Niko Matsakis [Thu, 8 Aug 2019 07:49:45 +0000 (03:49 -0400)]
add debug logs

4 years agoAuto merge of #63579 - alexcrichton:new-lockfile, r=Mark-Simulacrum
bors [Mon, 19 Aug 2019 17:04:10 +0000 (17:04 +0000)]
Auto merge of #63579 - alexcrichton:new-lockfile, r=Mark-Simulacrum

Use to Cargo's experimental lockfile format

This commit changes the lock file format of this repository to an
experimental format that isn't rolled out by default in Cargo but is
intended to eventually become the default. The new format moves
information around and compresses the lock file a bit. The intention of
the new format is to reduce the amount of git merge conflicts that
happen in a repository, with rust-lang/rust being a prime candidate for
testing this.

The new format wille ventually become the default but for now it is
off-by-default in Cargo, but Cargo will preserve the format if it sees
it. Since we always build with a beta version of Cargo for the
rust-lang/rust repository it should be safe to go ahead and change the
lock file format here and everyone building this repository will
automatically pick it up.

It's intended that we'll evaluate this lock file format in the
rust-lang/rust repository to see if it reduces the number of perceived
merge conflicts for changes that touch the lock file. This will in turn
help inform the development of the feature in Cargo and whether we
choose to stabilize this and turn it on by default.

Note that this commit does not actually change the contents of the lock
file in terms of a resolution graph, it simply reencodes the lock file
with a new format.

4 years agoUse to Cargo's experimental lockfile format
Alex Crichton [Thu, 15 Aug 2019 00:45:09 +0000 (17:45 -0700)]
Use to Cargo's experimental lockfile format

This commit changes the lock file format of this repository to an
experimental format that isn't rolled out by default in Cargo but is
intended to eventually become the default. The new format moves
information around and compresses the lock file a bit. The intention of
the new format is to reduce the amount of git merge conflicts that
happen in a repository, with rust-lang/rust being a prime candidate for
testing this.

The new format wille ventually become the default but for now it is
off-by-default in Cargo, but Cargo will preserve the format if it sees
it. Since we always build with a beta version of Cargo for the
rust-lang/rust repository it should be safe to go ahead and change the
lock file format here and everyone building this repository will
automatically pick it up.

It's intended that we'll evaluate this lock file format in the
rust-lang/rust repository to see if it reduces the number of perceived
merge conflicts for changes that touch the lock file. This will in turn
help inform the development of the feature in Cargo and whether we
choose to stabilize this and turn it on by default.

Note that this commit does not actually change the contents of the lock
file in terms of a resolution graph, it simply reencodes the lock file
with a new format.

4 years agoFix suggestion from move async to async move.
Giles Cope [Mon, 19 Aug 2019 12:25:06 +0000 (13:25 +0100)]
Fix suggestion from move async to async move.

4 years agoMerge pull request #3 from Wind-River/vxworks-salim
Baoshan [Mon, 19 Aug 2019 15:45:43 +0000 (08:45 -0700)]
Merge pull request #3 from Wind-River/vxworks-salim

Fixed: error: unnecessary trailing semicolon

4 years agoAuto merge of #63700 - alexcrichton:update-backtrace, r=sfackler
bors [Mon, 19 Aug 2019 13:17:34 +0000 (13:17 +0000)]
Auto merge of #63700 - alexcrichton:update-backtrace, r=sfackler

std: Update `backtrace` crate dependency

This commit updates the `backtrace` crate from 0.3.34 to 0.3.35. The
[included set of changes][changes] for this update mostly includes some
gimli-related improvements (not relevant for the standard library) but
critically includes a fix for rust-lang/backtrace-rs#230. The standard
library will not aqcuire a session-local lock whenever a backtrace is
generated on Windows to allow external synchronization with the
`backtrace` crate itself, allowing `backtrace` to be safely used while
other threads may be panicking.

[changes]: https://github.com/rust-lang/backtrace-rs/compare/0.3.34...0.3.35

4 years agostd: Update `backtrace` crate dependency
Alex Crichton [Mon, 19 Aug 2019 13:13:18 +0000 (06:13 -0700)]
std: Update `backtrace` crate dependency

This commit updates the `backtrace` crate from 0.3.34 to 0.3.35. The
[included set of changes][changes] for this update mostly includes some
gimli-related improvements (not relevant for the standard library) but
critically includes a fix for rust-lang/backtrace-rs#230. The standard
library will not aqcuire a session-local lock whenever a backtrace is
generated on Windows to allow external synchronization with the
`backtrace` crate itself, allowing `backtrace` to be safely used while
other threads may be panicking.

[changes]: https://github.com/rust-lang/backtrace-rs/compare/0.3.34...0.3.35

4 years agoAuto merge of #63670 - Dante-Broggi:patch-2, r=Centril
bors [Mon, 19 Aug 2019 05:12:58 +0000 (05:12 +0000)]
Auto merge of #63670 - Dante-Broggi:patch-2, r=Centril

Size has a ::zero

4 years agoAuto merge of #63463 - matthewjasper:ty_param_cleanup, r=petrochenkov
bors [Mon, 19 Aug 2019 01:31:35 +0000 (01:31 +0000)]
Auto merge of #63463 - matthewjasper:ty_param_cleanup, r=petrochenkov

Don't special case the `Self` parameter by name

This results in a couple of small diagnostic regressions. They could be avoided by keeping the special case just for diagnostics, but that seems worse.

closes #50125
cc #60869

4 years agoAuto merge of #63045 - Rosto75:master, r=jonas-schievink
bors [Sun, 18 Aug 2019 22:01:21 +0000 (22:01 +0000)]
Auto merge of #63045 - Rosto75:master, r=jonas-schievink

Change the placement of two functions.

Right now, the order is as follows:
`pop_front()`
`push_front()`
`push_back()`
`pop_back()`

`swap_remove_back()`
`swap_remove_front()`

I believe it would be more natural, and easier to follow, if we place `pop_back()` right after the `pop_front()`, and `swap_remove_back()` after the `swap_remove_front()` like this:
`pop_front()`
`pop_back()`
`push_front()`
`push_back()`

`swap_remove_front()`
`swap_remove_back()`

The rest of the documentation (at least in this module) adheres to the same logic, where the 'front' function always precedes its 'back' equivalent.

4 years agoPre intern the `Self` parameter type
Matthew Jasper [Mon, 12 Aug 2019 21:15:12 +0000 (22:15 +0100)]
Pre intern the `Self` parameter type

Use this to simplify the object safety code a bit.

4 years agoAuto merge of #63659 - gilescope:async-in-closure, r=Centril
bors [Sun, 18 Aug 2019 18:23:28 +0000 (18:23 +0000)]
Auto merge of #63659 - gilescope:async-in-closure, r=Centril

Improved error message for break in async block

Fixes #63391

4 years agoAuto merge of #63635 - oli-obk:default-slice-dangles, r=eddyb
bors [Sun, 18 Aug 2019 13:22:38 +0000 (13:22 +0000)]
Auto merge of #63635 - oli-obk:default-slice-dangles, r=eddyb

Do not generate allocations for zero sized allocations

Alternative to https://github.com/rust-lang/rust/issues/62487

r? @eddyb

There are other places where we could do this, too, but that would cause `static FOO: () = ();` to not have a unique address

4 years agoBetter error message for break in async blocks.
Giles Cope [Sat, 17 Aug 2019 11:17:02 +0000 (12:17 +0100)]
Better error message for break in async blocks.

4 years agoAuto merge of #63269 - Aaron1011:feature/proc-macro-data, r=eddyb,petrochenkov
bors [Sun, 18 Aug 2019 08:15:38 +0000 (08:15 +0000)]
Auto merge of #63269 - Aaron1011:feature/proc-macro-data, r=eddyb,petrochenkov

Serialize additional data for procedural macros

Split off from #62855

This PR serializes the declaration `Span` and attributes for all
procedural macros. This allows Rustdoc to properly render doc comments
and source links when performing inlinig procedural macros across crates

4 years agoAuto merge of #62948 - matklad:failable-file-loading, r=petrochenkov
bors [Sun, 18 Aug 2019 04:37:01 +0000 (04:37 +0000)]
Auto merge of #62948 - matklad:failable-file-loading, r=petrochenkov

Normalize newlines when loading files

Fixes #62865

4 years agoFixed: error: unnecessary trailing semicolon
Salim Nasser [Sun, 18 Aug 2019 01:56:38 +0000 (18:56 -0700)]
Fixed: error: unnecessary trailing semicolon

4 years agoAuto merge of #61708 - dlrobertson:or-patterns-0, r=centril
bors [Sun, 18 Aug 2019 01:02:20 +0000 (01:02 +0000)]
Auto merge of #61708 - dlrobertson:or-patterns-0, r=centril

Initial implementation of or-patterns

An incomplete implementation of or-patterns (e.g. `Some(0 | 1)` as a pattern). This patch set aims to implement initial parsing of `or-patterns`.

Related to: #54883

CC @alexreg @varkor
r? @Centril

4 years agoAuto merge of #63671 - Centril:rollup-zufavt5, r=Centril
bors [Sat, 17 Aug 2019 21:30:10 +0000 (21:30 +0000)]
Auto merge of #63671 - Centril:rollup-zufavt5, r=Centril

Rollup of 5 pull requests

Successful merges:

 - #62451 (Add APIs for uninitialized Box, Rc, and Arc. (Plus get_mut_unchecked))
 - #63487 (Remove meaningless comments in src/test)
 - #63657 (Crank up invalid value lint)
 - #63667 (resolve: Properly integrate derives and `macro_rules` scopes)
 - #63669 (fix typos in mir/interpret)

Failed merges:

r? @ghost

4 years agoRollup merge of #63669 - Dante-Broggi:patch-1, r=jonas-schievink
Mazdak Farrokhzad [Sat, 17 Aug 2019 20:57:35 +0000 (22:57 +0200)]
Rollup merge of #63669 - Dante-Broggi:patch-1, r=jonas-schievink

fix typos in mir/interpret

4 years agoRollup merge of #63667 - petrochenkov:deriveholders, r=matthewjasper
Mazdak Farrokhzad [Sat, 17 Aug 2019 20:57:34 +0000 (22:57 +0200)]
Rollup merge of #63667 - petrochenkov:deriveholders, r=matthewjasper

resolve: Properly integrate derives and `macro_rules` scopes

So,
```rust
#[derive(A, B)]
struct S;

m!();
```
turns into something like
```rust
struct S;

A_placeholder!( struct S; );

B_placeholder!( struct S; );

m!();
```
during expansion.

And for `m!()` its "`macro_rules` scope" (aka "legacy scope") should point to the `B_placeholder` call rather than to the derive container `#[derive(A, B)]`.

`fn build_reduced_graph` now makes sure the legacy scope points to the right thing.
(It's still a mystery for me why this worked before https://github.com/rust-lang/rust/pull/63535.)

Unfortunately, placeholders from derives are currently treated separately from placeholders from other macros and need to be passed as `extra_placeholders` rather than a part of the AST fragment.
That's fixable, but I wanted to keep this PR more minimal to close the regression faster.

Fixes https://github.com/rust-lang/rust/issues/63651
r? @matthewjasper

4 years agoRollup merge of #63657 - RalfJung:invalid_value, r=Centril
Mazdak Farrokhzad [Sat, 17 Aug 2019 20:57:32 +0000 (22:57 +0200)]
Rollup merge of #63657 - RalfJung:invalid_value, r=Centril

Crank up invalid value lint

* Warn against uninit `bool` and `char`.
* Warn against 0-init `NonNull` and friends
* Detect transmute-from-0 as zero-initialization ([seen in the wild](https://github.com/glium/glium/issues/1775#issuecomment-522144636))

4 years agoRollup merge of #63487 - sd234678:remove-meaningless-comments-in-src/test-2, r=Centril
Mazdak Farrokhzad [Sat, 17 Aug 2019 20:57:30 +0000 (22:57 +0200)]
Rollup merge of #63487 - sd234678:remove-meaningless-comments-in-src/test-2, r=Centril

Remove meaningless comments in src/test

Moved from #63411

4 years agoRollup merge of #62451 - SimonSapin:new_uninit, r=RalfJung
Mazdak Farrokhzad [Sat, 17 Aug 2019 20:57:29 +0000 (22:57 +0200)]
Rollup merge of #62451 - SimonSapin:new_uninit, r=RalfJung

Add APIs for uninitialized Box, Rc, and Arc. (Plus get_mut_unchecked)

Assigning `MaybeUninit::<Foo>::uninit()` to a local variable is usually free, even when `size_of::<Foo>()` is large. However, passing it for example to `Arc::new` [causes at least one copy](https://youtu.be/F1AquroPfcI?t=4116) (from the stack to the newly allocated heap memory) even though there is no meaningful data. It is theoretically possible that a Sufficiently Advanced Compiler could optimize this copy away, but this is [reportedly unlikely to happen soon in LLVM](https://youtu.be/F1AquroPfcI?t=5431).

This PR proposes two sets of features:

* Constructors for containers (`Box`, `Rc`, `Arc`) of `MaybeUninit<T>` or `[MaybeUninit<T>]` that do not initialized the data, and unsafe conversions to the known-initialized types (without `MaybeUninit`). The constructors are guaranteed not to make unnecessary copies.

* On `Rc` and `Arc`, an unsafe `get_mut_unchecked` method that provides `&mut T` access without checking the reference count. `Arc::get_mut` involves multiple atomic operations whose cost can be non-trivial. `Rc::get_mut` is less costly, but we add `Rc::get_mut_unchecked` anyway for symmetry with `Arc`.

  These can be useful independently, but they will presumably be typical when the new constructors of `Rc` and `Arc` are used.

  An alternative with a safe API would be to introduce `UniqueRc` and `UniqueArc` types that have the same memory layout as `Rc` and `Arc` (and so zero-cost conversion to them) but are guaranteed to have only one reference. But introducing entire new types feels “heavier” than new constructors on existing types, and initialization of `MaybeUninit<T>` typically requires unsafe code anyway.

Summary of new APIs (all unstable in this PR):

```rust
impl<T> Box<T> { pub fn new_uninit() -> Box<MaybeUninit<T>> {…} }
impl<T> Box<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Box<T> {…} }
impl<T> Box<[T]> { pub fn new_uninit_slice(len: usize) -> Box<[MaybeUninit<T>]> {…} }
impl<T> Box<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Box<[T]> {…} }

impl<T> Rc<T> { pub fn new_uninit() -> Rc<MaybeUninit<T>> {…} }
impl<T> Rc<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Rc<T> {…} }
impl<T> Rc<[T]> { pub fn new_uninit_slice(len: usize) -> Rc<[MaybeUninit<T>]> {…} }
impl<T> Rc<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Rc<[T]> {…} }

impl<T> Arc<T> { pub fn new_uninit() -> Arc<MaybeUninit<T>> {…} }
impl<T> Arc<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Arc<T> {…} }
impl<T> Arc<[T]> { pub fn new_uninit_slice(len: usize) -> Arc<[MaybeUninit<T>]> {…} }
impl<T> Arc<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Arc<[T]> {…} }

impl<T: ?Sized> Rc<T> { pub unsafe fn get_mut_unchecked(this: &mut Self) -> &mut T {…} }
impl<T: ?Sized> Arc<T> { pub unsafe fn get_mut_unchecked(this: &mut Self) -> &mut T {…} }
```

4 years agotest in a way that works even with musl
Ralf Jung [Sat, 17 Aug 2019 20:11:43 +0000 (22:11 +0200)]
test in a way that works even with musl

4 years agosize has a zero
Dante-Broggi [Sat, 17 Aug 2019 20:09:49 +0000 (16:09 -0400)]
size has a zero

4 years agoDoc nit
Simon Sapin [Sat, 17 Aug 2019 19:40:35 +0000 (21:40 +0200)]
Doc nit

Co-Authored-By: Ralf Jung <post@ralfj.de>
4 years agofix typos
Dante-Broggi [Sat, 17 Aug 2019 19:33:44 +0000 (15:33 -0400)]
fix typos

4 years agoresolve/expand: Rename some things for clarity
Vadim Petrochenkov [Sat, 17 Aug 2019 17:49:00 +0000 (20:49 +0300)]
resolve/expand: Rename some things for clarity

4 years agoAuto merge of #63658 - RalfJung:miri-op, r=oli-obk
bors [Sat, 17 Aug 2019 17:53:31 +0000 (17:53 +0000)]
Auto merge of #63658 - RalfJung:miri-op, r=oli-obk

Refactor Miri ops (unary, binary) to have more types

This is the part of https://github.com/rust-lang/rust/pull/63448 that is just a refactoring. It helps that PR by making it easier to perform machine arithmetic.

r? @oli-obk @eddyb

4 years agoresolve: Properly integrate derives and `macro_rules` scopes
Vadim Petrochenkov [Sat, 17 Aug 2019 16:32:52 +0000 (19:32 +0300)]
resolve: Properly integrate derives and `macro_rules` scopes

4 years agoSerialize additional data for procedural macros
Aaron Hill [Sun, 4 Aug 2019 20:41:01 +0000 (16:41 -0400)]
Serialize additional data for procedural macros

Split off from #62855

This PR deerializes the declaration `Span` and attributes for all
procedural macros from their underlying function definitions.
This allows Rustdoc to properly render doc comments
and source links when inlining procedural macros across crates

4 years agoinitial implementation of or-pattern parsing
Dan Robertson [Sun, 14 Jul 2019 01:05:52 +0000 (01:05 +0000)]
initial implementation of or-pattern parsing

Initial implementation of parsing or-patterns e.g., `Some(Foo | Bar)`.
This is a partial implementation of RFC 2535.

4 years agoInitial implementation of or patterns
varkor [Fri, 19 Oct 2018 14:40:07 +0000 (15:40 +0100)]
Initial implementation of or patterns

4 years agoRename private helper method allocate_for_unsized to allocate_for_layout
Simon Sapin [Sat, 17 Aug 2019 13:39:21 +0000 (15:39 +0200)]
Rename private helper method allocate_for_unsized to allocate_for_layout

4 years agoless &
Ralf Jung [Sat, 17 Aug 2019 14:48:08 +0000 (16:48 +0200)]
less &

4 years agoDoc nits
Simon Sapin [Sat, 17 Aug 2019 13:15:17 +0000 (15:15 +0200)]
Doc nits

Co-Authored-By: Ralf Jung <post@ralfj.de>
4 years agoAuto merge of #63462 - matthewjasper:hygienic-builtin-derives, r=petrochenkov
bors [Sat, 17 Aug 2019 12:53:53 +0000 (12:53 +0000)]
Auto merge of #63462 - matthewjasper:hygienic-builtin-derives, r=petrochenkov

Opaque builtin derive macros

* Buiilt-in derives are now opaque macros
    * This required limiting the visibility of some previously unexposed functions in `core`.
    * This also required the change to `Ident` serialization.
* All gensyms are replaced with hygienic identifiers
* Use hygiene to avoid most other name-resolution issues with buiilt-in derives.
    *  As far as I know the only remaining case that breaks is an ADT that has the same name as one of its parameters. Fixing this completely seemed to be more effort than it's worth.
* Remove gensym in `Ident::decode`, which lead to linker errors due to `inline` being gensymmed.
    * `Ident`now panics if incremental compilation tries to serialize it (it currently doesn't).
    * `Ident` no longer uses `gensym` to emulate cross-crate hygiene. It only applied to reexports.
    * `SyntaxContext` is no longer serializable.
    * The long-term fix for this is to properly implement cross-crate hygiene, but this seemed to be acceptable for now.
* Move type/const parameter shadowing checks to `resolve`
    * This was previously split between resolve and type checking. The type checking pass compared `InternedString`s, not Identifiers.
* Removed the `SyntaxContext` from `{ast, hir}::{InlineAsm, GlobalAsm}`

cc #60869
r? @petrochenkov

4 years agodrift leftward
Ralf Jung [Sat, 17 Aug 2019 11:49:27 +0000 (13:49 +0200)]
drift leftward

4 years agofix tests
Ralf Jung [Sat, 17 Aug 2019 11:45:11 +0000 (13:45 +0200)]
fix tests

4 years agoFull stop
Ralf Jung [Sat, 17 Aug 2019 11:42:03 +0000 (13:42 +0200)]
Full stop

Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
4 years agouse ImmTy::from_uint in a few more spots
Ralf Jung [Sat, 10 Aug 2019 18:49:55 +0000 (20:49 +0200)]
use ImmTy::from_uint in a few more spots

4 years agomake both unary_op and binary_op fully typed, including a return type
Ralf Jung [Sat, 10 Aug 2019 17:40:56 +0000 (19:40 +0200)]
make both unary_op and binary_op fully typed, including a return type

4 years agoAdd ImmTy::from_uint
Ralf Jung [Sat, 17 Aug 2019 10:06:05 +0000 (12:06 +0200)]
Add ImmTy::from_uint

4 years agoinvalid_value: also detect transmute-from-0 (seen in the wild)
Ralf Jung [Sat, 17 Aug 2019 09:48:30 +0000 (11:48 +0200)]
invalid_value: also detect transmute-from-0 (seen in the wild)

4 years agomulti-variant enums are tricky
Ralf Jung [Sat, 17 Aug 2019 08:20:18 +0000 (10:20 +0200)]
multi-variant enums are tricky

4 years agoinvalid_value: warn for types with custom valid range
Ralf Jung [Sat, 17 Aug 2019 08:13:47 +0000 (10:13 +0200)]
invalid_value: warn for types with custom valid range

4 years agowarn about uninit bools and chars
Ralf Jung [Sat, 17 Aug 2019 07:39:25 +0000 (09:39 +0200)]
warn about uninit bools and chars

4 years agoinvalid_value: factor finding dangerous inits into separate function
Ralf Jung [Sat, 17 Aug 2019 06:39:20 +0000 (08:39 +0200)]
invalid_value: factor finding dangerous inits into separate function

4 years agoAdd tests
Oliver Scherer [Sat, 17 Aug 2019 09:31:09 +0000 (11:31 +0200)]
Add tests

4 years agoCast only where necessary
Oliver Scherer [Sat, 17 Aug 2019 09:29:17 +0000 (11:29 +0200)]
Cast only where necessary

4 years agoAuto merge of #63655 - Centril:rollup-ty1ot40, r=Centril
bors [Sat, 17 Aug 2019 09:14:37 +0000 (09:14 +0000)]
Auto merge of #63655 - Centril:rollup-ty1ot40, r=Centril

Rollup of 4 pull requests

Successful merges:

 - #62737 (Override Cycle::try_fold)
 - #63505 (Hash the remapped sysroot instead of the original.)
 - #63559 (rustc_codegen_utils: account for 1-indexed anonymous lifetimes in v0 mangling.)
 - #63621 (Modify librustc_llvm to pass -DNDEBUG while compiling.)

Failed merges:

r? @ghost

4 years agoRollup merge of #63621 - jgalenson:dndebug, r=alexcrichton
Mazdak Farrokhzad [Sat, 17 Aug 2019 09:13:47 +0000 (11:13 +0200)]
Rollup merge of #63621 - jgalenson:dndebug, r=alexcrichton

Modify librustc_llvm to pass -DNDEBUG while compiling.

Currently, librustc_llvm builds are not reproducible because the LLVM files it compiles use the debug version of llvm_unreachable, which uses __FILE__.  To fix this, we propagate NDEBUG from bootstrap if applicable and use it when compiling librustc_llvm.

r? @alexcrichton

4 years agoRollup merge of #63559 - eddyb:v0-mangling-off-by-1, r=estebank
Mazdak Farrokhzad [Sat, 17 Aug 2019 09:13:45 +0000 (11:13 +0200)]
Rollup merge of #63559 - eddyb:v0-mangling-off-by-1, r=estebank

rustc_codegen_utils: account for 1-indexed anonymous lifetimes in v0 mangling.

I don't really understand why `anonymize_late_bound_regions` starts with `BrAnon(1)` instead of `BrAnon(0)`, but it does (maybe @nikomatsakis knows?): https://github.com/rust-lang/rust/blob/c43d03a19f326f4a323569328cc501e86eb6d22e/src/librustc/ty/fold.rs#L696-L712

Thankfully, the mangling format and demangler implementations are fine, and I just needed to offset the anonymized lifetime indices by `1` to get the correct mangling.

cc @alexcrichton @michaelwoerister

4 years agoRollup merge of #63505 - jgalenson:sysroot-hash, r=alexcrichton
Mazdak Farrokhzad [Sat, 17 Aug 2019 09:13:44 +0000 (11:13 +0200)]
Rollup merge of #63505 - jgalenson:sysroot-hash, r=alexcrichton

Hash the remapped sysroot instead of the original.

One of the reasons that rustc builds are not reproducible is because the --sysroot path is dependent on the current directory.  We can fix this by hashing the remapped sysroot instead of the original when applicable.

Note that with this patch, the hash will stay the same if both the sysroot and the remapped path change.  However, given that if the contents of the sysroot change the hash will also stay the same, this might be acceptable.  I would appreciate feedback on the best way to do this.

This helps #34902, although it does not fix it by itself.

4 years agoRollup merge of #62737 - timvermeulen:cycle_try_fold, r=scottmcm
Mazdak Farrokhzad [Sat, 17 Aug 2019 09:13:42 +0000 (11:13 +0200)]
Rollup merge of #62737 - timvermeulen:cycle_try_fold, r=scottmcm

Override Cycle::try_fold

It's not very pretty, but I believe this is the simplest way to correctly implement `Cycle::try_fold`. The following may seem correct:
```rust
loop {
    acc = self.iter.try_fold(acc, &mut f)?;
    self.iter = self.orig.clone();
}
```
...but this loops infinitely in case `self.orig` is empty, as opposed to returning `acc`. So we first have to fully iterate `self.orig` to check whether it is empty or not, and before _that_, we have to iterate the remaining elements of `self.iter`.

This should always call `self.orig.clone()` the same amount of times as repeated `next()` calls would.

r? @scottmcm

4 years agoRemove unused `SyntaxContext` serialization impls
Matthew Jasper [Tue, 13 Aug 2019 18:19:31 +0000 (19:19 +0100)]
Remove unused `SyntaxContext` serialization impls

The implementations were wrong and unused.

4 years agoRemove SyntaxContext from {ast, hir}::{GlobalAsm, InlineAsm}
Matthew Jasper [Mon, 12 Aug 2019 21:12:53 +0000 (22:12 +0100)]
Remove SyntaxContext from {ast, hir}::{GlobalAsm, InlineAsm}

We now store it in the `Span` of the expression or item.

4 years agoMove type parameter shadowing errors to resolve
Matthew Jasper [Sun, 11 Aug 2019 17:09:50 +0000 (18:09 +0100)]
Move type parameter shadowing errors to resolve

For some reason type checking did this. Further it didn't consider
hygiene.

4 years agoRemove gensyms from built-in derives
Matthew Jasper [Sun, 11 Aug 2019 13:16:12 +0000 (14:16 +0100)]
Remove gensyms from built-in derives

Also make them generally more hygienic with name resolution.

4 years agoMake fmt-internal functions private
Matthew Jasper [Sun, 11 Aug 2019 12:31:11 +0000 (13:31 +0100)]
Make fmt-internal functions private

4 years agoMake built-in derives opaque macros
Matthew Jasper [Fri, 9 Aug 2019 20:15:00 +0000 (21:15 +0100)]
Make built-in derives opaque macros

4 years agoStop emulating cross-crate hygiene with gensyms
Matthew Jasper [Sun, 11 Aug 2019 10:48:22 +0000 (11:48 +0100)]
Stop emulating cross-crate hygiene with gensyms

Most `Ident`s are serialized as `InternedString`s the exceptions are:

* Reexports
* Attributes
* Idents in macro definitions

Using gensyms helped reexports emulate hygiene. However, the actual item
wouldn't have a gensymmed name so would be usable cross-crate. So
removing this case until we have proper cross-crate hygiene seems
sensible.

Codegen attributes (`inline`, `export_name`) are resolved by their
`Symbol`. This meant that opaque macro-expanded codegen attributes could
cause linker errors. This prevented making built-in derives hygienic.

4 years agoAuto merge of #63491 - Xanewok:update-rls, r=Mark-Simulacrum
bors [Sat, 17 Aug 2019 04:47:20 +0000 (04:47 +0000)]
Auto merge of #63491 - Xanewok:update-rls, r=Mark-Simulacrum

Update RLS

This fixes handling default configuration for the `crate_blacklist`
RLS configuration.

Technically this isn't needed, as the VS Code extension can be
configured to accept a predefined blacklist that's equal to the default
one but it's best that it also lands so that we don't need to work
around that.

Without this, manually passing a `null` value as the configuration
unfortunately crashes the RLS. This is the last fix related to configuration.

cc https://github.com/rust-lang/rust/pull/63472

r? @Mark-Simulacrum

4 years agoAuto merge of #63648 - Centril:rollup-2kpdrj1, r=Centril
bors [Sat, 17 Aug 2019 01:04:36 +0000 (01:04 +0000)]
Auto merge of #63648 - Centril:rollup-2kpdrj1, r=Centril

Rollup of 6 pull requests

Successful merges:

 - #63149 (resolve: Populate external modules in more automatic and lazy way)
 - #63545 (Feature gate 'yield $expr?' pre-expansion)
 - #63548 (Update rustc-demangle to 0.1.16.)
 - #63558 (Remap paths for proc-macro crates.)
 - #63641 (add git keyword to submodule comments in config.example.toml)
 - #63642 (Rename overflowing_{add,sub,mul} intrinsics to wrapping_{add,sub,mul}.)

Failed merges:

r? @ghost

4 years agoRollup merge of #63642 - eddyb:wrap-it-up, r=rkruppe,Mark-Simulacrum
Mazdak Farrokhzad [Sat, 17 Aug 2019 01:03:02 +0000 (03:03 +0200)]
Rollup merge of #63642 - eddyb:wrap-it-up, r=rkruppe,Mark-Simulacrum

Rename overflowing_{add,sub,mul} intrinsics to wrapping_{add,sub,mul}.

These confused @Gankra, and then, also me, especially since `overflowing_*` *methods* also exist, but they map to `*_with_overflow` intrinsics!

r? @oli-obk / @nikomatsakis cc @Mark-Simulacrum (on the rustbuild workaround)

4 years agoRollup merge of #63641 - DieracDelta:master, r=eddyb
Mazdak Farrokhzad [Sat, 17 Aug 2019 01:03:01 +0000 (03:03 +0200)]
Rollup merge of #63641 - DieracDelta:master, r=eddyb

add git keyword to submodule comments in config.example.toml

I searched over config.example.toml file looking for a place to disable git submodules from being updated, and missed the two options related to this because they did not include the keyword git. This pr simply adds git to the relevant comments so hopefully others won't also miss that these options exist.

4 years agoRollup merge of #63558 - jgalenson:move-remap, r=alexcrichton
Mazdak Farrokhzad [Sat, 17 Aug 2019 01:02:59 +0000 (03:02 +0200)]
Rollup merge of #63558 - jgalenson:move-remap, r=alexcrichton

Remap paths for proc-macro crates.

The remap-debuginfo config option remaps paths in most crates, but it does not apply to proc-macros, so they are still non-reproducible.  This patch fixes that.

I'm not completely sure if this is the best way to do this, but to get reproducible builds we need librustc_macros to be built with --remap-path-prefix.  I was previously modifying Cargo to pass that argument to all child crates, so this seems simpler and more correct.

I did not add a test since there do not seem to be any existing tests for RUSTC_DEBUGINFO_MAP.

r? @alexcrichton

4 years agoRollup merge of #63548 - eddyb:unicode-demangling, r=alexcrichton
Mazdak Farrokhzad [Sat, 17 Aug 2019 01:02:57 +0000 (03:02 +0200)]
Rollup merge of #63548 - eddyb:unicode-demangling, r=alexcrichton

Update rustc-demangle to 0.1.16.

Includes https://github.com/alexcrichton/rustc-demangle/pull/29 and https://github.com/alexcrichton/rustc-demangle/pull/30.
You can see the effects of the former in the testcase changes.

r? @alexcrichton cc @davidtwco @michaelwoerister

4 years agoRollup merge of #63545 - Centril:gate-yield-preexp, r=oli-obk
Mazdak Farrokhzad [Sat, 17 Aug 2019 01:02:56 +0000 (03:02 +0200)]
Rollup merge of #63545 - Centril:gate-yield-preexp, r=oli-obk

Feature gate 'yield $expr?' pre-expansion

Also improve the overall ergonomics of pre-expansion gating in general.

r? @Zoxc

4 years agoRollup merge of #63149 - petrochenkov:lazypop2, r=eddyb
Mazdak Farrokhzad [Sat, 17 Aug 2019 01:02:54 +0000 (03:02 +0200)]
Rollup merge of #63149 - petrochenkov:lazypop2, r=eddyb

resolve: Populate external modules in more automatic and lazy way

So, resolve had this function `populate_module_if_necessary` for loading module children from other crates from metadata.
I never really understood when it should've been called and when not.
This PR removes the function and loads the module children automatically on the first access instead.

r? @eddyb

4 years agoAuto merge of #63640 - Centril:rollup-yeb8o66, r=Centril
bors [Fri, 16 Aug 2019 18:35:17 +0000 (18:35 +0000)]
Auto merge of #63640 - Centril:rollup-yeb8o66, r=Centril

Rollup of 10 pull requests

Successful merges:

 - #60492 (Add custom nth_back for Chain)
 - #61780 (Finalize the error type for `try_reserve`)
 - #63495 ( Remove redundant `ty` fields from `mir::Constant` and `hair::pattern::PatternRange`.)
 - #63525 (Make sure that all file loading happens via SourceMap)
 - #63595 (add sparc64-unknown-openbsd target)
 - #63604 (Some update for vxWorks)
 - #63613 (Hygienize use of built-in macros in the standard library)
 - #63632 (A couple of comment fixes.)
 - #63634 (ci: properly set the job name in CPU stats)
 - #63636 (ci: move linkcheck from mingw-2 to mingw-1)

Failed merges:

r? @ghost

4 years agoFix rebase
Vadim Petrochenkov [Fri, 16 Aug 2019 18:19:43 +0000 (21:19 +0300)]
Fix rebase

Move some code into `build_reduced_graph.rs` to keep `BuildReducedGraphVisitor` it private
Also move the def collector call to `build_reduced_graph.rs`, it belongs there.

4 years agoresolve: Move some code around
Vadim Petrochenkov [Thu, 15 Aug 2019 22:18:14 +0000 (01:18 +0300)]
resolve: Move some code around

4 years agoresolve: Populate external traits lazily as well
Vadim Petrochenkov [Thu, 15 Aug 2019 22:15:36 +0000 (01:15 +0300)]
resolve: Populate external traits lazily as well

4 years agoresolve: Populate external modules in more automatic and lazy way
Vadim Petrochenkov [Mon, 29 Jul 2019 18:19:50 +0000 (21:19 +0300)]
resolve: Populate external modules in more automatic and lazy way

The modules are now populated implicitly on the first access

4 years agoSimplify pre-expansion gating in general.
Mazdak Farrokhzad [Wed, 14 Aug 2019 04:09:11 +0000 (06:09 +0200)]
Simplify pre-expansion gating in general.

4 years agoFeature gate 'yield ?' pre-expansion.
Mazdak Farrokhzad [Wed, 14 Aug 2019 03:44:32 +0000 (05:44 +0200)]
Feature gate 'yield ?' pre-expansion.

4 years agorustbuild: work around the stdarch cfg(bootstrap) bug.
Eduard-Mihai Burtescu [Fri, 16 Aug 2019 17:12:10 +0000 (20:12 +0300)]
rustbuild: work around the stdarch cfg(bootstrap) bug.

4 years agoRename overflowing_{add,sub,mul} intrinsics to wrapping_{add,sub,mul}.
Eduard-Mihai Burtescu [Fri, 16 Aug 2019 17:02:31 +0000 (20:02 +0300)]
Rename overflowing_{add,sub,mul} intrinsics to wrapping_{add,sub,mul}.

4 years agoadd git keyword to submodule option
Justin Restivo [Fri, 16 Aug 2019 16:39:45 +0000 (12:39 -0400)]
add git keyword to submodule option

4 years agoRollup merge of #63636 - pietroalbini:ci-mingw, r=alexcrichton
Mazdak Farrokhzad [Fri, 16 Aug 2019 16:22:34 +0000 (18:22 +0200)]
Rollup merge of #63636 - pietroalbini:ci-mingw, r=alexcrichton

ci: move linkcheck from mingw-2 to mingw-1

Running UI tests now takes a huge amount of time on mingw builders
(between 40 and 50 minutes), with mingw-1 builders taking even an hour
less to finish than mingw-2. This PR moves linkcheck from mingw-2 to
mingw-1, removing between 10 and 20 minutes of runtime on the -2
builders.

r? @alexcrichton

4 years agoRollup merge of #63634 - pietroalbini:cpu-stats-name, r=alexcrichton
Mazdak Farrokhzad [Fri, 16 Aug 2019 16:22:33 +0000 (18:22 +0200)]
Rollup merge of #63634 - pietroalbini:cpu-stats-name, r=alexcrichton

ci: properly set the job name in CPU stats

r? @alexcrichton

4 years agoRollup merge of #63632 - vext01:vext01-comment-fixes, r=eddyb
Mazdak Farrokhzad [Fri, 16 Aug 2019 16:22:31 +0000 (18:22 +0200)]
Rollup merge of #63632 - vext01:vext01-comment-fixes, r=eddyb

A couple of comment fixes.

This change fixes a couple of comments in the compiler code.

The first change was discussed with @eddyb. This one confused me because I thought only *public* defs were in the table (not so).

The second was a typo I noticed yesterday.

OK to go in?

4 years agoRollup merge of #63613 - petrochenkov:stdhyg, r=alexcrichton
Mazdak Farrokhzad [Fri, 16 Aug 2019 16:22:30 +0000 (18:22 +0200)]
Rollup merge of #63613 - petrochenkov:stdhyg, r=alexcrichton

Hygienize use of built-in macros in the standard library

Same as https://github.com/rust-lang/rust/pull/61629, but for built-in macros.

Closes https://github.com/rust-lang/rust/issues/48781
r? @alexcrichton