about summary refs log tree commit diff
path: root/src/libsyntax/parse/lexer
AgeCommit message (Collapse)AuthorLines
2018-05-31Rollup merge of #51240 - nnethercote:parse-2, r=nikomatsakisGuillaume Gomez-5/+3
Two minor parsing tweaks
2018-05-31Avoid an unnecessary `match` when lexing "<-".Nicholas Nethercote-5/+1
2018-05-31Tweak identifer lexing.Nicholas Nethercote-0/+2
By calling `bump()` after getting the first char, to avoid a redundant `ident_continue()` test on it.
2018-05-28Auto merge of #50724 - zackmdavis:applicability_rush, r=Manishearthbors-6/+7
add suggestion applicabilities to librustc and libsyntax A down payment on #50723. Interested in feedback on whether my `MaybeIncorrect` vs. `MachineApplicable` judgement calls are well-calibrated (and that we have a consensus on what this means). r? @Manishearth cc @killercup @estebank
2018-05-26Fix testEsteban Küber-4/+8
2018-05-25in which we check for confusable Unicodepoints in float literal exponentZack M. Davis-5/+12
The `FatalError.raise()` might seem unmotivated (in most places in the compiler, `err.emit()` suffices), but it's actually used to maintain behavior (viz., stop lexing, don't emit potentially spurious errors looking for the next token after the bad Unicodepoint in the exponent): the previous revision's `self.err_span_` ultimately calls `Handler::emit`, which aborts if the `Handler`'s continue_after_error flag is set, which seems to typically be true during lexing (see `phase_1_parse_input` and and how `CompileController::basic` has `continue_parse_after_error: false` in librustc_driver). Also, let's avoid apostrophes in error messages (the present author would argue that users expect a reassuringly detached, formal, above-it-all tone from a Serious tool like a compiler), and use an RLS-friendly structured suggestion. Resolves #49746.
2018-05-22Auto merge of #50838 - alexcrichton:token-impls, r=eddybbors-17/+40
rustc: Fix joint-ness of stringified token-streams This commit fixes `StringReader`'s parsing of tokens which have been stringified through procedural macros. Whether or not a token tree is joint is defined by span information, but when working with procedural macros these spans are often dummy and/or overridden which means that they end up considering all operators joint if they can! The fix here is to track the raw source span as opposed to the overridden span. With this information we can more accurately classify `Punct` structs as either joint or not. Closes #50700
2018-05-20suggestion applicabilities for libsyntax and librustc, run-rustfix testsZack M. Davis-6/+7
Consider this a down payment on #50723. To recap, an `Applicability` enum was recently (#50204) added, to convey to Rustfix and other tools whether we think it's OK for them to blindly apply the suggestion, or whether to prompt a human for guidance (because the suggestion might contain placeholders that we can't infer, or because we think it has a sufficiently high probability of being wrong even though it's— presumably—right often enough to be worth emitting in the first place). When a suggestion is marked as `MaybeIncorrect`, we try to use comments to indicate precisely why (although there are a few places where we just say `// speculative` because the present author's subjective judgement balked at the idea that the suggestion has no false positives). The `run-rustfix` directive is opporunistically set on some relevant UI tests (and a couple tests that were in the `test/ui/suggestions` directory, even if the suggestions didn't originate in librustc or libsyntax). This is less trivial than it sounds, because a surprising number of test files aren't equipped to be tested as fixed even when they contain successfully fixable errors, because, e.g., there are more, not-directly-related errors after fixing. Some test files need an attribute or underscore to avoid unused warnings tripping up the "fixed code is still producing diagnostics" check despite the fixes being correct; this is an interesting contrast-to/inconsistency-with the behavior of UI tests (which secretly pass `-A unused`), a behavior which we probably ought to resolve one way or the other (filed issue #50926). A few suggestion labels are reworded (e.g., to avoid phrasing it as a question, which which is discouraged by the style guidelines listed in `.span_suggestion`'s doc-comment).
2018-05-20lexer: Fix span override for the first token in a stringVadim Petrochenkov-9/+12
2018-05-18rustc: Fix joint-ness of stringified token-streamsAlex Crichton-17/+40
This commit fixes `StringReader`'s parsing of tokens which have been stringified through procedural macros. Whether or not a token tree is joint is defined by span information, but when working with procedural macros these spans are often dummy and/or overridden which means that they end up considering all operators joint if they can! The fix here is to track the raw source span as opposed to the overridden span. With this information we can more accurately classify `Punct` structs as either joint or not. Closes #50700
2018-05-18Auto merge of #50307 - petrochenkov:keyhyg2, r=nikomatsakisbors-1/+1
Implement edition hygiene for keywords Determine "keywordness" of an identifier in its hygienic context. cc https://github.com/rust-lang/rust/pull/49611 I've resurrected `proc` as an Edition-2015-only keyword for testing purposes, but it should probably be buried again. EDIT: `proc` is removed again.
2018-05-18Auto merge of #50566 - nnethercote:bump, r=petrochenkovbors-65/+55
Streamline `StringReader::bump` These patches make `bump` smaller and nicer. They speed up most runs for coercions and tuple-stress by 1--3%.
2018-05-17Turn some functions from `token.rs` into methods on `Ident`Vadim Petrochenkov-1/+1
2018-05-15Represent lifetimes as two joint tokens in proc macrosVadim Petrochenkov-4/+1
2018-05-15proc_macro: Validate inputs to `Punct::new` and `Ident::new`Vadim Petrochenkov-0/+9
2018-05-14Remove `StringReader::col`.Nicholas Nethercote-7/+13
It only has a single use, within code handling indented block comments. We can replace that with the new `FileMap::col_pos()`, which computes the col position (BytePos instead of CharPos) based on the record of the last newline char (which we already record). This is actually an improvement, because `trim_whitespace_prefix_and_push_line()` was using `col`, which is a `CharPos`, as a slice index, which is a byte/char confusion.
2018-05-14Make `nextnextch()` more closely resemble `nextch()`.Nicholas Nethercote-8/+7
2018-05-13Remove `StringReader::terminator`.Nicholas Nethercote-20/+11
It's silly for a hot function like `bump()` to have such an expensive bounds check. This patch replaces terminator with `end_src_index`. Note that the `self.terminator` check in `is_eof()` wasn't necessary because of the way `StringReader` is initialized.
2018-05-13Rename some stuff in `StringReader`.Nicholas Nethercote-29/+24
- `source_text` becomes `src`, matching `FileMap::src`. - `byte_offset()` becomes `src_index()`, which makes it clearer that it's an index into `src`. (Likewise for variables containing `byte_offset` in their name.) This function also now returns a `usize` instead of a `BytePos`, because every callsite immediately converted the `BytePos` to a `usize`.
2018-05-13Tweak naming and ordering in `StringReader::bump()`.Nicholas Nethercote-16/+15
This patch removes the "old"/"new" names in favour of "foo"/"next_foo", which matches the field names. It also moves the setting of `self.{ch,pos,next_pos}` in the common case to the end, so that the meaning of "foo"/"next_foo" is consistent until the end.
2018-04-12Change the hashcounts in raw `Lit` variants from usize to u16.Nicholas Nethercote-3/+3
This reduces the size of `Token` from 32 bytes to 24 bytes on 64-bit platforms.
2018-04-12Deprecate the std_unicode crateSimon Sapin-1/+1
2018-04-10Auto merge of #49390 - Zoxc:sync-syntax, r=michaelwoeristerbors-5/+4
More thread-safety changes r? @michaelwoerister
2018-04-06Use `Span` instead of `SyntaxContext` in `Ident`Vadim Petrochenkov-1/+1
2018-03-28Make ParseSess thread-safeJohn Kåre Alsaker-5/+4
2018-03-18Move raw_identifiers check to the lexer.Lymia Aluysia-0/+4
2018-03-18Feature gate raw identifiers.Lymia Aluysia-0/+1
2018-03-18Initial implementation of RFC 2151, Raw IdentifiersLymia Aluysia-23/+46
2018-03-18Auto merge of #48917 - petrochenkov:import, r=oli-obkbors-1/+1
syntax: Make imports in AST closer to the source and cleanup their parsing This is a continuation of https://github.com/rust-lang/rust/pull/45846 in some sense.
2018-03-17Rename `Span::empty` to `Span::shrink_to_lo`, add `Span::shrink_to_hi`Vadim Petrochenkov-1/+1
2018-03-17syntax: Make `_` an identifierVadim Petrochenkov-10/+4
2018-03-15Use a single Lock for CodeMap.stable_id_to_filemap and CodeMap.filesJohn Kåre Alsaker-1/+1
2018-03-14Remove syntax and syntax_pos thread localsJohn Kåre Alsaker-116/+143
2018-03-08Move REGISTERED_DIAGNOSTICS to a ParseSess fieldJohn Kåre Alsaker-0/+3
2018-03-04Add note for unterminated raw string errorGuillaume Gomez-8/+25
2018-03-02Replace Rc with Lrc for shared dataJohn Kåre Alsaker-22/+20
2018-02-01Improve char escaping in lexer messagesRyan Cumming-12/+19
Currently ', " and \ are escaped as \', \" and \\ respectively. This leads to confusing messages such as `error: unknown start of token: \\` when encountering a single backslash. Fix by emitting printable ASCII characters directly. This will still escape \r, \n, \t and Unicode characters. Fixes #47902
2018-01-29Toggle span highlighting on `-Zteach`Esteban Küber-0/+1
2018-01-26Do not capture stderr in the compiler. Instead just panic silently for fatal ↵John Kåre Alsaker-35/+34
errors
2018-01-06wherein careful doc-decoration arithmetic proves quite the ICE-breakerZack M. Davis-1/+1
This `horizontal_trim` function strips the leading whitespace from doc-comments that have a left-asterisk-margin: /** * You know what I mean— * * comments like this! */ The index of the column of asterisks is `i`, and if trimming is deemed possible, we slice each line from `i+1` to the end of the line. But if, in particular, `i` was 0 _and_ there was an empty line (as in the example given in the reporting issue), we ended up panicking trying to slice an empty string from 0+1 (== 1). Let's tighten our check to say that we can't trim when `i` is even the same as the length of the line, not just when it's greater. (Any such cases would panic trying to slice `line` from `line.len()+1`.) Resolves #47197.
2017-12-19Implement non-mod.rs mod statementsTaylor Cramer-0/+1
2017-12-14When attempting to write str with single quote suggest double quotesEsteban Küber-1/+27
2017-12-14Use PathBuf instead of String where applicableOliver Schneider-3/+4
2017-12-07address commentsAgustin Chiappe Berrini-1/+1
2017-12-06and refactor to just move the checkingAgustin Chiappe Berrini-13/+1
2017-11-28Fix hygiene bug.Jeffrey Seyfried-3/+10
2017-11-03Display spans correctly when there are non-half-width charactersWonwoo Choi-0/+1
2017-10-20Add short message-formatGuillaume Gomez-1/+3
2017-10-13Fix typo in libsyntax/parse/lexer/unicode_chars.rskennytm-1/+1
` (U+0060) should be the "grave" accent, not "Greek" accent.
2017-09-22Add support for `..=` syntaxAlex Burka-0/+3
Add ..= to the parser Add ..= to libproc_macro Add ..= to ICH Highlight ..= in rustdoc Update impl Debug for RangeInclusive to ..= Replace `...` to `..=` in range docs Make the dotdoteq warning point to the ... Add warning for ... in expressions Updated more tests to the ..= syntax Updated even more tests to the ..= syntax Updated the inclusive_range entry in unstable book