Commit Graph

95388 Commits

Author SHA1 Message Date
Vadim Petrochenkov
e1d871e2d9 Remove built-in derive macros Send and Sync 2019-06-23 15:33:39 +03:00
bors
5d677b2efd Auto merge of #60861 - Centril:let-chains-ast-intro, r=petrochenkov
[let_chains, 2/6] Introduce `Let(..)` in AST, remove IfLet + WhileLet and parse let chains

Here we remove `ast::ExprKind::{IfLet, WhileLet}` and introduce `ast::ExprKind::Let`.
Moreover, we also:
+ connect the parsing logic for let chains
+ introduce the feature gate
+ rewire HIR lowering a bit.

However, this does not connect the new syntax to semantics in HIR.
That will be the subject of a subsequent PR.

Per https://github.com/rust-lang/rust/issues/53667#issuecomment-471583239.
Next step after https://github.com/rust-lang/rust/pull/59288.

cc @Manishearth re. Clippy.

r? @oli-obk
2019-06-23 12:28:12 +00:00
Julien Cretin
0aeab41e5a Run rustfmt 2019-06-23 11:44:52 +02:00
Mazdak Farrokhzad
4d53714183 Remove redundant syntax::ast::Guard. 2019-06-23 11:32:16 +02:00
bors
a96ba96915 Auto merge of #62069 - Centril:rollup-m8n4uw7, r=Centril
Rollup of 5 pull requests

Successful merges:

 - #62047 (Trigger `unused_attribute` lint on `#[cfg_attr($pred,)]`)
 - #62049 (Fix one missing `dyn`.)
 - #62051 (Lint empty `#[derive()]` as unused attribute.)
 - #62057 (Deny explicit_outlives_requirements in the compiler)
 - #62068 (Fix meta-variable binding errors in macros)

Failed merges:

r? @ghost
2019-06-23 00:10:17 +00:00
Mazdak Farrokhzad
74380b3336
Rollup merge of #62068 - ia0:fix_meta_var, r=petrochenkov
Fix meta-variable binding errors in macros

The errors are either:
- The meta-variable used in the right-hand side is not bound (or defined) in the
  left-hand side.
- The meta-variable used in the right-hand side does not repeat with the same
  kleene operator as its binder in the left-hand side. Either it does not repeat
  enough, or it uses a different operator somewhere.

This change should have no semantic impact.

Found by https://github.com/rust-lang/rust/pull/62008
2019-06-23 01:59:20 +02:00
Mazdak Farrokhzad
07c82e183b
Rollup merge of #62057 - matthewjasper:deny-unnecessary-outlives, r=Mark-Simulacrum
Deny explicit_outlives_requirements in the compiler
2019-06-23 01:59:19 +02:00
Mazdak Farrokhzad
675ac94f8b
Rollup merge of #62051 - Centril:unused-derive-, r=petrochenkov
Lint empty `#[derive()]` as unused attribute.

Closes https://github.com/rust-lang/rust/issues/54651.

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

r? @petrochenkov
2019-06-23 01:59:17 +02:00
Mazdak Farrokhzad
0f2f993879
Rollup merge of #62049 - crlf0710:patch-2, r=jonas-schievink
Fix one missing `dyn`.

It's in the documentation of `Unsize`.
2019-06-23 01:59:16 +02:00
Mazdak Farrokhzad
869680736d
Rollup merge of #62047 - Centril:cfg-attr-empty-lint, r=estebank
Trigger `unused_attribute` lint on `#[cfg_attr($pred,)]`

Lint on `#[cfg_attr($pred,)]` as decided in https://github.com/rust-lang/rust/issues/54881#issuecomment-441442173.

Closes https://github.com/rust-lang/rust/issues/54881.

r? @estebank
2019-06-23 01:59:15 +02:00
Mazdak Farrokhzad
c75f7ecaee let_chains: note re. back-compat wrt. expr beginning. 2019-06-23 01:41:09 +02:00
Mazdak Farrokhzad
7abb2350df let_chains: Revert 'fn with' in ast_validation. 2019-06-23 01:39:13 +02:00
Julien Cretin
b8106b59d2 Fix meta-variable binding errors in macros
The errors are either:
- The meta-variable used in the right-hand side is not bound (or defined) in the
  left-hand side.
- The meta-variable used in the right-hand side does not repeat with the same
  kleene operator as its binder in the left-hand side. Either it does not repeat
  enough, or it uses a different operator somewhere.

This change should have no semantic impact.
2019-06-23 01:30:41 +02:00
Mazdak Farrokhzad
90b9e96cc3 let_chains: More accurately describe ast::ExprKind::Let.
Co-Authored-By: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
bc72ce66a1 let_chains: Add test cases to pprust-expr-roundtrip. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
851066f57e let_chains: Fix bugs in pretty printing. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
7465eb44f0 let_chains: Refactor parse_{if,while}_expr a bit. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
5ae5086cc5 let_chains: --bless tests due to recovery in lowering. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
2017be4ef6 let_chains: Remove ast_validation logic in favor of lowering with recovery. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
10234d286a let_chains: Adjust tests for pre-expansion gating. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
eb4f54a58d let_chains: Move feature gating to pre-expansion. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
d551880267 let_chains: Inline visit_expr_with_let_maybe_allowed. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
92587e41d9 let_chains: readd kw::let to ident_can_begin_expr. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
61fc727fe0 let_chains: Fuse PatternSource::Let & ::LetExpr. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
a505d9d20a let_chains: scrutinee -> condition 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
07f37c88fb let_chains: Account for const generics in validation tests. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
a80aa34951 let_chains: Change AST validation strategy slightly. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
1ff947f596 let_chains: scrutinee -> head expression. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
3b7f0cb7e0 let_chains: Fix outdated doc-comment re. 'parse_if_expr'. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
8b72e4c815 let_chains: Improve documentation for ast::ExprKind::Let(..). 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
86250a666e let_chains: Comment out Let in ident_can_begin_expr. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
530f954e92 let_chains: Test pretty output for simple stable if-let. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
b425df0be1 let_chains: Remove redundant tests in syntax-ambiguity-*.rs. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
d45dadd951 let_chains: Add test protecting the precedence of && in relation to other things. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
6a6b07906f let_chains: Adjust unnecessary parens tests. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
c0c5791049 let_chains: Add feature gate tests. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
357b49992c let_chains: Add tests for places where let expressions aren't allowed. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
ebea1c2cc0 let_chains: Add feature gate. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
c9fb639085 let_chains: Adjust lowering logic in lieu of ::Let. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
a7b00f5807 let_chains: Handle disallowing of let chains in places lowering won't support. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
fcffac5eea let_chains: Handle in unused parenthesis lint. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
70a65e9d1f let_chains: Handle in resolve. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
dff1e379fc let_chains: Add support for parsing let expressions. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
3fc9642014 let_chains: Handle it in AST pretty printing. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
f0ab633e4d let_chains: Remove ast::ExprKind::{IfLet, WhileLet} from visitors and introduce ::Let. 2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
42accc99e6 let_chains: Remove ast::ExprKind::{IfLet, WhileLet} and introduce ::Let. 2019-06-23 01:29:29 +02:00
Aaron Hill
93aa60b4bf
Move run-pass test to run-pass/generator 2019-06-22 17:31:14 -04:00
Aaron Hill
8450289e65
Fix fallout from rebase 2019-06-22 17:30:56 -04:00
bors
de02101e6d Auto merge of #62040 - felixrabe:patch-3, r=dtolnay
Punctuation typo in ! docs
2019-06-22 20:45:34 +00:00
Aaron Hill
0fa945e184
Change how we compute yield_in_scope
Compound operators (e.g. 'a += b') have two different possible
evaluation orders. When the left-hand side is a primitive type, the
expression is evaluated right-to-left. However, when the left-hand side
is a non-primitive type, the expression is evaluated left-to-right.

This causes problems when we try to determine if a type is live across a
yield point. Since we need to perform this computation before typecheck
has run, we can't simply check the types of the operands.

This commit calculates the most 'pessimistic' scenario - that is,
erring on the side of treating more types as live, rather than fewer.
This is perfectly safe - in fact, this initial liveness computation is
already overly conservative (e.g. issue #57478). The important thing is
that we compute a superset of the types that are actually live across
yield points. When we generate MIR, we'll determine which types actually
need to stay live across a given yield point, and which ones cam
actually be dropped.

Concretely, we force the computed HIR traversal index for
right-hand-side yield expression to be equal to the maximum index for
the left-hand side. This covers both possible execution orders:

* If the expression is evalauted right-to-left, our 'pessismitic' index
is unecessary, but safe. We visit the expressions in an
ExprKind::AssignOp from right to left, so it actually would have been
safe to do nothing. However, while increasing the index of a yield point
might cause the compiler to reject code that could actually compile, it
will never cause incorrect code to be accepted.
* If the expression is evaluated left-to-right, our 'pessimistic' index
correctly ensures that types in the left-hand-side are seen as occuring
before the yield - which is exactly what we want
2019-06-22 16:03:17 -04:00