Commit Graph

95958 Commits

Author SHA1 Message Date
Vadim Petrochenkov
dcd30a4b17 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.
2019-07-11 00:12:57 +03:00
Vadim Petrochenkov
99c7432896 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.
2019-07-11 00:12:57 +03:00
Vadim Petrochenkov
d1949b1ab0 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
2019-07-11 00:12:08 +03:00
Vadim Petrochenkov
0ec6ea7333 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.
2019-07-11 00:12:08 +03:00
Vadim Petrochenkov
f923942094 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.
2019-07-11 00:12:08 +03:00
Vadim Petrochenkov
8bc187d104 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
2019-07-11 00:12:08 +03:00
Vadim Petrochenkov
3041ec6118 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.
2019-07-11 00:12:08 +03:00
Vadim Petrochenkov
f16993d4ac 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.
2019-07-11 00:12:08 +03:00
Vadim Petrochenkov
cd0fd630e8 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.
2019-07-11 00:12:08 +03:00
Vadim Petrochenkov
b392781edc def_collector: parent_def is no longer optional 2019-07-11 00:12:08 +03:00
Vadim Petrochenkov
e272946066 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.
2019-07-11 00:12:08 +03:00
Vadim Petrochenkov
aff9738462 hygiene: Reuse MacroKind in ExpnKind
Orthogonality and reuse are good.
2019-07-11 00:12:08 +03:00
Vadim Petrochenkov
4dcf9b15c4 hygiene: Remove some unused impls 2019-07-11 00:12:08 +03:00
Vadim Petrochenkov
3eafaae510 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.
2019-07-11 00:12:07 +03:00
Vadim Petrochenkov
a138e9d625 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.
2019-07-11 00:12:07 +03:00
Vadim Petrochenkov
62a1f5dbc0 hygiene: Remove some dead code 2019-07-11 00:12:07 +03:00
Vadim Petrochenkov
f1d4ebf015 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.
2019-07-11 00:12:07 +03:00
Vadim Petrochenkov
16918a8e28 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
2019-07-11 00:12:07 +03:00
Vadim Petrochenkov
ec376c783e Move MacroKind into libsyntax_pos
So it can be eventually used in `ExpnInfo`
2019-07-11 00:12:07 +03:00
Vadim Petrochenkov
48635226d8 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.
2019-07-11 00:12:07 +03:00
bors
c6a9e766f9 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
2019-07-10 12:26:44 +00:00
bors
d4e1565509 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
2019-07-10 08:59:15 +00:00
bors
0324a2b309 Auto merge of #62555 - Centril:rollup-ti46adx, r=Centril
Rollup of 5 pull requests

Successful merges:

 - #61853 (Emit warning when trying to use PGO in conjunction with unwinding on …)
 - #62278 (Add Iterator::partition_in_place() and is_partitioned())
 - #62283 (Target::arch can take more than listed options)
 - #62393 (Fix pretty-printing of `$crate` (take 4))
 - #62474 (Prepare for LLVM 9 update)

Failed merges:

r? @ghost
2019-07-10 05:21:43 +00:00
Mazdak Farrokhzad
6c0a406b1c
Rollup merge of #62474 - nikic:update-llvm, r=alexcrichton
Prepare for LLVM 9 update

Main changes:

 * In preparation for opaque pointer types, the `byval` attribute now takes a type. As such, the argument type needs to be threaded through to the function/callsite attribute application logic.
 * On ARM the `+fp-only-sp` and `+d16` features have become `-fp64` and `-d32`. I've switched the target definitions to use the new names, but also added bidirectional emulation so either can be used on any LLVM version for backwards compatibility.
 * The datalayout can now specify function pointer alignment. In particular on ARM `Fi8` is specified, which means that function pointer alignment is independent of function alignment. I've added this to our datalayouts to match LLVM (which is something we check) and strip the fnptr alignment for older LLVM versions.
 * The fmul/fadd reductions now always respect the accumulator (including for unordered reductions), so we should pass the identity instead of undef.

Open issues:

 * https://reviews.llvm.org/D62106 causes linker errors with ld.bdf due to https://sourceware.org/bugzilla/show_bug.cgi?id=24784. To avoid this I've enabled `RelaxELFRelocations`, which results in a GOTPCRELX relocation for `__tls_get_addr` and avoids the issue. However, this is likely not acceptable because relax relocations are not supported by older linker versions. We may need an LLVM option to keep using PLT for `__tls_get_addr` despite `RtLibUseGOT`.

The corresponding llvm-project PR is https://github.com/rust-lang/llvm-project/pull/19.

r? @ghost
2019-07-10 05:14:10 +02:00
Mazdak Farrokhzad
fe26fc9a1c
Rollup merge of #62393 - petrochenkov:notto-disu, r=Mark-Simulacrum
Fix pretty-printing of `$crate` (take 4)

Pretty-print `$crate` as `crate` or `crate_name` in unstructured tokens like `a $crate c` in `foo!(a $crate c)`, but only if those tokens are printed as a part of AST pretty-printing, rather than as a standalone token stream.

Fixes https://github.com/rust-lang/rust/issues/62325
Previous iterations - https://github.com/rust-lang/rust/pull/56647, https://github.com/rust-lang/rust/pull/57155, https://github.com/rust-lang/rust/pull/57915.
2019-07-10 05:14:09 +02:00
Mazdak Farrokhzad
1e48be948a
Rollup merge of #62283 - fintelia:patch-5, r=Mark-Simulacrum
Target::arch can take more than listed options

A list of options in a comment like this is almost guaranteed to become out of date: right now it is missing "riscv32" and "riscv64" and perhaps other architectures as well.
2019-07-10 05:14:07 +02:00
Mazdak Farrokhzad
b14b20c638
Rollup merge of #62278 - cuviper:iter-partition, r=alexcrichton
Add Iterator::partition_in_place() and is_partitioned()

`partition_in_place()` swaps `&mut T` items in-place to satisfy the
predicate, so all `true` items precede all `false` items. This requires
a `DoubleEndedIterator` so we can search from front and back for items
that need swapping.

`is_partitioned()` checks whether the predicate is already satisfied.
2019-07-10 05:14:06 +02:00
Mazdak Farrokhzad
3c3e3756b0
Rollup merge of #61853 - EricRahm:use_warning, r=varkor
Emit warning when trying to use PGO in conjunction with unwinding on …

…Windows.

This reduces the error introduced for #61002 to just a warning.
2019-07-10 05:14:04 +02:00
bors
3f435f622e Auto merge of #62548 - ehuss:update-cargo, r=alexcrichton
Update cargo

Update cargo

12 commits in 4c1fa54d10f58d69ac9ff55be68e1b1c25ecb816..677a180f4c8ca1dcef594f68dd0e63e4f08621f5
2019-06-24 11:24:18 +0000 to 2019-07-08 13:43:02 +0000
- Update dependencies (rust-lang/cargo#7106)
- Fix overwriting .d file for binary with dSYM on apple targets. (rust-lang/cargo#7057)
- Update changelog. (rust-lang/cargo#7102)
- Revert "Fix 'getting started' internal links" (rust-lang/cargo#7099)
- Bump to 0.39.0 (rust-lang/cargo#7100)
- Update dependency.rs (rust-lang/cargo#7098)
- Typo (rust-lang/cargo#7097)
- Fix 'getting started' internal links (rust-lang/cargo#7093)
- Fix misleading comment in testsuite (rust-lang/cargo#7090)
- improve uncommitted changes cargo-package message (rust-lang/cargo#7083)
- Clean environment when git-fetch-with-cli is used. (rust-lang/cargo#7082)
- Fix exponentiality in depend_on_deps_of_deps. (rust-lang/cargo#7062)
2019-07-10 01:53:04 +00:00
Eric Huss
03a4068152 Update cargo 2019-07-09 16:47:45 -07:00
Josh Stone
7171c83ab2 Tracking issue 62544 for iter_is_partitioned 2019-07-09 15:18:33 -07:00
Josh Stone
4c22e48f6e Tracking issue 62543 for iter_partition_in_place 2019-07-09 15:17:47 -07:00
bors
e7efdf1c33 Auto merge of #62542 - Centril:rollup-5mpb8tu, r=Centril
Rollup of 9 pull requests

Successful merges:

 - #62417 (Fix ICEs when `Self` is used in type aliases)
 - #62450 (Raise the default recursion limit to 128)
 - #62470 (Prevent shrinking of "crate select" element on Firefox)
 - #62515 (cli: make help output for -l and -L consistent)
 - #62520 (Regression test for issue 42574.)
 - #62526 (normalize use of backticks in compiler messages for libsyntax/feature_gate.rs)
 - #62527 (clarify that debug_assert does not completely omits the code)
 - #62535 (ci: Configure $CI_JOB_NAME correctly)
 - #62541 (Add spastorino for rustc-guide toolstate)

Failed merges:

r? @ghost
2019-07-09 22:02:58 +00:00
Eric Rahm
74a39a39a4 Emit warning when trying to use PGO in conjunction with unwinding on Windows. 2019-07-09 17:17:30 -04:00
Nikita Popov
ac560258e3 Adjust codegen tests for DISPFlagMainSubprogram 2019-07-09 21:55:29 +02:00
Nikita Popov
5c95f5fa6b Fix float add/mul reduction codegen
The accumulator is now respected for unordered reductions.
2019-07-09 21:55:29 +02:00
Nikita Popov
8789c9e595 Strip function pointer alignment for older LLVM versions 2019-07-09 21:55:29 +02:00
Nikita Popov
5324b42a59 Add function pointer alignment to ARM/Thumb data layout 2019-07-09 21:55:29 +02:00
Nikita Popov
3170b62cca Use new feature names in target feature lists 2019-07-09 21:55:29 +02:00
Nikita Popov
b57c499ea2 Translate target features for LLVM 9 2019-07-09 21:55:29 +02:00
Nikita Popov
eb33822091 Pass type to byval attributes 2019-07-09 21:55:29 +02:00
Nikita Popov
04304fcd16 Pass GUIDPreservedSymbols to thinLTOResolvePrevailingInIndex() 2019-07-09 21:55:29 +02:00
Vadim Petrochenkov
4cb67c0f1c Add a test case with $crate from other crate 2019-07-09 22:45:25 +03:00
Josh Stone
265e3a6230 Unit test Iterator::partition_in_place and is_partitioned 2019-07-09 12:39:25 -07:00
Josh Stone
0492f972c7 Return the true count from partition_in_place 2019-07-09 12:39:25 -07:00
Josh Stone
cd0ebc43c7 Rename partition_mut to partition_in_place 2019-07-09 12:39:25 -07:00
Josh Stone
cdeec0a618 Capitalize example comment
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-07-09 12:39:25 -07:00
Josh Stone
60f1449b61 Add Iterator::partition_mut() and is_partitioned()
`partition_mut()` swaps `&mut T` items in-place to satisfy the
predicate, so all `true` items precede all `false` items. This requires
a `DoubleEndedIterator` so we can search from front and back for items
that need swapping.

`is_partitioned()` checks whether the predicate is already satisfied.
2019-07-09 12:39:25 -07:00
Vadim Petrochenkov
3997507786 Resolve $crate in all hygienic contexts for pretty-pringing
Stop visiting AST to discover those contexts, just iterate through hygiene data instead
2019-07-09 22:17:44 +03:00
Vadim Petrochenkov
4344a90308 Pretty-print $crate as crate/::my_crate in tokens
...but only if those tokens are printed from inside of AST pretty-printing.
2019-07-09 22:17:44 +03:00