about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2019-05-06Remove resolved FIXMEvarkor-2/+0
2019-05-06`token::LArrow` can begin argumentsvarkor-1/+2
`<-` may indicate the start of a negative const argument.
2019-05-06Remove duplicate commentvarkor-4/+0
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
2019-05-06Auto merge of #60261 - matklad:one-escape, r=petrochenkovbors-665/+905
introduce unescape module A WIP PR to gauge early feedback Currently, we deal with escape sequences twice: once when we [lex](https://github.com/rust-lang/rust/blob/112f7e9ac564e2cfcfc13d599c8376a219fde1bc/src/libsyntax/parse/lexer/mod.rs#L928-L1065) a string, and a second time when we [unescape](https://github.com/rust-lang/rust/blob/112f7e9ac564e2cfcfc13d599c8376a219fde1bc/src/libsyntax/parse/mod.rs#L313-L366) literals. Note that we also produce different sets of diagnostics in these two cases. This PR aims to remove this duplication, by introducing a new `unescape` module as a single source of truth for character escaping rules. I think this would be a useful cleanup by itself, but I also need this for https://github.com/rust-lang/rust/pull/59706. In the current state, the PR has `unescape` module which fully (modulo bugs) deals with string and char literals. I am quite happy about the state of this module What this PR doesn't have yet are: * [x] handling of byte and byte string literals (should be simple to add) * [x] good diagnostics * [x] actual removal of code from lexer (giant `scan_char_or_byte` should go away completely) * [x] performance check * [x] general cleanup of the new code Diagnostics will be the most labor-consuming bit here, but they are mostly a question of just correctly adjusting spans to sub-tokens. The current setup for diagnostics is that `unescape` produces a plain old `enum` with various problems, and they are rendered into `Handler` separately. This bit is not actually required (it is possible to just pass the `Handler` in), but I like the separation between diagnostics and logic this approach imposes, and such separation should again be useful for #59706 cc @eddyb , @petrochenkov
2019-05-05Correct handling of arguments in async fnTaiki Endo-11/+22
2019-05-04Rollup merge of #60429 - estebank:pub-path, r=michaelwoeristerMazdak Farrokhzad-2/+4
Account for paths in incorrect pub qualifier help Handle case where incorrect pub qualifier with a mod path is used and provide the same help given for all other incorrect qualifiers by making the `pub(crate)` parse check more specific.
2019-05-04Rename 'no tracking issue START' to fit better with tidy.Mazdak Farrokhzad-8/+8
2019-05-04Enforce sorting of accepted and removed features.Mazdak Farrokhzad-8/+31
2019-05-03Rollup merge of #60501 - taiki-e:async-await-mutable-arguments, r=cramertjMazdak Farrokhzad-6/+4
Propagate mutability from arguments to local bindings in async fn Fixes #60498 cc @nikomatsakis r? @davidtwco
2019-05-03Propagate mutability from arguments to local bindings in async fnTaiki Endo-6/+4
2019-05-02Deduplicate needed parentheses suggestion codeEsteban Küber-24/+28
2019-05-02fix typoEsteban Küber-4/+4
2019-05-02don't amplify errors in format! with bad literalsAleksey Kladov-7/+15
2019-05-02Group and sort feature_gate.rsAlexey Shmalko-11/+22
2019-05-02introduce unescape moduleAleksey Kladov-665/+897
Currently, we deal with escape sequences twice: once when we lex a string, and a second time when we unescape literals. This PR aims to remove this duplication, by introducing a new `unescape` mode as a single source of truth for character escaping rules
2019-05-02Rollup merge of #60437 - davidtwco:issue-60236, r=nikomatsakisMazdak Farrokhzad-23/+72
Ensure that drop order of `async fn` matches `fn` and that users cannot refer to generated arguments. Fixes #60236 and fixes #60438. This PR modifies the lowering of `async fn` arguments so that the drop order matches the equivalent `fn`. Previously, async function arguments were lowered as shown below: async fn foo(<pattern>: <ty>) { async move { } } // <-- dropped as you "exit" the fn // ...becomes... fn foo(__arg0: <ty>) { async move { let <pattern> = __arg0; } // <-- dropped as you "exit" the async block } After this PR, async function arguments will be lowered as: async fn foo(<pattern>: <ty>, <pattern>: <ty>, <pattern>: <ty>) { async move { } } // <-- dropped as you "exit" the fn // ...becomes... fn foo(__arg0: <ty>, __arg1: <ty>, __arg2: <ty>) { async move { let __arg2 = __arg2; let <pattern> = __arg2; let __arg1 = __arg1; let <pattern> = __arg1; let __arg0 = __arg0; let <pattern> = __arg0; } // <-- dropped as you "exit" the async block } If `<pattern>` is a simple ident, then it is lowered to a single `let <pattern> = <pattern>;` statement as an optimization. This PR also stops users from referring to the generated `__argN` identifiers. r? @nikomatsakis
2019-05-02Rollup merge of #60348 - agnxy:refactor-parser, r=petrochenkovMazdak Farrokhzad-162/+231
move some functions from parser.rs to diagostics.rs Starting with a few functions mentioned in https://github.com/rust-lang/rust/issues/60015#issuecomment-484259773. We might refactor parser.rs further in subsequent changes. r? @petrochenkov
2019-05-02Rollup merge of #59634 - DevQps:explain-E0704, r=estebankMazdak Farrokhzad-1/+29
Added an explanation for the E0704 error. # Description Adds an explanation on the E0704 error. I tried to stick as closely to the message that the compiler generates. It's the first time I am fixing error messages here, so if there is something I did wrong or should improve, please let me know. closes #55398
2019-05-01Ensure that users cannot use generated arguments.David Wood-1/+1
This commit gensyms the generated ident for replacement arguments so that users cannot refer to them. It also ensures that levenshtein distance suggestions do not suggest gensymed identifiers.
2019-05-01Ensure that drop order of `async fn` matches `fn`.David Wood-22/+71
This commit modifies the lowering of `async fn` arguments so that the drop order matches the equivalent `fn`. Previously, async function arguments were lowered as shown below: async fn foo(<pattern>: <ty>) { async move { } } // <-- dropped as you "exit" the fn // ...becomes... fn foo(__arg0: <ty>) { async move { let <pattern> = __arg0; } // <-- dropped as you "exit" the async block } After this PR, async function arguments will be lowered as: async fn foo(<pattern>: <ty>, <pattern>: <ty>, <pattern>: <ty>) { async move { } } // <-- dropped as you "exit" the fn // ...becomes... fn foo(__arg0: <ty>, __arg1: <ty>, __arg2: <ty>) { async move { let __arg2 = __arg2; let <pattern> = __arg2; let __arg1 = __arg1; let <pattern> = __arg1; let __arg0 = __arg0; let <pattern> = __arg0; } // <-- dropped as you "exit" the async block } If `<pattern>` is a simple ident, then it is lowered to a single `let <pattern> = <pattern>;` statement as an optimization.
2019-05-01move some functions from parser.rs to diagostics.rsAndrew Xu-162/+231
parser.rs is too big. Some functions only for error reporting and error recovery are being moved to diagostics.rs.
2019-05-01Added the E0704 error with a link to the Rust reference.Christian-1/+29
2019-04-30Reword ambigous parse error to fit with the current errorEsteban Küber-5/+6
2019-04-30Account for paths in incorrect pub qualifier helpEsteban Küber-2/+4
2019-04-30Rollup merge of #60362 - Centril:cleanup-declare-features-active, r=oli-obkMazdak Farrokhzad-183/+252
Cleanup 'active' declare_features! with uniform style + sorting. r? @oli-obk (added the FIXME you wanted) cc https://github.com/rust-lang/rust/pull/60354 cc https://github.com/rust-lang/rust/issues/60361
2019-04-30Rollup merge of #60354 - Centril:cleanup-declare-features-accepted, r=oli-obkMazdak Farrokhzad-56/+73
Cleanup declare_features! for 'accepted' with a uniform style + sort them r? @oli-obk cc https://github.com/rust-lang/rust/pull/60362 cc https://github.com/rust-lang/rust/issues/60361
2019-04-30Cleanup 'active' declare_features! with uniform style + sorting.Mazdak Farrokhzad-183/+252
2019-04-29Auto merge of #60006 - nnethercote:json-for-pipelining, r=alexcrichtonbors-2/+20
In JSON output, emit a directive after metadata is generated. To implement pipelining, Cargo needs to know when metadata generation is finished. This is done via a new JSON "directive". Unfortunately, metadata file writing currently occurs very late during compilation, so pipelining won't produce a speed-up. Moving metadata file writing earlier will be a follow-up. r? @alexcrichton
2019-04-30In JSON output, emit a directive after metadata is generated.Nicholas Nethercote-2/+20
To implement pipelining, Cargo needs to know when metadata generation is finished. This commit adds code to do that. Unfortunately, metadata file writing currently occurs very late during compilation, so pipelining won't produce a speed-up. Moving metadata file writing earlier will be a follow-up. The change involves splitting the existing `Emitter::emit` method in two: `Emitter::emit_diagnostic` and `Emitter::emit_directive`. The JSON directives look like this: ``` {"directive":"metadata file written: liba.rmeta"} ``` The functionality is behind the `-Z emit-directives` option, and also requires `--error-format=json`.
2019-04-29Identify when a stmt could have been parsed as an exprEsteban Küber-5/+88
There are some expressions that can be parsed as a statement without a trailing semicolon depending on the context, which can lead to confusing errors due to the same looking code being accepted in some places and not others. Identify these cases and suggest enclosing in parenthesis making the parse non-ambiguous without changing the accepted grammar.
2019-04-29Auto merge of #60182 - matklad:lexer-cleanup, r=petrochenkovbors-6/+4
Lexer cleanup another couple of tiny cleanups
2019-04-28Auto merge of #60352 - Centril:const-incomplete-features, r=oli-obkbors-6/+9
Float 'incomplete_features' out to a const for visibility Float `let incomplete_features` out to a `const INCOMPLETE_FEATURES` and colocate near `active` features so that it is easier to find and edit. r? @oli-obk (use rollup)
2019-04-28Cleanup declare_features! for 'accepted' with a uniform style + sort them.Mazdak Farrokhzad-56/+73
2019-04-28Float 'incomplete_features' out to a const for visibility.Mazdak Farrokhzad-6/+9
2019-04-27Document ast::ExprKind::Type.Mazdak Farrokhzad-0/+1
2019-04-26Auto merge of #60167 - varkor:tidy-filelength, r=matthewjasperbors-0/+4
Add a tidy check for files with over 3,000 lines Files with a large number of lines can cause issues in GitHub (e.g. https://github.com/rust-lang/rust/issues/60015) and also tend to be indicative of opportunities to refactor into less monolithic structures. This adds a new check to tidy to warn against files that have more than 3,000 lines, as suggested in https://github.com/rust-lang/rust/issues/60015#issuecomment-483868594. (This number was chosen fairly arbitrarily as a reasonable indicator of size.) This check can be ignored with `// ignore-tidy-filelength`. Existing files with greater than 3,000 lines currently ignore the check, but this helps us spot when files are getting too large. (We might try to split up all files larger than this in the future, as in https://github.com/rust-lang/rust/issues/60015).
2019-04-26Rollup merge of #60289 - tmandry:allow-features-include-std, r=cramertjMazdak Farrokhzad-17/+17
Make `-Z allow-features` work for stdlib features r? @cramertj
2019-04-26Rollup merge of #60267 - gnzlbg:f16c_target_feature, r=alexcrichtonMazdak Farrokhzad-0/+1
Add feature-gate for f16c target feature r? @alexcrichton
2019-04-25Make `-Z allow-features` work for stdlib featuresTyler Mandry-17/+17
2019-04-25ignore-tidy-filelength on all files with greater than 3000 linesvarkor-0/+4
2019-04-25Add feature-gate for f16c target featuregnzlbg-0/+1
2019-04-24Add guard for missing comma in macro call suggestionEsteban Küber-2/+4
2019-04-24Rollup merge of #60186 - estebank:accept-suffix, r=nikomatsakisMazdak Farrokhzad-3/+31
Temporarily accept [i|u][32|size] suffixes on a tuple index and warn Fix #60138. #59553 will need to be kept open to track the change back to rejecting this code a few versions down thee line.
2019-04-23Add rustc_allow_const_fn_ptrTaylor Cramer-4/+14
2019-04-23review comment: change linked ticketEsteban Küber-1/+1
2019-04-23Rollup merge of #59823 - davidtwco:issue-54716, r=cramertjMazdak Farrokhzad-34/+190
[wg-async-await] Drop `async fn` arguments in async block Fixes #54716. This PR modifies the HIR lowering (and some other places to make this work) so that unused arguments to a async function are always dropped inside the async move block and not at the end of the function body. ``` async fn foo(<pattern>: <type>) { async move { } } // <-- dropped as you "exit" the fn // ...becomes... fn foo(__arg0: <ty>) { async move { let <pattern>: <ty> = __arg0; } // <-- dropped as you "exit" the async block } ``` However, the exact ordering of drops is not the same as a regular function, [as visible in this playground example](https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=be39af1a58e5d430be1eb3c722cb1ec3) - I believe this to be an unrelated issue. There is a [Zulip topic](https://rust-lang.zulipchat.com/#narrow/stream/187312-t-compiler.2Fwg-async-await/topic/.2354716.20drop.20order) for this. r? @cramertj cc @nikomatsakis
2019-04-22Temporarily accept [i|u][32|size] suffixes on a tuple index and warnEsteban Küber-3/+31
2019-04-23reduce visibilityAleksey Kladov-1/+1
2019-04-23simplify and avoid allocationAleksey Kladov-2/+2
2019-04-23remove obsolete and incorrect commentAleksey Kladov-3/+1