about summary refs log tree commit diff
path: root/tests/ui/lexer
AgeCommit message (Collapse)AuthorLines
2025-06-03Add missing 2015 edition directivesLukas Wirth-4/+5
These tests specifically test 2015 edition behavior, so ensure that they can only be run with this edition
2025-04-03Use `cfg(false)` in UI testsclubby789-1/+1
2025-03-07Refactor `emitter` to better account for unicode chars when trimmingEsteban Küber-1/+1
Change the way that underline positions are calculated by delaying using the "visual" column position until the last possible moment, instead using the "file"/byte position in the file, and then calculating visual positioning as late as possible. This should make the underlines more resilient to non-1-width unicode chars. Unfortunately, as part of this change (which fixes some visual bugs) comes with the loss of some eager tab codepoint handling, but the output remains legible despite some minor regression on the "margin trimming" logic.
2025-02-14Trim suggestion parts to the subset that is purely additiveMichael Goulet-1/+1
2025-02-14Consider add-prefix replacements tooMichael Goulet-3/+2
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-36/+54
``` error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> $DIR/attempted-access-non-fatal.rs:7:15 | LL | let _ = 2.l; | ^ | help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix | LL - let _ = 2.l; LL + let _ = 2.0f64; | ```
2025-02-04Rename and Move some UI tests to more suitable subdirsDuskyElf-0/+7
2024-10-30Annotate `input` reference testsEric Huss-0/+1
2024-09-06Reserve prefix lifetimes tooMichael Goulet-0/+24
2024-07-18Be more accurate about calculating `display_col` from a `BytePos`Esteban Küber-2/+2
No longer track "zero-width" chars in `SourceMap`, read directly from the line when calculating the `display_col` of a `BytePos`. Move `char_width` to `rustc_span` and use it from the emitter. This change allows the following to properly align in terminals (depending on the font, the replaced control codepoints are rendered as 1 or 2 width, on my terminal they are rendered as 1, on VSCode text they are rendered as 2): ``` error: this file contains an unclosed delimiter --> $DIR/issue-68629.rs:5:17 | LL | ␜␟ts␀![{i | -- unclosed delimiter | | | unclosed delimiter LL | ␀␀ fn rݻoa>rݻm | ^ ```
2024-07-18Replace ASCII control chars with Unicode Control PicturesEsteban Küber-7/+7
``` error: bare CR not allowed in doc-comment --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:3:32 | LL | /// doc comment with bare CR: '␍' | ^ ```
2024-07-12Make parse error suggestions verbose and fix spansEsteban Küber-1/+6
Go over all structured parser suggestions and make them verbose style. When suggesting to add or remove delimiters, turn them into multiple suggestion parts.
2024-04-18Rollup merge of #123752 - estebank:emoji-prefix, r=wesleywiserJubilee-0/+22
Properly handle emojis as literal prefix in macros Do not accept the following ```rust macro_rules! lexes {($($_:tt)*) => {}} lexes!(🐛"foo"); ``` Before, invalid emoji identifiers were gated during parsing instead of lexing in all cases, but this didn't account for macro pre-expansion of literal prefixes. Fix #123696.
2024-04-10Properly handle emojis as literal prefix in macrosEsteban Küber-0/+22
Do not accept the following ```rust macro_rules! lexes {($($_:tt)*) => {}} lexes!(🐛"foo"); ``` Before, invalid emoji identifiers were gated during parsing instead of lexing in all cases, but this didn't account for macro expansion of literal prefixes. Fix #123696.
2024-04-07Fix invalid silencing of parsing errorEsteban Küber-2/+73
Given ```rust macro_rules! a { ( ) => { impl<'b> c for d { e::<f'g> } }; } ``` ensure an error is emitted. Fix #123079.
2024-03-17Silence redundant error on char literal that was meant to be a string in ↵Esteban Küber-14/+1
2021 edition
2024-03-17Extend test to trigger on 2015, 2018 and 2021 editionsEsteban Küber-8/+48
2024-03-17review comment: `str` -> string in messagesEsteban Küber-11/+11
2024-03-17Use shorter span for existing `'` -> `"` structured suggestionEsteban Küber-9/+9
2024-03-17Handle str literals written with `'` lexed as lifetimeEsteban Küber-0/+75
Given `'hello world'` and `'1 str', provide a structured suggestion for a valid string literal: ``` error[E0762]: unterminated character literal --> $DIR/lex-bad-str-literal-as-char-3.rs:2:26 | LL | println!('hello world'); | ^^^^ | help: if you meant to write a `str` literal, use double quotes | LL | println!("hello world"); | ~ ~ ``` ``` error[E0762]: unterminated character literal --> $DIR/lex-bad-str-literal-as-char-1.rs:2:20 | LL | println!('1 + 1'); | ^^^^ | help: if you meant to write a `str` literal, use double quotes | LL | println!("1 + 1"); | ~ ~ ``` Fix #119685.
2024-02-26separate messages for individual categoriesHTGAzureX1212.-2/+3
2024-02-16[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives许杰友 Jieyou Xu (Joe)-2/+2
2024-01-23address requested changesHTGAzureX1212.-2/+2
2024-01-23add list of characters to uncommon codepoints lintHTGAzureX1212.-1/+1
2023-11-24Show number in error message even for one errorNilstrieb-6/+6
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-07-29Update lexer emoji diagnostics to Unicode 15.0Charles Lew-21/+19
2023-06-10Use a better linkHankai Zhang-2/+2
2023-06-10Update links to Rust Reference page on literals in diagnosticHankai Zhang-2/+2
Instead of linking to the old Rust Reference site on static.rust-lang.org, link to the current website doc.rust-lang.org/stable/reference instead in diagnostic about incorrect literals.
2023-04-10Revert "Don't recover lifetimes/labels containing emojis as character literals"Michael Goulet-131/+0
Reverts PR #108031 Fixes (doesnt close until beta backported) #109746 This reverts commit e3f9db5fc319c6d8eee5d47d216ea6a426070c41. This reverts commit 98b82aedba3f3f581e89df54352914b27f42c6f7. This reverts commit 380fa264132ad481e73cbbf0f3a0feefd99a1d78.
2023-04-05Auto merge of #108905 - ferrocene:pa-compiletest-ignore, r=ehussbors-1/+0
Validate `ignore` and `only` compiletest directive, and add human-readable ignore reasons This PR adds strict validation for the `ignore` and `only` compiletest directives, failing if an unknown value is provided to them. Doing so uncovered 79 tests in `tests/ui` that had invalid directives, so this PR also fixes them. Finally, this PR adds human-readable ignore reasons when tests are ignored due to `ignore` or `only` directives, like *"only executed when the architecture is aarch64"* or *"ignored when the operative system is windows"*. This was the original reason why I started working on this PR and #108659, as we need both of them for Ferrocene. The PR is a draft because the code is extremely inefficient: it calls `rustc --print=cfg --target $target` for every rustc target (to gather the list of allowed ignore values), which on my system takes between 4s and 5s, and performs a lot of allocations of constant values. I'll fix both of them in the coming days. r? `@ehuss`
2023-04-03remove invalid ignore-prettyPietro Albini-1/+0
2023-04-02Move some UI tests into subdirectoriesjyn-0/+35
to avoid going over the existing limit now that the ui-fulldeps tests have been moved to ui.
2023-02-14Don't recover lifetimes/labels containing emojis as character literals许杰友 Jieyou Xu (Joe)-0/+131
Note that at the time of this commit, `unic-emoji-char` seems to have data tables only up to Unicode 5.0, but Unicode is already newer than this. A newer emoji such as `🥺` will not be recognized as an emoji but older emojis such as `🐱` will.
2023-01-11Move /src/test to /testsAlbert Larsan-0/+878