]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoRollup merge of #62578 - JohnTitor:add-test-for-49919, r=alexcrichton
Mazdak Farrokhzad [Fri, 12 Jul 2019 20:46:46 +0000 (22:46 +0200)]
Rollup merge of #62578 - JohnTitor:add-test-for-49919, r=alexcrichton

Add test for #49919

Closes #49919

4 years agoRollup merge of #62568 - lzutao:replace_may_dangle, r=matthewjasper
Mazdak Farrokhzad [Fri, 12 Jul 2019 20:46:44 +0000 (22:46 +0200)]
Rollup merge of #62568 - lzutao:replace_may_dangle, r=matthewjasper

Replace unsafe_destructor_blind_to_params with may_dangle

This PR will completely remove support for `#[unsafe_destructor_blind_to_params]` attribute,
which is deprecated in #38970 by `[may_dangle]` unsafe  attribute.

Closes #34761

4 years agoRollup merge of #62453 - zackmdavis:single_path, r=estebank
Mazdak Farrokhzad [Fri, 12 Jul 2019 20:46:43 +0000 (22:46 +0200)]
Rollup merge of #62453 - zackmdavis:single_path, r=estebank

in which we suggest anonymizing single-use lifetimes in paths

Following @nikomatsakis's [October 2017 comment](https://github.com/rust-lang/rust/issues/44752#issuecomment-340885834).

![path_anon_suggest](https://user-images.githubusercontent.com/1076988/60761598-e2619180-a000-11e9-9144-1bdf8eb848e3.png)

r? @estebank
cc @eddyb (you were saying something about running single-use-lifetimes against the tree the other week?)

4 years agoRollup merge of #62431 - czipperz:add-messages-to-must-use-is_-methods, r=scottmcm
Mazdak Farrokhzad [Fri, 12 Jul 2019 20:46:41 +0000 (22:46 +0200)]
Rollup merge of #62431 - czipperz:add-messages-to-must-use-is_-methods, r=scottmcm

Add messages to `Option`'s and `Result`'s `must_use` annotation for `is_*`

r? @RalfJung

4 years agoRollup merge of #62274 - eddyb:const-false-unwind, r=pnkfelix
Mazdak Farrokhzad [Fri, 12 Jul 2019 20:46:40 +0000 (22:46 +0200)]
Rollup merge of #62274 - eddyb:const-false-unwind, r=pnkfelix

rustc_mir: follow FalseUnwind's real_target edge in qualify_consts.

As far as I can tell, this was accidentally omitted from #47802.
Fixes #62272.

r? @matthewjasper or @nikomatsakis

4 years agoRollup merge of #61535 - ohadravid:test-generic-with-default-assiociated-type-re...
Mazdak Farrokhzad [Fri, 12 Jul 2019 20:46:38 +0000 (22:46 +0200)]
Rollup merge of #61535 - ohadravid:test-generic-with-default-assiociated-type-re-rebalance-coherence, r=nikomatsakis

Coherence test when a generic type param has a default value from an associated type

A followup on #61400.
Before `re_rebalance_coherence`, this fails to compile (even though it should be accepted).
`re_rebalance_coherence` had no direct test for this, and I wanted to (a) make sure it doesn't regress in the future and (b) get it on record that this is actually the intended behavior.

4 years agoAuto merge of #61462 - GuillaumeGomez:fix-local-storage, r=Manishearth
bors [Fri, 12 Jul 2019 12:04:25 +0000 (12:04 +0000)]
Auto merge of #61462 - GuillaumeGomez:fix-local-storage, r=Manishearth

[rustdoc] Fix storage usage when disabled

Fixes #61239.

@starblue: Can you give a try to this change please? I tried on chrome and firefox and both worked so if you're using another web browser, that might be useful. :)

r? @Manishearth

4 years agoAuto merge of #62549 - ehuss:update-cargo-vendor, r=alexcrichton
bors [Fri, 12 Jul 2019 08:35:46 +0000 (08:35 +0000)]
Auto merge of #62549 - ehuss:update-cargo-vendor, r=alexcrichton

Update cargo-vendor usage

This contains a variety of updates to clean up the usage of cargo-vendor.

- Remove the install step for the old cargo-vendor now that it is built-in to cargo and available in the stage0 install.
- Update installation instructions, dealing with vendoring. The current instructions of running `sudo ./x.py install` is broken, it will almost always fail (since the vendor directory doesn't exist). Since the steps for properly handling this are numerous, I'm recommending removing the suggestion to use `sudo` altogether.
- If the sudo-forced-vendoring detects that the vendor directory is not available, abort with instructions on how to fix.
- Now that cargo-vendor is built-in, automatically run it if it looks like it is needed.
- Update instructions on how to install cargo.
- Remove the unused markdown link references in README/CONTRIBUTING. This reverts most of #44935. These references don't do anything if they are unused.

Closes #49269
cc #61142 #48771 #40108

4 years agoAuto merge of #61590 - matthewjasper:remove-borrowck-mir-dependency, r=pnkfelix
bors [Fri, 12 Jul 2019 04:56:05 +0000 (04:56 +0000)]
Auto merge of #61590 - matthewjasper:remove-borrowck-mir-dependency, r=pnkfelix

Remove rustc_mir dependency from rustc_borrowck

Also renames `rustc_borrowck` to `rustc_ast_borrowck` and removes all error reporting from it.

cc #59193

4 years agoAuto merge of #62594 - JohnTitor:update-miri, r=RalfJung
bors [Thu, 11 Jul 2019 21:54:55 +0000 (21:54 +0000)]
Auto merge of #62594 - JohnTitor:update-miri, r=RalfJung

Update miri

Fixes #62347

r? @RalfJung

4 years agoRemove feature gate `dropck_parametricity` completely
Lzu Tao [Thu, 11 Jul 2019 18:44:56 +0000 (18:44 +0000)]
Remove feature gate `dropck_parametricity` completely

Therefore we also remove `#[unsafe_destructor_blind_to_params]`
attribute completly.

4 years agoReplace unsafe_destructor_blind_to_params with may_dangle
Lzu Tao [Wed, 10 Jul 2019 18:49:05 +0000 (18:49 +0000)]
Replace unsafe_destructor_blind_to_params with may_dangle

4 years agoMove rustc_borrowck -> rustc_ast_borrowck
Matthew Jasper [Sat, 29 Jun 2019 16:37:32 +0000 (17:37 +0100)]
Move rustc_borrowck -> rustc_ast_borrowck

4 years agoRemove rustc_mir dependency from rustc_borrowck
Matthew Jasper [Sat, 29 Jun 2019 16:36:46 +0000 (17:36 +0100)]
Remove rustc_mir dependency from rustc_borrowck

4 years agoUpdate miri
Yuki Okushi [Thu, 11 Jul 2019 17:43:19 +0000 (02:43 +0900)]
Update miri

4 years agoAuto merge of #62503 - pnkfelix:dont-recur-infiitely-from-print-def-path, r=eddyb
bors [Thu, 11 Jul 2019 13:34:29 +0000 (13:34 +0000)]
Auto merge of #62503 - pnkfelix:dont-recur-infiitely-from-print-def-path, r=eddyb

Dont recur infinitely from print_def_path

Fix #61711

4 years agoAuto merge of #62574 - petrochenkov:dcrate-40000, r=Mark-Simulacrum
bors [Thu, 11 Jul 2019 10:05:09 +0000 (10:05 +0000)]
Auto merge of #62574 - petrochenkov:dcrate-40000, r=Mark-Simulacrum

pretty-print: Do not lose the `$crate` printing flag in `print_tt`

https://github.com/rust-lang/rust/pull/62393 had this accidental mistake.

Fixes https://github.com/rust-lang/rust/issues/62562
r? @Mark-Simulacrum

4 years agoAddress review comments
Vadim Petrochenkov [Thu, 11 Jul 2019 09:34:57 +0000 (12:34 +0300)]
Address review comments

4 years agorustc_mir: follow FalseUnwind's real_target edge in qualify_consts.
Eduard-Mihai Burtescu [Mon, 1 Jul 2019 16:26:36 +0000 (19:26 +0300)]
rustc_mir: follow FalseUnwind's real_target edge in qualify_consts.

4 years agopretty-print: Merge `print_tts` and `print_tts_ext`
Vadim Petrochenkov [Thu, 11 Jul 2019 00:16:19 +0000 (03:16 +0300)]
pretty-print: Merge `print_tts` and `print_tts_ext`

4 years agopretty-print: Do not lose the `$crate` printing flag in `print_tt`
Vadim Petrochenkov [Wed, 10 Jul 2019 23:01:45 +0000 (02:01 +0300)]
pretty-print: Do not lose the `$crate` printing flag in `print_tt`

4 years agoAuto merge of #62580 - Centril:rollup-remihe0, r=Centril
bors [Thu, 11 Jul 2019 04:45:15 +0000 (04:45 +0000)]
Auto merge of #62580 - Centril:rollup-remihe0, r=Centril

Rollup of 7 pull requests

Successful merges:

 - #61665 (core: check for pointer equality when comparing Eq slices)
 - #61923 (Prerequisites from dep graph refactoring #2)
 - #62270 (Move async-await tests from run-pass to ui)
 - #62425 (filedesc: don't use ioctl(FIOCLEX) on Linux)
 - #62476 (Continue refactoring macro expansion and resolution)
 - #62519 (Regression test for HRTB bug (issue 30786).)
 - #62557 (Fix typo in libcore/intrinsics.rs)

Failed merges:

r? @ghost

4 years agoRollup merge of #62557 - taiki-e:typo, r=Centril
Mazdak Farrokhzad [Thu, 11 Jul 2019 02:33:20 +0000 (04:33 +0200)]
Rollup merge of #62557 - taiki-e:typo, r=Centril

Fix typo in libcore/intrinsics.rs

4 years agoRollup merge of #62519 - pnkfelix:add-test-for-30786, r=pnkfelix
Mazdak Farrokhzad [Thu, 11 Jul 2019 02:33:19 +0000 (04:33 +0200)]
Rollup merge of #62519 - pnkfelix:add-test-for-30786, r=pnkfelix

Regression test for HRTB bug (issue 30786).

Close #30786.

4 years agoRollup merge of #62476 - petrochenkov:expref, r=matthewjasper
Mazdak Farrokhzad [Thu, 11 Jul 2019 02:33:17 +0000 (04:33 +0200)]
Rollup merge of #62476 - petrochenkov:expref, r=matthewjasper

Continue refactoring macro expansion and resolution

This PR continues the work started in https://github.com/rust-lang/rust/pull/62042.
It contains a set of more or less related refactorings with the general goal of making things simpler and more orthogonal.
Along the way most of the issues uncovered in https://github.com/rust-lang/rust/pull/62086 are fixed.

The PR is better read in per-commit fashion with whitespace changes ignored.
I tried to leave some more detailed commit messages describing the motivation behind the individual changes.

Fixes https://github.com/rust-lang/rust/issues/44692
Fixes https://github.com/rust-lang/rust/issues/52363
Unblocks https://github.com/rust-lang/rust/pull/62086
r? @matthewjasper

4 years agoRollup merge of #62425 - cyphar:linux-cloexec-use-fcntl, r=alexcrichton
Mazdak Farrokhzad [Thu, 11 Jul 2019 02:33:16 +0000 (04:33 +0200)]
Rollup merge of #62425 - cyphar:linux-cloexec-use-fcntl, r=alexcrichton

filedesc: don't use ioctl(FIOCLEX) on Linux

All `ioctl(2)`s will fail on `O_PATH` file descriptors on Linux (because
they use `&empty_fops` as a security measure against `O_PATH` descriptors
affecting the backing file).

As a result, `File::try_clone()` and various other methods would always
fail with `-EBADF` on `O_PATH` file descriptors. The solution is to simply
use `F_SETFD` (as is used on other unices) which works on `O_PATH`
descriptors because it operates through the `fnctl(2)` layer and not
through `ioctl(2)`s.

Since this code is usually only used in strange error paths (a broken or
ancient kernel), the extra overhead of one syscall shouldn't cause any
dramas. Most other systems programming languages also use the fnctl(2)
so this brings us in line with them.

Fixes: rust-lang/rust#62314
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
4 years agoRollup merge of #62270 - agnxy:move-async-test, r=Centril,tmandry
Mazdak Farrokhzad [Thu, 11 Jul 2019 02:33:14 +0000 (04:33 +0200)]
Rollup merge of #62270 - agnxy:move-async-test, r=Centril,tmandry

Move async-await tests from run-pass to ui

fix #62236

r? @Centril

4 years agoRollup merge of #61923 - Zoxc:dep-stream-prefix-2, r=pnkfelix
Mazdak Farrokhzad [Thu, 11 Jul 2019 02:33:12 +0000 (04:33 +0200)]
Rollup merge of #61923 - Zoxc:dep-stream-prefix-2, r=pnkfelix

Prerequisites from dep graph refactoring #2

Split out from https://github.com/rust-lang/rust/pull/60035 and overlaps with https://github.com/rust-lang/rust/pull/60559.

4 years agoRollup merge of #61665 - aschampion:slice-eq-ptr, r=sfackler
Mazdak Farrokhzad [Thu, 11 Jul 2019 02:33:11 +0000 (04:33 +0200)]
Rollup merge of #61665 - aschampion:slice-eq-ptr, r=sfackler

core: check for pointer equality when comparing Eq slices

Because `Eq` types must be reflexively equal, an equal-length slice to the same memory location must be equal.

This is related to #33892 (and #32699) answering this comment from that PR:

> Great! One more easy question: why does this optimization not apply in the non-BytewiseEquality implementation directly above?

Because slices of non-reflexively equal types (like `f64`) are not equal even if it's the same slice. But if the types are `Eq`, we can use this same-address optimization, which this PR implements. Obviously this changes behavior if types violate the reflexivity condition of `Eq`, because their impls of `PartialEq` will no longer be called per-item, but 🤷‍♂ .

It's not clear how often this optimization comes up in the real world outside of the same-`&str` case covered by #33892, so **I'm requesting a perf run** (on MacOS today, so can't run `rustc_perf` myself). I'm going ahead and making the PR on the basis of being surprised things didn't already work this way.

This is my first time hacking rust itself, so as a perf sanity check I ran `./x.py bench --stage 0 src/lib{std,alloc}`, but the differences were noisy.

To make the existing specialization for `BytewiseEquality` explicit, it's now a supertrait of `Eq + Copy`. `Eq` should be sufficient, but `Copy` was included for clarity.

4 years agoAdd test for #49919
Yuki Okushi [Thu, 11 Jul 2019 00:58:09 +0000 (09:58 +0900)]
Add test for #49919

4 years agoRefactor diagnostic emission for green nodes
John Kåre Alsaker [Fri, 19 Apr 2019 16:49:15 +0000 (18:49 +0200)]
Refactor diagnostic emission for green nodes

4 years agoAuto merge of #62561 - Centril:rollup-5pxj3bo, r=Centril
bors [Wed, 10 Jul 2019 23:02:44 +0000 (23:02 +0000)]
Auto merge of #62561 - Centril:rollup-5pxj3bo, r=Centril

Rollup of 5 pull requests

Successful merges:

 - #62275 (rustc_mir: treat DropAndReplace as Drop + Assign in qualify_consts.)
 - #62465 (Sometimes generate storage statements for temporaries with type `!`)
 - #62481 (Use `fold` in `Iterator::last` default implementation)
 - #62493 (#62357: doc(ptr): add example for {read,write}_unaligned)
 - #62532 (Some more cleanups to syntax::print)

Failed merges:

r? @ghost

4 years agoAdd a regression test for #44692
Vadim Petrochenkov [Mon, 8 Jul 2019 18:58:42 +0000 (21:58 +0300)]
Add a regression test for #44692

Add a test for the issue resolved by removing `resolve_macro_path`

Add a test making sure that extern prelude entries introduced from an opaque macro are not visible anywhere, even it that macro

Fix test output after rebase

4 years agoFix failing tests
Vadim Petrochenkov [Sun, 7 Jul 2019 22:00:54 +0000 (01:00 +0300)]
Fix failing tests

4 years agoexpand: Move "derive containers" into a separate `InvocationKind` variant
Vadim Petrochenkov [Sun, 7 Jul 2019 22:00:43 +0000 (01:00 +0300)]
expand: Move "derive containers" into a separate `InvocationKind` variant

`InvocationKind::Attr { attr: None, .. }` meaning something entirely different from a regular attribute was confusing as hell.

4 years agoexpand: Merge `expand_{bang,attr,derive}_invoc` into a single function
Vadim Petrochenkov [Sun, 7 Jul 2019 15:55:29 +0000 (18:55 +0300)]
expand: Merge `expand_{bang,attr,derive}_invoc` into a single function

It's more convenient to have all this highly related stuff together on one screen (for future refactorings).
The `expand_invoc` function is compact enough now, after all the previous refactorings.

4 years agoexpand: It's always possible to create a dummy AST fragment
Vadim Petrochenkov [Sun, 7 Jul 2019 15:29:22 +0000 (18:29 +0300)]
expand: It's always possible to create a dummy AST fragment

Remove a bunch of `Option`s that assumed that dummy fragment creation could fail.

The test output changed due to not performing the expansion in `fn expand_invoc` in case of the recursion limit hit.

4 years agohygiene: Make sure each `Mark` has an associated expansion info
Vadim Petrochenkov [Sun, 7 Jul 2019 13:45:41 +0000 (16:45 +0300)]
hygiene: Make sure each `Mark` has an associated expansion info

The root expansion was missing one.
Expansions created for "derive containers" (see one of the next commits for the description) also didn't get expansion info.

4 years agohygiene: Fix wording of desugaring descriptions
Vadim Petrochenkov [Sun, 7 Jul 2019 10:02:05 +0000 (13:02 +0300)]
hygiene: Fix wording of desugaring descriptions

Use variant names rather than descriptions for identifying desugarings in `#[rustc_on_unimplemented]`.
Both are highly unstable, but variant name is at least a single identifier.

4 years agohygiene: Introduce a helper method for creating new expansions
Vadim Petrochenkov [Sat, 6 Jul 2019 18:02:45 +0000 (21:02 +0300)]
hygiene: Introduce a helper method for creating new expansions

Creating a fresh expansion and immediately generating a span from it is the most common scenario.

Also avoid allocating `allow_internal_unstable` lists for derive markers repeatedly.
And rename `ExpnInfo::with_unstable` to `ExpnInfo::allow_unstable`, seems to be a better fitting name.

4 years agoexpand: Do not overwrite existing `ExpnInfo` when injecting derive markers
Vadim Petrochenkov [Sat, 6 Jul 2019 17:25:34 +0000 (20:25 +0300)]
expand: Do not overwrite existing `ExpnInfo` when injecting derive markers

Create a fresh expansion for them instead - this is the usual way to allow unstable features for generated/desugared code.
Fixes https://github.com/rust-lang/rust/issues/52363

4 years agoresolve: Fix access to extern and stdlib prelude from opaque macros
Vadim Petrochenkov [Sat, 6 Jul 2019 16:45:23 +0000 (19:45 +0300)]
resolve: Fix access to extern and stdlib prelude from opaque macros

Ok, it's hard to explain what happens, but identifier's hygienic contexts need to be "adjusted" to modules/scopes before they are resolved in them.
To be resolved in all kinds on preludes the identifier needs to be adjusted to the root expansion (aka "no expansion").

Previously this was done for the `macro m() { ::my_crate::foo }` case, but forgotten for all other cases.

4 years agoresolve: Divide macro path resolution into speculative and error reporting parts
Vadim Petrochenkov [Wed, 3 Jul 2019 20:59:03 +0000 (23:59 +0300)]
resolve: Divide macro path resolution into speculative and error reporting parts

Also move macro stability checking closer to other checks performed on obtained resolutions.
Tighten the stability spans as well, it is an error to *refer* to and unstable entity in any way, not only "call" it.

4 years agoresolve: Include stdlib prelude into name lookup in macro namespace
Vadim Petrochenkov [Wed, 3 Jul 2019 20:25:46 +0000 (23:25 +0300)]
resolve: Include stdlib prelude into name lookup in macro namespace

This is going to be used when built-in macros are defined through libcore and made available to other crates through standard library prelude

4 years agoresolve/expand: Catch macro kind mismatches early in resolve
Vadim Petrochenkov [Wed, 3 Jul 2019 09:47:24 +0000 (12:47 +0300)]
resolve/expand: Catch macro kind mismatches early in resolve

This way we are processing all of them in a single point, rather than separately for each syntax extension kind.
Also, the standard expected/found wording is used.

4 years agoresolve/expand: `resolve_macro_invocation` no longer returns determinate errors
Vadim Petrochenkov [Wed, 3 Jul 2019 08:44:57 +0000 (11:44 +0300)]
resolve/expand: `resolve_macro_invocation` no longer returns determinate errors

It either returns the indeterminacy error, or valid (but perhaps dummy) `SyntaxExtension`.

With this change enum `Determinacy` is no longer used in libsyntax and can be moved to resolve.

The regressions in diagnosics are fixed in the next commits.

4 years agoresolve: Make proc macro stubs less stubby
Vadim Petrochenkov [Tue, 2 Jul 2019 22:44:04 +0000 (01:44 +0300)]
resolve: Make proc macro stubs less stubby

Create real working and registered (even if dummy) `SyntaxExtension`s for them.
This improves error recovery and allows to avoid all special cases for proc macro stubs (except for the error on use, of course).

The introduced dummy `SyntaxExtension`s can be used for any other inappropriately resolved macros as well.

4 years agodef_collector: `parent_def` is no longer optional
Vadim Petrochenkov [Tue, 2 Jul 2019 20:42:00 +0000 (23:42 +0300)]
def_collector: `parent_def` is no longer optional

4 years agodef_collector: Simplify tracking of macro invocation parents
Vadim Petrochenkov [Tue, 2 Jul 2019 10:47:28 +0000 (13:47 +0300)]
def_collector: Simplify tracking of macro invocation parents

Avoid the tricky scheme with callbacks and keep the invocation parent data where it logically belongs - in `Definitions`.

This also allows to create `InvocationData` entries in resolve when the data is actually ready, and remove cells and "uninitialized" variants from it.

4 years agohygiene: Reuse `MacroKind` in `ExpnKind`
Vadim Petrochenkov [Sun, 30 Jun 2019 12:58:56 +0000 (15:58 +0300)]
hygiene: Reuse `MacroKind` in `ExpnKind`

Orthogonality and reuse are good.

4 years agohygiene: Remove some unused impls
Vadim Petrochenkov [Sun, 30 Jun 2019 11:57:34 +0000 (14:57 +0300)]
hygiene: Remove some unused impls

4 years agosyntax: Make def-site span mandatory in ExpnInfo/MacroBacktrace/DiagnosticSpanMacroEx...
Vadim Petrochenkov [Sun, 30 Jun 2019 00:05:52 +0000 (03:05 +0300)]
syntax: Make def-site span mandatory in ExpnInfo/MacroBacktrace/DiagnosticSpanMacroExpansion

We have to deal with dummy spans anyway

Remove def-site span from expander interfaces.
It's not used by the expansion infra, only by specific expanders, which can keep it themselves if they want it.

4 years agoexpand: Get rid of `resolve_macro_path`
Vadim Petrochenkov [Fri, 28 Jun 2019 23:30:53 +0000 (02:30 +0300)]
expand: Get rid of `resolve_macro_path`

It was used to choose whether to apply derive markers like `#[rustc_copy_clone_marker]` or not,
but it was called before all the data required for resolution is available, so it could work incorrectly in some corner cases (like user-defined derives name `Copy` or `Eq`).
Delay the decision about markers until the proper resolution results are available instead.

4 years agohygiene: Remove some dead code
Vadim Petrochenkov [Thu, 20 Jun 2019 07:34:51 +0000 (10:34 +0300)]
hygiene: Remove some dead code

4 years agoRemove unnecessary expansions created by `#[test_case/test/bench]`
Vadim Petrochenkov [Wed, 19 Jun 2019 23:33:39 +0000 (02:33 +0300)]
Remove unnecessary expansions created by `#[test_case/test/bench]`

The expansions were created to allow unstable things inside `#[test_case/test/bench]`, but that's not a proper way to do that.
Put the required `allow_internal_unstable`s into the macros' properties instead.

4 years agoRename some things in `syntax_pos/hygiene`
Vadim Petrochenkov [Tue, 18 Jun 2019 22:08:45 +0000 (01:08 +0300)]
Rename some things in `syntax_pos/hygiene`

More consistent with other naming:
ExpnFormat -> ExpnKind
ExpnKind::name -> ExpnKind::descr
DesugaringKind::name -> DesugaringKind::descr

Shorter, no tautology:
CompilerDesugaring -> Desugaring
CompilerDesugaringKind -> DesugaringKind

4 years agoMove `MacroKind` into `libsyntax_pos`
Vadim Petrochenkov [Tue, 18 Jun 2019 22:00:49 +0000 (01:00 +0300)]
Move `MacroKind` into `libsyntax_pos`

So it can be eventually used in `ExpnInfo`

4 years agoRemove `MacroKind::ProcMacroStub`
Vadim Petrochenkov [Tue, 18 Jun 2019 19:23:13 +0000 (22:23 +0300)]
Remove `MacroKind::ProcMacroStub`

It's internal to resolve and always results in `Res::Err` outside of resolve.
Instead put `DefKind::Fn`s themselves into the macro namespace, it's ok.

Proc macro stubs are items placed into macro namespase for functions that define proc macros.
https://github.com/rust-lang/rust/pull/52383

The rustdoc test is changed because the old test didn't actually reproduce the ICE it was supposed to reproduce.

4 years agoAuto merge of #62564 - Mark-Simulacrum:azure-line-endings, r=pietroalbini
bors [Wed, 10 Jul 2019 19:36:42 +0000 (19:36 +0000)]
Auto merge of #62564 - Mark-Simulacrum:azure-line-endings, r=pietroalbini

Ensure that checkout is with \n line endings

During installation of mingw, at least, the git directories change, so
we need to reset the core.autocrlf config to false.

Once we finish checking out submodules, check that the line endings are
\n and not \r\n.

Artifacts were built via the last try on #62545; I've manually confirmed that `install.sh` appears to no longer have `\r\n` line endings.

Fixes #62276.

4 years agoRegression test for issue 30786.
Felix S. Klock II [Tue, 9 Jul 2019 09:15:05 +0000 (11:15 +0200)]
Regression test for issue 30786.

4 years agoRollup merge of #62532 - Mark-Simulacrum:syntax-print-cleanup, r=petrochenkov
Mazdak Farrokhzad [Wed, 10 Jul 2019 14:08:26 +0000 (16:08 +0200)]
Rollup merge of #62532 - Mark-Simulacrum:syntax-print-cleanup, r=petrochenkov

Some more cleanups to syntax::print

All of these changes should be functionally equivalent to previous code.

Each commit mostly stands alone and this PR is easiest to review by-commit.

4 years agoRollup merge of #62493 - Freyskeyd:valid_example_read-write_unaligned, r=rkruppe
Mazdak Farrokhzad [Wed, 10 Jul 2019 14:08:24 +0000 (16:08 +0200)]
Rollup merge of #62493 - Freyskeyd:valid_example_read-write_unaligned, r=rkruppe

#62357: doc(ptr): add example for {read,write}_unaligned

related to #62357

> With #62323 the only example (that had UB and was thus invalid) in std::ptr::read_unaligned and std::ptr::write_unaligned is removed.

> We should add a valid example of using the aforementioned functions.

Signed-off-by: Freyskeyd <simon.paitrault@gmail.com>
4 years agoRollup merge of #62481 - czipperz:iterator-last-nth-use-for_each, r=scottmcm
Mazdak Farrokhzad [Wed, 10 Jul 2019 14:08:23 +0000 (16:08 +0200)]
Rollup merge of #62481 - czipperz:iterator-last-nth-use-for_each, r=scottmcm

Use `fold` in `Iterator::last` default implementation

We already use it in all the other methods.  Consistency + potential perf is a pretty nice win!

4 years agoRollup merge of #62465 - matthewjasper:never-type-storage, r=pnkfelix
Mazdak Farrokhzad [Wed, 10 Jul 2019 14:08:21 +0000 (16:08 +0200)]
Rollup merge of #62465 - matthewjasper:never-type-storage, r=pnkfelix

Sometimes generate storage statements for temporaries with type `!`

Closes #62165
cc #42371

4 years agoRollup merge of #62275 - eddyb:const-drop-replace, r=pnkfelix
Mazdak Farrokhzad [Wed, 10 Jul 2019 14:08:19 +0000 (16:08 +0200)]
Rollup merge of #62275 - eddyb:const-drop-replace, r=pnkfelix

rustc_mir: treat DropAndReplace as Drop + Assign in qualify_consts.

This slipped through the cracks and never got implemented (thankfully that just meant it was overly conservative and didn't allow assignments that don't *actually* drop the previous value).
Fixes #62273.

r? @oli-obk

4 years agofiledesc: don't use ioctl(FIOCLEX) on Linux
Aleksa Sarai [Fri, 5 Jul 2019 14:51:19 +0000 (00:51 +1000)]
filedesc: don't use ioctl(FIOCLEX) on Linux

All ioctl(2)s will fail on O_PATH file descriptors on Linux (because
they use &empty_fops as a security measure against O_PATH descriptors
affecting the backing file).

As a result, File::try_clone() and various other methods would always
fail with -EBADF on O_PATH file descriptors. The solution is to simply
use F_SETFD (as is used on other unices) which works on O_PATH
descriptors because it operates through the fnctl(2) layer and not
through ioctl(2)s.

Since this code is usually only used in strange error paths (a broken or
ancient kernel), the extra overhead of one syscall shouldn't cause any
dramas. Most other systems programming languages also use the fnctl(2)
so this brings us in line with them.

Fixes: rust-lang/rust#62314
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
4 years agoEnsure that checkout is with \n line endings
Mark Rousskov [Tue, 9 Jul 2019 22:21:23 +0000 (18:21 -0400)]
Ensure that checkout is with \n line endings

During installation of mingw, at least, the git directories change, so
we need to reset the core.autocrlf config to false.

Once we finish checking out submodules, check that the line endings are
\n and not \r\n.

4 years agoIgnore async-fn-size-moved-locals test on wasm
Andrew Xu [Wed, 10 Jul 2019 13:18:51 +0000 (21:18 +0800)]
Ignore async-fn-size-moved-locals test on wasm

The sizes for wasm are different.

Co-Authored-By: Tyler Mandry <tmandry@gmail.com>
4 years agoAuto merge of #62339 - pnkfelix:issue-61188-use-visitor-for-structural-match-check...
bors [Wed, 10 Jul 2019 12:26:44 +0000 (12:26 +0000)]
Auto merge of #62339 - pnkfelix:issue-61188-use-visitor-for-structural-match-check, r=nikomatsakis

use visitor for #[structural_match] check

This changes the code so that we recur down the structure of a type of a const (rather than just inspecting at a shallow one or two levels) when we are looking to see if it has an ADT that did not derive `PartialEq` and `Eq`.

Fix #61188

Fix #62307

Cc #62336

4 years agoFile is now short enough for tidy
Mark Rousskov [Tue, 9 Jul 2019 15:10:03 +0000 (11:10 -0400)]
File is now short enough for tidy

4 years agoRemove writer function from PrintState
Mark Rousskov [Tue, 9 Jul 2019 13:51:56 +0000 (09:51 -0400)]
Remove writer function from PrintState

4 years agoUse constant instead of magic number
Mark Rousskov [Tue, 9 Jul 2019 13:49:37 +0000 (09:49 -0400)]
Use constant instead of magic number

4 years agoRemove needless indent arguments
Mark Rousskov [Tue, 9 Jul 2019 13:30:08 +0000 (09:30 -0400)]
Remove needless indent arguments

We're always indenting by INDENT_UNIT anyway

4 years agoProperly case indent_unit constant
Mark Rousskov [Tue, 9 Jul 2019 13:32:25 +0000 (09:32 -0400)]
Properly case indent_unit constant

4 years agoMove pp::Printer helpers to direct impl
Mark Rousskov [Tue, 9 Jul 2019 13:26:50 +0000 (09:26 -0400)]
Move pp::Printer helpers to direct impl

4 years agoRename is_bol -> is_beginning_of_line
Mark Rousskov [Tue, 9 Jul 2019 11:42:05 +0000 (07:42 -0400)]
Rename is_bol -> is_beginning_of_line

Also moves it to pp::Printer from PrintState.

4 years agoRemove needless indirection in bclose
Mark Rousskov [Tue, 9 Jul 2019 11:38:31 +0000 (07:38 -0400)]
Remove needless indirection in bclose

4 years agoDrop length from Token::String
Mark Rousskov [Fri, 5 Jul 2019 13:58:34 +0000 (09:58 -0400)]
Drop length from Token::String

It was always set to the string's length

4 years agoRename pretty_print_* to scan_* to follow naming in the paper
Mark Rousskov [Mon, 8 Jul 2019 18:25:01 +0000 (14:25 -0400)]
Rename pretty_print_* to scan_* to follow naming in the paper

This is also easier to understand because the scan and print "tasks" are
separate, but previously were both called "print" or "pretty print."

4 years agoRemove is_begin/is_end functions from PrintState
Mark Rousskov [Sun, 7 Jul 2019 14:51:18 +0000 (10:51 -0400)]
Remove is_begin/is_end functions from PrintState

These are somewhat ambiguous (beginning/end of what?) so it's better to
inline their one use into the code.

4 years agoSimplify print_end
Mark Rousskov [Sun, 7 Jul 2019 14:38:09 +0000 (10:38 -0400)]
Simplify print_end

Presumably the code was from an older age of Rust and can now be written
much simpler.

4 years agoSimplify check_stack implementation
Mark Rousskov [Sun, 7 Jul 2019 14:15:47 +0000 (10:15 -0400)]
Simplify check_stack implementation

4 years agoMove BufEntry assignment into scan_push
Mark Rousskov [Sat, 6 Jul 2019 11:28:25 +0000 (07:28 -0400)]
Move BufEntry assignment into scan_push

4 years agoRemove useless call to indent
Mark Rousskov [Sat, 6 Jul 2019 02:31:45 +0000 (22:31 -0400)]
Remove useless call to indent

4 years agoFully privatize (vs. crate visibility) functions
Mark Rousskov [Sat, 6 Jul 2019 02:27:36 +0000 (22:27 -0400)]
Fully privatize (vs. crate visibility) functions

4 years agoMove pp::Printer out field to owned String
Mark Rousskov [Fri, 5 Jul 2019 23:10:18 +0000 (19:10 -0400)]
Move pp::Printer out field to owned String

This enforces that eof() must be called to get the String out, and
generally is better from an API perspective. No users of pretty printing
pre-allocate the buffer.

4 years agoInline State::new_from_input in pprust
Mark Rousskov [Fri, 5 Jul 2019 22:32:04 +0000 (18:32 -0400)]
Inline State::new_from_input in pprust

This function took too many arguments and are simple on the inside;
inlining them makes complexity go down.

hir::print's copy is unfortunately used from librustc_driver so inlining
it is not as straightforward.

4 years agoprint_crate returns String instead of taking an out pointer
Mark Rousskov [Fri, 5 Jul 2019 21:48:21 +0000 (17:48 -0400)]
print_crate returns String instead of taking an out pointer

4 years agoReplace src: &mut dyn Read with String
Mark Rousskov [Fri, 5 Jul 2019 21:12:11 +0000 (17:12 -0400)]
Replace src: &mut dyn Read with String

4 years agoCombine comment-handling logic into struct
Mark Rousskov [Fri, 5 Jul 2019 22:29:15 +0000 (18:29 -0400)]
Combine comment-handling logic into struct

This also permits sharing the underlying code between pprust and
hir::print.

4 years agoInline State::new
Mark Rousskov [Fri, 5 Jul 2019 20:35:23 +0000 (16:35 -0400)]
Inline State::new

There was only one callsite for each and this removes the
unwrap_or_default's on the comments argument

4 years agoStop Option-wrapping comments
Mark Rousskov [Fri, 5 Jul 2019 20:32:15 +0000 (16:32 -0400)]
Stop Option-wrapping comments

We always check against the length before indexing anyway.

4 years agoRemove unused boxes vector
Mark Rousskov [Fri, 5 Jul 2019 20:14:47 +0000 (16:14 -0400)]
Remove unused boxes vector

4 years agoPrivatize and remove unused functions
Mark Rousskov [Fri, 5 Jul 2019 20:00:38 +0000 (16:00 -0400)]
Privatize and remove unused functions

4 years agoDon't re-collect tokenstream twice to pretty print
Mark Rousskov [Fri, 5 Jul 2019 16:25:34 +0000 (12:25 -0400)]
Don't re-collect tokenstream twice to pretty print

4 years agoMove lifetime_to_string to Display impl
Mark Rousskov [Fri, 5 Jul 2019 19:42:28 +0000 (15:42 -0400)]
Move lifetime_to_string to Display impl

4 years agoRemove unused arm_to_string
Mark Rousskov [Fri, 5 Jul 2019 19:43:13 +0000 (15:43 -0400)]
Remove unused arm_to_string

4 years agoRemove duplicate attr_to_string
Mark Rousskov [Fri, 5 Jul 2019 16:16:41 +0000 (12:16 -0400)]
Remove duplicate attr_to_string

attribute_to_string exists.

4 years agoMove literal_to_string to fmt::Display
Mark Rousskov [Wed, 26 Jun 2019 11:23:27 +0000 (07:23 -0400)]
Move literal_to_string to fmt::Display

4 years agoAuto merge of #62441 - RalfJung:place-ptr-normalization, r=oli-obk
bors [Wed, 10 Jul 2019 08:59:15 +0000 (08:59 +0000)]
Auto merge of #62441 - RalfJung:place-ptr-normalization, r=oli-obk

Miri: Provide pointer forcing methods for MemPlace and Op

These are useful when one wants to to a lot of work with some place or operand and not to int-to-ptr casts all the time. In particular, this is needed to fix some test failures in Miri: we need to normalize before starting a visitor that walks a run-time value, so that we can later be sure (during the visitor walk) that we have a proper `Pointer`.

Also see the Miri side at https://github.com/rust-lang/miri/pull/830.

Cc @eddyb @oli-obk