Commit graph

185 commits

Author SHA1 Message Date
Ariel Ben-Yehuda
5d79e8c4c9 reserve impl<T> From<!> for T
this is necessary for never-type stabilization
2019-09-24 21:11:50 +03:00
Matthew Jasper
5ae3830d58 Give more Idents spans 2019-09-15 09:15:38 +01:00
Vadim Petrochenkov
f7434aef26 Support "soft" feature-gating using a lint
Use it for feature-gating `#[bench]`
2019-09-07 21:37:51 +03:00
Mazdak Farrokhzad
db493ef613
Rollup merge of #63919 - matthewjasper:remove-gensymmed, r=petrochenkov
Use hygiene for AST passes

AST passes are now able to have resolve consider their expansions as if they were opaque macros defined either in some module in the current crate, or a fake empty module with `#[no_implicit_prelude]`.

* Add an ExpnKind for AST passes.
* Remove gensyms in AST passes.
* Remove gensyms in`#[test]`, `#[bench]` and `#[test_case]`.
* Allow opaque macros to define tests.
* Move tests for unit tests to their own directory.
* Remove `Ident::{gensym, is_gensymed}` - `Ident::gensym_if_underscore` still exists.

cc #60869, #61019

r? @petrochenkov
2019-09-07 08:06:04 +02:00
Matthew Jasper
beb2f5b8ff Remove Ident::{gensym, is_gensymed}
`gensym_if_underscore` still exists. The symbol interner can still
create arbitray gensyms, this is just not exposed publicly.
2019-09-05 15:07:16 +01:00
Nicholas Nethercote
cc17b1bc3c Add Symbol::{with,with2}.
And remove the `unsafe` blocks, they're not necessary.

Also rewrite `InternedString::{with,with2}` to use the new functions.

Finally, add some comments about the speed of the
`as_str()`/`as_interned_str()` functions.
2019-09-04 15:21:33 +10:00
Nicholas Nethercote
7a1bc79cbd Remove LocalInternedString::intern. 2019-09-04 14:41:09 +10:00
Nicholas Nethercote
a1cd79ff4e Remove Encodable/Decodable impls for LocalInternedString. 2019-09-04 14:41:09 +10:00
Nicholas Nethercote
6025fc843a Remove hashing impls for LocalInternedString. 2019-09-04 14:41:07 +10:00
Nicholas Nethercote
224daa64bd Remove LocalInternedString::get.
It has a single use, which is easily changed to something better.
2019-09-04 14:40:23 +10:00
Nicholas Nethercote
69ae8d9dfd Remove LocalInternedString::as_interned_str().
It's unused.
2019-09-04 14:23:45 +10:00
Oliver Scherer
26e9990198 Add a "diagnostic item" scheme
This allows lints and other diagnostics to refer to items
by a unique ID instead of relying on whacky path
resolution schemes that may break when items are
relocated.
2019-08-30 01:00:55 +02:00
Mazdak Farrokhzad
52c3846d51
Rollup merge of #63945 - Centril:recover-mut-pat, r=estebank
Recover `mut $pat` and other improvements

- Recover on e.g. `mut Foo(x, y)` and suggest `Foo(mut x, mut y)`. Fixes https://github.com/rust-lang/rust/issues/63764.
- Recover on e.g. `let mut mut x;`
- Recover on e.g. `let keyword` and `let keyword(...)`.
- Cleanups in `token.rs` with `fn is_non_raw_ident_where` and friends.
2019-08-29 05:32:48 +02:00
Matthew Jasper
3d718037dc Add default serialization for Idents
Add tests for -Zast-json and -Zast-json-noexpand, which need this impl.
2019-08-27 23:02:22 +01:00
Mazdak Farrokhzad
e49b9581ba Simplify with Symbol/Token::is_book_lit. 2019-08-27 10:21:41 +02:00
bors
fc8765d6d8 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
2019-08-18 01:02:20 +00:00
Dan Robertson
1870537f27
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.
2019-08-17 15:55:40 +00:00
Matthew Jasper
497b502062 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.
2019-08-17 08:59:36 +01:00
Mazdak Farrokhzad
cd21715c34
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
2019-08-16 18:22:30 +02:00
Vadim Petrochenkov
263e3c5950 Remove __rust_unstable_column 2019-08-15 22:58:57 +03:00
Vadim Petrochenkov
6cb28b6617 Ident::with_empty_ctxt -> Ident::with_dummy_span
`Ident` has had a full span rather than just a `SyntaxContext` for a long time now.
2019-08-15 20:39:26 +03:00
Vadim Petrochenkov
dfcbe75900 syntax_pos: Introduce a helper for checking whether a span comes from expansion 2019-08-15 20:38:12 +03:00
Ralf Jung
da6fbb1895 add basic lint testing for misuse of mem::zeroed and mem::uninitialized 2019-08-11 12:04:49 +02:00
Vadim Petrochenkov
2a9b75281b Move special treatment of derive(Copy, PartialEq, Eq) from expansion infrastructure to elsewhere 2019-08-03 23:57:35 +03:00
bors
d7270712cb Auto merge of #63180 - varkor:trait-alias-impl-trait, r=Centril
Change opaque type syntax from `existential type` to type alias `impl Trait`

This implements a new feature gate `type_alias_impl_trait` (this is slightly different from the originally proposed feature name, but matches what has been used in discussion since), deprecating the old `existential_types` feature.

The syntax for opaque types has been changed. In addition, the "existential" terminology has been replaced with "opaque", as per previous discussion and the RFC.

This makes partial progress towards implementing https://github.com/rust-lang/rust/issues/63063.

r? @Centril
2019-08-03 02:21:23 +00:00
varkor
c28ce3e4ca Replace "existential" by "opaque" 2019-08-02 02:44:36 +01:00
varkor
87738fe834 Switch existential_type to type_alias_impl_trait 2019-08-02 02:44:35 +01:00
Vadim Petrochenkov
6cc43db0b7 libsyntax_pos: Unconfigure tests during normal build 2019-08-02 01:59:01 +03:00
Vadim Petrochenkov
614037171b cleanup: Remove extern crate serialize as rustc_serializes 2019-07-23 19:20:16 +03:00
bors
fe499a7b34 Auto merge of #62684 - petrochenkov:scopevisit, r=davidtwco
resolve: Improve candidate search for unresolved macro suggestions

Use same scope visiting machinery for both collecting suggestion candidates and actually resolving the names.

The PR is better read in per-commit fashion with whitespace changes ignored (the first commit in particular moves some code around).

This should be the last pre-requisite for https://github.com/rust-lang/rust/pull/62086.
r? @davidtwco
2019-07-19 00:24:39 +00:00
bors
a3369981de Auto merge of #61749 - davidtwco:rfc-2203-const-array-repeat-exprs, r=eddyb
rustc/rustc_mir: Implement RFC 2203.

This PR implements RFC 2203, allowing constants in array repeat
expressions. Part of #49147.

r? @eddyb
2019-07-18 20:41:40 +00:00
Vadim Petrochenkov
329c05251a resolve: Visit all scopes to collect suggestion candidates for unresolved macros 2019-07-18 13:42:45 +03:00
Lzu Tao
8347917dd9 Remove feature gate dropck_parametricity completely
Therefore we also remove `#[unsafe_destructor_blind_to_params]`
attribute completly.
2019-07-11 18:44:56 +00: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
David Wood
3cca4ceed8
syntax: Add feature gate.
This commit adds a `const_in_array_repeat_expressions` feature gate and
only create `Candidate::Repeat` if it is enabled.
2019-07-07 19:51:29 +01:00
Mazdak Farrokhzad
fe807fcf3e
Rollup merge of #62213 - QuietMisdreavus:cfg-doctest, r=GuillaumeGomez
rustdoc: set cfg(doctest) when collecting doctests

Note: This PR builds on top of https://github.com/rust-lang/rust/pull/61199; only the last commit is specific to this PR.

As discussed in https://github.com/rust-lang/rust/pull/61199, we want the ability to isolate items to only when rustdoc is collecting doctests, but we can't use `cfg(test)` because of libcore's `#![cfg(not(test))]`. This PR proposes a new cfg flag, `cfg(doctest)`, specific to this situation, rather than reusing an existing flag. I've isolated it behind a feature gate so that we can contain the effects to nightly only. (A stable workaround that can be used in lieu of `#[cfg(doctest)]` is `#[cfg(rustdoc)] #[doc(hidden)]`, at least once https://github.com/rust-lang/rust/pull/61351 lands.)

Tracking issue: https://github.com/rust-lang/rust/issues/62210
2019-07-07 17:00:18 +02:00
Vadim Petrochenkov
b6d522a101 syntax: Pre-intern names of all built-in macros
They always end up interned anyway
2019-07-07 13:04:07 +03:00
QuietMisdreavus
bed54cf854 rustdoc: set cfg(doctest) when collecting doctests 2019-07-06 21:37:17 -05:00
Vadim Petrochenkov
22d6d8ac76 #[rustc_transparent_macro] -> #[rustc_macro_transparency = ...] 2019-07-06 16:59:08 +03:00
Vadim Petrochenkov
15042a3c1c #[rustc_doc_only_macro] -> #[rustc_builtin_macro] 2019-07-06 16:59:08 +03:00
Mazdak Farrokhzad
485a084b45
Rollup merge of #61545 - flip1995:internal_lints, r=oli-obk
Implement another internal lints

cc #49509

This adds ~~two~~ one internal lint~~s~~:
1. LINT_PASS_IMPL_WITHOUT_MACRO: Make sure, that the `{declare,impl}_lint_pass` macro is used to implement lint passes. cc #59669
2. ~~USAGE_OF_TYCTXT_AND_SPAN_ARGS: item 2 on the list in #49509~~

~~With 2. I wasn't sure, if this lint should be applied everywhere. That means a careful review of 0955835 would be great. Also 73fb9b4 allows this lint on some functions. Should I also apply this lint there?~~

TODO (not directly relevant for review):
- [ ] https://github.com/rust-lang/rust/pull/59316#discussion_r280186517 (not sure yet, if this works or how to query for `rustc_private`, since it's not in [`Features`](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/feature_gate/struct.Features.html) 🤔 cc @eddyb)
- [x] https://github.com/rust-lang/rust/pull/61735#discussion_r292389870
- [x] Check explicitly for the `{declare,impl}_lint_pass!` macros

r? @oli-obk
2019-07-05 20:26:51 +02:00
Mazdak Farrokhzad
bb7fbb99a2 Add separate 'async_closure' feature gate. 2019-07-03 23:59:36 +02:00
Niko Matsakis
74a6efbf00 feature-gate member constraints outside of async-await
Minimizes risk.
2019-07-02 12:25:22 -04:00
Mazdak Farrokhzad
94a066e229
Rollup merge of #62104 - Zoxc:query-info, r=eddyb
Inform the query system about properties of queries at compile time
2019-06-29 11:18:11 +02:00
bors
303f77ee1d Auto merge of #60732 - jswrenn:arbitrary_enum_discriminant, r=pnkfelix
Implement arbitrary_enum_discriminant

Implements RFC rust-lang/rfcs#2363 (tracking issue #60553).
2019-06-25 15:12:11 +00:00
John Kåre Alsaker
c877989655 Add some #[inline] attributes 2019-06-25 04:38:01 +02:00
flip1995
8e087cdd98
Use symbols in lint tool list 2019-06-24 18:14:04 +02:00
flip1995
37f09cb237
Only allow {declare,impl}_lint_pass macros for implementing LintPass 2019-06-24 10:45:20 +02:00
Mazdak Farrokhzad
ebea1c2cc0 let_chains: Add feature gate. 2019-06-23 01:29:29 +02:00
John Wrenn
ac98342e84 Implement arbitrary_enum_discriminant 2019-06-21 11:00:10 -04:00