Commit graph

9494 commits

Author SHA1 Message Date
Mathias Blikstad
ef5acdeceb RFC 2027: "first draft" of implementation
These are a squashed series of commits.
2019-10-22 15:24:33 -04:00
Mazdak Farrokhzad
7c20a8ddb8
Rollup merge of #65214 - Amanieu:cfg_atomic, r=alexcrichton
Split non-CAS atomic support off into target_has_atomic_load_store

This PR implements my proposed changes in https://github.com/rust-lang/rust/issues/32976#issuecomment-518542029 by removing `target_has_atomic = "cas"` and splitting `target_has_atomic` into two separate `cfg`s:

* `target_has_atomic = 8/16/32/64/128`: This indicates the largest width that the target can atomically CAS (which implies support for all atomic operations).
* ` target_has_atomic_load_store = 8/16/32/64/128`: This indicates the largest width that the target can support loading or storing atomically (but may not support CAS).

cc #32976

r? @alexcrichton
2019-10-13 19:17:04 +02:00
Mazdak Farrokhzad
b82859171c
Rollup merge of #65360 - Centril:mbrpt, r=petrochenkov
mbe: reduce panictry! uses.

Extracted from https://github.com/rust-lang/rust/pull/65324.

r? @petrochenkov
2019-10-13 13:34:44 +02:00
Mazdak Farrokhzad
af54a3e91d
Rollup merge of #65359 - Centril:sil, r=davidtwco
simplify integer_lit

Extracted from https://github.com/rust-lang/rust/pull/65324.

r? @davidtwco
2019-10-13 13:34:42 +02:00
Mazdak Farrokhzad
5af528a03a
Rollup merge of #65358 - Centril:smsf, r=davidtwco
simplify maybe_stage_features

Extracted from https://github.com/rust-lang/rust/pull/65324.

r? @estebank
2019-10-13 13:34:41 +02:00
Mazdak Farrokhzad
b143aa2b38
Rollup merge of #65357 - Centril:simplify-maybe-annotate-with-ascription, r=davidtwco
syntax: simplify maybe_annotate_with_ascription

Split out from https://github.com/rust-lang/rust/pull/65324.

r? @estebank
2019-10-13 13:34:40 +02:00
Mazdak Farrokhzad
94db37a4f5 mbe: reduce panictry! uses. 2019-10-13 06:23:20 +02:00
Mazdak Farrokhzad
7effe633b0 simplify integer_lit 2019-10-13 06:20:03 +02:00
Mazdak Farrokhzad
477a68b720 simplify maybe_stage_features 2019-10-13 06:16:40 +02:00
Mazdak Farrokhzad
9f09387f53 syntax: simplify maybe_annotate_with_ascription 2019-10-13 06:14:07 +02:00
Guanqun Lu
63cb2fa197 compress the function, remove the assert check. 2019-10-12 23:00:48 +08:00
Guanqun Lu
e0395341f7 replace the hand-written binary search with the library one 2019-10-12 15:50:26 +08:00
bors
d4f7f974b8 Auto merge of #64716 - jonhoo:stabilize-mem-take, r=SimonSapin
Stabilize mem::take (mem_take)

Tracking issue: https://github.com/rust-lang/rust/issues/61129

r? @matklad
2019-10-11 12:45:20 +00:00
bors
e59dab52d4 Auto merge of #65198 - nnethercote:fix-65080, r=Mark-Simulacrum
Speed up `TokenStream` concatenation

This PR fixes the quadratic behaviour identified in #65080.

r? @Mark-Simulacrum
2019-10-09 08:57:26 +00:00
Mazdak Farrokhzad
ae5bb7e289
Rollup merge of #65037 - anp:track-caller, r=oli-obk
`#[track_caller]` feature gate (RFC 2091 1/N)

RFC text: https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md
Tracking issue: https://github.com/rust-lang/rust/issues/47809

I started with @ayosec's commit to add the feature gate with tests and rebased it onto current master. I fixed up some tidy lints and added a test.
2019-10-09 05:31:35 +02:00
Jon Gjengset
45aca119a6
Stabilize mem::take (mem_take)
Tracking issue: https://github.com/rust-lang/rust/issues/61129
2019-10-08 18:04:18 -04:00
Mazdak Farrokhzad
fc068222d0
Rollup merge of #64284 - Mark-Simulacrum:include-warn, r=petrochenkov
Warn if include macro fails to include entire file

This currently introduces an error, mainly because that was just simpler, and I'm not entirely certain if we can introduce a lint without an RFC and such.

This is primarily to get feedback on the approach and overall aim -- in particular, do we think this is helpful? If so, we probably will need lang-team sign off and decide if it should be an error (as currently introduced by this PR), a lint, or a warning.

r? @petrochenkov

cc https://github.com/rust-lang/rust/issues/35560
2019-10-08 23:31:19 +02:00
Amanieu d'Antras
dfe76a1093 Split non-CAS atomic support off into target_has_atomic_load_store 2019-10-08 20:34:30 +01:00
Mazdak Farrokhzad
7153c9262a
Rollup merge of #64918 - GuillaumeGomez:long-err-explanation-E0551, r=oli-obk
Add long error explanation for E0551

Part of #61137
2019-10-08 15:45:25 +02:00
Nicholas Nethercote
75e0078a17 Optimize TokenStreamBuilder::push.
Currently, when two tokens must be glued together, this function duplicates
large chunks of the existing streams. This can cause quadratic behaviour.

This commit changes the function so that it overwrites the last token with a
glued token, which avoids the quadratic behaviour. This removes the need for
`TokenStreamBuilder::push_all_but_{first,last}_tree`.

The commit also restructures `push` somewhat, by removing
`TokenStream::{first_tree_and_joint,last_tree_if_joint}` in favour of more
pattern matching and some comments. This makes the code shorter, and in my
opinion, more readable.
2019-10-08 16:57:29 +11:00
Nicholas Nethercote
3832a634d3 Optimize TokenStream::from_streams.
Currently, this function creates a new empty stream, and then appends
the elements from each given stream onto that stream. This can cause
quadratic behaviour.

This commit changes the function so that it modifies the first stream
(which can be long) by extending it with the elements from the
subsequent streams (which are almost always short), which avoids the
quadratic behaviour.
2019-10-08 16:57:07 +11:00
Mazdak Farrokhzad
4737095416
Rollup merge of #65040 - Centril:items-cleanup, r=estebank
syntax: more cleanups in item and function signature parsing

Follow up to https://github.com/rust-lang/rust/pull/64910.

Best read commit-by-commit.

r? @estebank
2019-10-08 05:02:35 +02:00
Mark Rousskov
e068cec13e Warn if include macro fails to include entire file 2019-10-07 19:47:53 -04:00
Adam Perry
d931afe470 Mark #![feature(track_caller)] as incomplete. 2019-10-07 08:05:32 -07:00
Adam Perry
43d4b70417 track_caller feature gate starts in 1.40.0.
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-10-07 08:05:22 -07:00
Adam Perry
6c04c8eb8e track_caller run-pass test, lint cleanup, PR review. 2019-10-07 08:05:22 -07:00
Ayose
543449d4fd [RFC 2091] Add #[track_caller] attribute.
- The attribute is behind a feature gate.
- Error if both #[naked] and #[track_caller] are applied to the same function.
- Error if #[track_caller] is applied to a non-function item.
- Error if ABI is not "rust"
- Error if #[track_caller] is applied to a trait function.

Error codes and descriptions are pending.
2019-10-07 08:05:21 -07:00
Charles Lew
2dab187024 Fix compilation error after rebase. 2019-10-07 14:33:49 +08:00
Mazdak Farrokhzad
6b23c22cca syntax: refactor with new fn parse_use_tree_glob_or_nested. 2019-10-07 06:47:24 +02:00
Mazdak Farrokhzad
9c6582a2c0 syntax: use parse_extern_abi more. 2019-10-07 06:18:47 +02:00
Charles Lew
eb492455f2 Address review comments. 2019-10-07 12:01:56 +08:00
Charles Lew
e70ffed9cd Add feature gate for raw_dylib. 2019-10-07 12:01:54 +08:00
Mazdak Farrokhzad
a7ba754b6c syntax: unify and simplify fn signature parsing. 2019-10-07 06:01:38 +02:00
Mazdak Farrokhzad
7f9638d5d4 syntax: unify trait parsing a bit. 2019-10-07 06:01:38 +02:00
Mazdak Farrokhzad
090f3fd0c9 syntax: further item parsing cleanup 2019-10-07 06:01:38 +02:00
Mazdak Farrokhzad
3bdbfbe8b9 syntax: de-dups in item parsing. 2019-10-07 05:59:56 +02:00
Mazdak Farrokhzad
e0fe4be465 syntax: cleanup associated const parsing. 2019-10-07 05:59:56 +02:00
bors
4ac4809ccf Auto merge of #64906 - Aaron1011:feature/extern-const-fn, r=Centril
Add support for `const unsafe? extern fn`

This works just as you might expect - an `const extern fn` is a `const fn` that is callable from foreign code.

Currently, panicking is not allowed in `const`s. When https://github.com/rust-lang/rfcs/pull/2345 (https://github.com/rust-lang/rust/issues/51999) is stabilized, then panicking in an `const extern fn` will produce a compile-time error when invoked at compile time, and an abort when invoked at runtime.

Since this is extending the language (we're allowing the `const` keyword in a new context), I believe that this will need an FCP. However, it's a very minor change, so I didn't think that filing an RFC was necessary.

This will allow libc (and other FFI crates) to make many functions `const`, without having to give up on making them `extern` as well.

Tracking issue: https://github.com/rust-lang/rust/issues/64926.
2019-10-07 00:12:12 +00:00
Tyler Mandry
f5c8e12a7e
Rollup merge of #65123 - Centril:mac-invoc-in-mut-pat, r=estebank
Account for macro invocation in `let mut $pat` diagnostic.

Fixes https://github.com/rust-lang/rust/issues/65122.

r? @estebank
2019-10-05 21:55:07 -07:00
Tyler Mandry
c7d7e3730a
Rollup merge of #64909 - estebank:turbofish-reloaded, r=Centril
When encountering chained operators use heuristics to recover from bad turbofish
2019-10-05 21:54:52 -07:00
Mazdak Farrokhzad
5f94a53d1a Account for macro invocation in let mut $pat diagnostic. 2019-10-05 04:34:26 +02:00
Tyler Mandry
dd9ccb20fc
Rollup merge of #65055 - GuillaumeGomez:long-err-explanation-E0556, r=petrochenkov
Add long error explanation for E0556

Part of #61137
2019-10-03 16:25:47 -07:00
Tyler Mandry
2a9bd75994
Rollup merge of #64690 - petrochenkov:mixed, r=dtolnay
proc_macro API: Expose `macro_rules` hygiene

Proc macros do not have direct access to our oldest and most stable hygiene kind - `macro_rules` hygiene.

To emulate it macro authors have to go through two steps - first generate a temporary `macro_rules` item (using a derive, at least until https://github.com/rust-lang/rust/pull/64035 is merged), then generate a macro call to that item. Popular crates like [proc_macro_hack](https://crates.io/crates/proc-macro-hack) use this trick to generate hygienic identifiers from proc macros.

I'd say that these workarounds with nested macro definitions have more chances to hit some corner cases in our hygiene system, in which we don't have full confidence.
So, let's provide a direct access to `macro_rules` hygiene instead.

This PR does that by adding a new method `Span::mixed_site` (bikeshedding is welcome) in addition to existing `Span::call_site` (stable) and `Span::def_site` (unstable).
Identifiers with this span resolve at def-site in for local variables, labels and `$crate`, and resolve at call-site for everything else, i.e. exactly like identifiers produced by `macro_rules`.

This API addition opens the way to stabilizing proc macros in expression positions (https://github.com/rust-lang/rust/issues/54727), for which use of call-site hygiene or workarounds with temporary items would be quite unfortunate.
(`macro_rules` expanded in expression position, on the other hand, are stable since 1.0 and widely used.)

r? @dtolnay @alexcrichton
2019-10-03 16:25:39 -07:00
Tyler Mandry
da0afc1638
Rollup merge of #64675 - Centril:deprecate-plugin, r=oli-obk
Deprecate `#![plugin]` & `#[plugin_registrar]`

This PR deprecates `#![plugin]` and `#[plugin_registrar]`.

~A removal deadline is set: 1.44.0. This will be in 9 months from now and should give everyone who is still relying on the feature ample time to rid themselves of this dependency.~

cc https://github.com/rust-lang/rust/issues/29597

r? @Mark-Simulacrum
2019-10-03 16:25:37 -07:00
Esteban Küber
02f57f83a9 review comments 2019-10-03 13:22:18 -07:00
Esteban Küber
f1499a8646 review comments 2019-10-03 11:55:19 -07:00
Esteban Küber
dfdc369b40 review comments 2019-10-03 11:55:19 -07:00
Esteban Küber
d7dceaa0c5 Account for missing turbofish in paths too 2019-10-03 11:55:18 -07:00
Esteban Küber
6c9f298a8b review comments 2019-10-03 11:55:18 -07:00
Esteban Küber
ed60cf2475 When encountering chained operators use heuristics to recover from bad turbofish 2019-10-03 11:55:18 -07:00