about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2019-10-01Rollup merge of #64907 - alexreg:tidy-up, r=Mark-SimulacrumMazdak Farrokhzad-1/+1
A small amount of tidying-up factored out from PR #64648 As requested by @Mark-Simulacrum, I put this in a separate commit to make it easier to review. (As far as I can tell, no violations of the policy here, and they are simply in a separate PR because they're not directly related to the import of that PR.) r? @Mark-Simulacrum
2019-10-01Rollup merge of #64887 - Centril:recover-trailing-vert, r=estebankMazdak Farrokhzad-26/+79
syntax: recover trailing `|` in or-patterns Fixes https://github.com/rust-lang/rust/issues/64879. For example (this also shows that we are sensitive to the typo `||`): ``` error: a trailing `|` is not allowed in an or-pattern --> $DIR/remove-leading-vert.rs:33:11 | LL | A || => {} | - ^^ help: remove the `||` | | | while parsing this or-pattern starting here | = note: alternatives in or-patterns are separated with `|`, not `||` ``` r? @estebank
2019-10-01Rollup merge of #63931 - petrochenkov:stabmac, r=CentrilMazdak Farrokhzad-20/+8
Stabilize macros in some more positions - Fn-like macros and attribute macros in `extern` blocks - Fn-like procedural macros in type positions - ~Attribute macros on inline modules~ (moved to https://github.com/rust-lang/rust/pull/64273) Stabilization report: https://github.com/rust-lang/rust/pull/63931#issuecomment-526362396. Closes https://github.com/rust-lang/rust/issues/49476 cc https://github.com/rust-lang/rust/issues/54727
2019-10-01Rollup merge of #63674 - petrochenkov:meta2, r=CentrilMazdak Farrokhzad-65/+93
syntax: Support modern attribute syntax in the `meta` matcher Where "modern" means https://github.com/rust-lang/rust/pull/57367: ``` PATH PATH `(` TOKEN_STREAM `)` PATH `[` TOKEN_STREAM `]` PATH `{` TOKEN_STREAM `}` ``` Unfortunately, `meta` wasn't future-proofed using the `FOLLOW` token set like other matchers (https://github.com/rust-lang/rust/issues/34011), so code like `$meta:meta {` or `$meta:meta [` may break, and we need a crater run to find out how often this happens in practice. Closes https://github.com/rust-lang/rust/issues/49629 (by fully supporting `meta` rather than removing it.)
2019-10-01Address review commentsVadim Petrochenkov-2/+3
2019-09-30Rollup merge of #64838 - GuillaumeGomez:long-err-explanation-e0550, r=oli-obkTyler Mandry-1/+19
Add long error explanation for E0550 Part of #61137
2019-09-30syntax: Support modern attribute syntax in the `meta` matcherVadim Petrochenkov-46/+64
2019-09-30syntax: Split `ast::Attribute` into container and inner partsVadim Petrochenkov-19/+28
2019-09-30Stabilize proc macros in type positionsVadim Petrochenkov-5/+5
2019-09-30Stabilize macros in `extern` blocksVadim Petrochenkov-15/+3
Add some tests for macros in extern blocks, remove duplicate tests
2019-09-30Add long error explanation for E0550Guillaume Gomez-1/+19
2019-09-30Auto merge of #64778 - csmoe:index, r=eddybbors-5/+5
Introduce librustc_index crate Closes #50592
2019-09-30Added backticks for one diagnostic message.Alexander Regueiro-1/+1
2019-09-29Rollup merge of #64894 - Centril:fix-64682, r=petrochenkovMazdak Farrokhzad-76/+41
syntax: fix dropping of attribute on first param of non-method assocated fn Fixes #64682. The general idea is that we bake parsing of `self` into `parse_param_general` and then we just use standard list parsing. Overall, this simplifies the parsing and makes it more consistent. r? @petrochenkov cc @c410-f3r
2019-09-29remove indexed_vec re-export from rustc_data_structurescsmoe-4/+3
2019-09-29remove bit_set re-export from rustc_data_structurescsmoe-1/+2
2019-09-29syntax: fix #64682.Mazdak Farrokhzad-76/+41
Fuse parsing of `self` into `parse_param_general`.
2019-09-29syntax: recover trailing `|` in or-patterns.Mazdak Farrokhzad-26/+79
2019-09-29Rollup merge of #64824 - Mark-Simulacrum:no-stable-hasher-result-everywhere, ↵Mazdak Farrokhzad-5/+2
r=michaelwoerister No StableHasherResult everywhere This removes the generic parameter on `StableHasher`, instead moving it to the call to `finish`. This has the side-effect of making all `HashStable` impls nicer, since we no longer need the verbose `<W: StableHasherResult>` that previously existed -- often forcing line wrapping. This is done for two reasons: * we should avoid false "generic" dependency on the result of StableHasher * we don't need to codegen two/three copies of all the HashStable impls when they're transitively used to produce a fingerprint, u64, or u128. I haven't measured, but this might actually make our artifacts somewhat smaller too. * Easier to understand/read/write code -- the result of the stable hasher is irrelevant when writing a hash impl.
2019-09-29Rollup merge of #63492 - eddyb:cvarargs, r=nagisa,matthewjasperMazdak Farrokhzad-15/+21
Remove redundancy from the implementation of C variadics. This cleanup was first described in https://github.com/rust-lang/rust/issues/44930#issuecomment-497163539: * AST doesn't track `c_variadic: bool` anymore, relying solely on a trailing `CVarArgs` type in fn signatures * HIR doesn't have a `CVarArgs` anymore, relying solely on `c_variadic: bool` * same for `ty::FnSig` (see tests for diagnostics improvements from that) * `{hir,mir}::Body` have one extra argument than the signature when `c_variadic == true` * `rustc_typeck` and `rustc_mir::{build,borrowck}` need to give that argument the right type (which no longer uses a lifetime parameter, but a function-internal scope) * `rustc_target::abi::call` doesn't need special hacks anymore (since it never sees the `VaListImpl` now, it's all inside the body) r? @nagisa / @rkruppe cc @dlrobertson @oli-obk
2019-09-28Switch over all StableHash impls to new formatMark Rousskov-5/+2
2019-09-28syntax: don't keep a redundant c_variadic flag in the AST.Eduard-Mihai Burtescu-15/+21
2019-09-27Filter out stmts made for the redundant_semicolon lint when pretty-printingnathanwhit-3/+12
2019-09-27Auto merge of #64813 - varkor:node-to-kind, r=Centrilbors-298/+295
Rename `*.node` to `*.kind`, and `hair::Pattern*` to `hair::Pat*` In both `ast::Expr` and `hir::Expr`: - Rename `Expr.node` to `Expr.kind`. - Rename `Pat.node` to `Pat.kind`. - Rename `ImplItem.node` to `ImplItem.kind`. - Rename `Lit.node` to `Lit.kind`. - Rename `TraitItem.node` to `TraitItem.kind`. - Rename `Ty.node` to `Ty.kind`. - Rename `Stmt.node` to `Stmt.kind`. - Rename `Item.node` to `Item.kind`. - Rename `ForeignItem.node` to `ForeignItem.kind`. - Rename `MetaItem.node` to `MetaItem.kind`. Also: - Rename `hair::FieldPattern` to `hair::FieldPat`. - Rename `hair::PatternKind` to `hair::PatKind`. - Rename `hair::PatternRange` to `hair::PatRange`. - Rename `PatternContext` to `PatCtxt`. - Rename `PatternTypeProjection` to `PatTyProj`. - Rename `hair::Pattern` to `hair::Pat`. These two sets of changes are grouped together to aid with merging. The only changes are renamings. r? @petrochenkov
2019-09-26Rename `MetaItem.node` to `MetaItem.kind`varkor-35/+35
2019-09-26Rename `ForeignItem.node` to `ForeignItem.kind`varkor-13/+13
2019-09-26Rename `Item.node` to `Item.kind`varkor-28/+28
2019-09-26Rename `Stmt.node` to `Stmt.kind`varkor-40/+40
2019-09-26Rename `Ty.node` to `Ty.kind`varkor-37/+37
2019-09-26Rename `TraitItem.node` to `TraitItem.kind`varkor-11/+11
2019-09-26Rename `Lit.node` to `Lit.kind`varkor-15/+15
2019-09-26Rename `ImplItem.node` to `ImplItem.kind`varkor-13/+13
2019-09-26Rename `Pat.node` to `Pat.kind`varkor-39/+39
2019-09-26Rename `Expr.node` to `Expr.kind`varkor-70/+67
For both `ast::Expr` and `hir::Expr`.
2019-09-26Rollup merge of #64783 - onehr:onehrxn, r=varkorMazdak Farrokhzad-1/+7
Fix issue #64732 Based on issue #64732, when creating a byte literal with single quotes, the suggestion message would indicate that you meant to write a `str` literal, but we actually meant to write a byte string literal. So I changed the unescape_error_reporting.rs to decide whether to print out "if you meant to write a `str` literal, use double quotes", or "if you meant to write a byte string literal, use double quotes". Fixes #64732.
2019-09-26Auto merge of #62661 - arielb1:never-reserve, r=nikomatsakisbors-1/+4
reserve `impl<T> From<!> for T` this is necessary for never-type stabilization. cc #57012 #35121 I think we wanted a crater run for this @nikomatsakis? r? @nikomatsakis
2019-09-25Fix issue #64732Haoran Wang-1/+7
Based on issue #64732, when creating a byte literal with single quotes, the suggestion message would indicate that you meant to write a `str` literal, but we actually meant to write a byte string literal. So I changed the unescape_error_reporting.rs to decide whether to print out "if you meant to write a `str` literal, use double quotes", or "if you meant to write a byte string literal, use double quotes".
2019-09-25Rollup merge of #64764 - Mark-Simulacrum:snap, r=CentrilMazdak Farrokhzad-1/+0
Master is now 1.40 r? @pietroalbini
2019-09-25Rollup merge of #64759 - matklad:simplify-macro, r=petrochenkovMazdak Farrokhzad-48/+18
Refactor mbe a tiny bit
2019-09-25Rollup merge of #64508 - Centril:or-pat-hir, r=matthewjasperMazdak Farrokhzad-2/+0
or-patterns: Push `PatKind/PatternKind::Or` at top level to HIR & HAIR Following up on work in https://github.com/rust-lang/rust/pull/64111, https://github.com/rust-lang/rust/pull/63693, and https://github.com/rust-lang/rust/pull/61708, in this PR: - We change `hair::Arm.patterns: Vec<Pattern<'_>>` into `hir::Arm.pattern: Pattern<'_>`. - `fn hair::Arm::top_pats_hack` is introduced as a temporary crutch in MIR building to avoid more changes. - We change `hir::Arm.pats: HirVec<P<Pat>>` into `hir::Arm.pat: P<Pat>`. - The hacks in `rustc::hir::lowering` are removed since the representation hack is no longer necessary. - In some places, `fn hir::Arm::top_pats_hack` is introduced to leave some things as future work. - Misc changes: HIR pretty printing is adjusted to behave uniformly wrt. top/inner levels, rvalue promotion is adjusted, regionck, and dead_code is also. - Type checking is adjusted to uniformly handle or-patterns at top/inner levels. To make things compile, `p_0 | ... | p_n` is redefined as a "reference pattern" in [`fn is_non_ref_pat`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_typeck/check/struct.FnCtxt.html#method.is_non_ref_pat) for now. This is done so that reference types are not eagerly stripped from the `expected: Ty<'tcx>`. - Liveness is adjusted wrt. the `unused_variables` and `unused_assignments` lints to handle top/inner levels uniformly and the handling of `fn` parameters, `let` locals, and `match` arms are unified in this respect. This is not tested for now as exhaustiveness checks are reachable and will ICE. - In `check_match`, checking `@` and by-move bindings is adjusted. However, exhaustiveness checking is not adjusted the moment and is handled by @dlrobertson in https://github.com/rust-lang/rust/pull/63688. - AST borrowck (`construct.rs`) is not adjusted as AST borrowck will be removed soon. r? @matthewjasper cc @dlrobertson @varkor @oli-obk
2019-09-25Snap cfgs to new betaMark Rousskov-1/+0
2019-09-25remove unused peekableAleksey Kladov-4/+3
2019-09-25move function closer to its usageAleksey Kladov-13/+14
2019-09-25remove unused parametersAleksey Kladov-31/+1
2019-09-25Rollup merge of #64753 - ehuss:json-short-explain, r=Mark-SimulacrumMazdak Farrokhzad-0/+7
Don't emit explain with json short messages. This fixes an issue where `--error-format=json --json=diagnostic-short` would emit the "For more information about this error" message, which doesn't match the behavior of `--error-format=short` which explicitly excludes it.
2019-09-24Don't emit explain with json short messages.Eric Huss-0/+7
2019-09-24Rollup merge of #64702 - sinkuu:deps, r=jonas-schievinkMazdak Farrokhzad-1/+0
Remove unused dependencies
2019-09-24Rollup merge of #64698 - Centril:infer-const-with-stash, r=estebankMazdak Farrokhzad-8/+45
Recover on `const X = 42;` and infer type + Error Stash API Here we: 1. Introduce a notion of the "error stash". This is a map in the `Handler` to which you can `err.stash(...)` away your diagnostics and then steal them in a later "phase" of the compiler (e.g. stash in parser, steal in typeck) to enrich them with more information that isn't available in the previous "phase". I believe I've covered all the bases to make sure these diagnostics are actually emitted eventually even under `#[cfg(FALSE)]` but please check my logic. 2. Recover when parsing `[const | static mut?] $ident = $expr;` which has a missing type. Use the "error stash" to stash away the error and later steal the error in typeck where we emit the error as `MachineApplicable` with the actual inferred type. This builds on https://github.com/rust-lang/rust/pull/62804. cc https://github.com/rust-lang/rfcs/pull/2545 r? @estebank
2019-09-24Rollup merge of #64689 - matklad:refactor-mbe, r=petrochenkovMazdak Farrokhzad-292/+295
Refactor macro by example This doesn't do anything useful yet, and just moves code around and restricts visibility
2019-09-24add error message for caseAriel Ben-Yehuda-2/+1