Skip to content

Validate source snippet when format input is raw string#152277

Merged
rust-bors[bot] merged 5 commits intorust-lang:mainfrom
gurry:114865-ice-format-args
May 3, 2026
Merged

Validate source snippet when format input is raw string#152277
rust-bors[bot] merged 5 commits intorust-lang:mainfrom
gurry:114865-ice-format-args

Conversation

@gurry
Copy link
Copy Markdown
Contributor

@gurry gurry commented Feb 7, 2026

View all comments

Fixes #114865

The issue occurred because the user's proc macro respanned the format arg to an unrelated multi-byte string and we ICE'd by landing in the middle of a multi-byte char.

This PR adds validation that prevents the parser from trying to walk such obviously wrong snippets. Such validation already existed for non-raw strings. This PR adds it for raw strings as well.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 7, 2026
@gurry gurry force-pushed the 114865-ice-format-args branch from 70647fa to 4483628 Compare February 7, 2026 09:59
@gurry gurry marked this pull request as ready for review February 7, 2026 12:56
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 7, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 7, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Feb 7, 2026

r? @TaKO8Ki

rustbot has assigned @TaKO8Ki.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 21 candidates
  • Random selection from 12 candidates

Copy link
Copy Markdown
Member

@TaKO8Ki TaKO8Ki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I found another related ICE while reviewing the PR, so if possible, could you take a look at fixing that as well?

The implementation might have a somewhat broader impact, so I’d like to review it more carefully on my side. Please give me a little more time.

View changes since this review

Comment thread tests/ui/proc-macro/ice-wrong-span-114865.rs Outdated
Comment thread compiler/rustc_parse_format/src/lib.rs Outdated
@gurry
Copy link
Copy Markdown
Contributor Author

gurry commented Feb 15, 2026

Thank you. I found another related ICE while reviewing the PR, so if possible, could you take a look at fixing that as well?

The implementation might have a somewhat broader impact, so I’d like to review it more carefully on my side. Please give me a little more time.

View changes since this review

No worries. Please take your time. I'll fix the second ICE in the meanwhile.

@gurry gurry force-pushed the 114865-ice-format-args branch from a1cee4e to 42a2960 Compare February 16, 2026 13:08
@gurry gurry force-pushed the 114865-ice-format-args branch from 42a2960 to 6b3d04e Compare February 16, 2026 13:11
@TaKO8Ki
Copy link
Copy Markdown
Member

TaKO8Ki commented Feb 26, 2026

@bors try jobs=x86_64-gnu

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Feb 26, 2026
Validate source snippet when format input is raw string


try-job: x86_64-gnu
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Feb 26, 2026

☀️ Try build successful (CI)
Build commit: 2546166 (254616605b508b115246302fd7e3fd0b12bf7af1, parent: 1ed488274bec5bf5cfe6bf7a1cc089abcc4ebd68)

@TaKO8Ki
Copy link
Copy Markdown
Member

TaKO8Ki commented Feb 26, 2026

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Feb 26, 2026
Validate source snippet when format input is raw string
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 26, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Feb 26, 2026

☀️ Try build successful (CI)
Build commit: 0421599 (04215991e86652a3338382526b1fbca9130d42c2, parent: 1ed488274bec5bf5cfe6bf7a1cc089abcc4ebd68)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (0421599): comparison URL.

Overall result: ❌ regressions - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.9% [2.9%, 2.9%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -2.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.5% [-3.9%, -1.2%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.5% [-3.9%, -1.2%] 2

Cycles

Results (primary -2.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.8% [-2.8%, -2.8%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.8% [-2.8%, -2.8%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 492.161s -> 479.296s (-2.61%)
Artifact size: 395.78 MiB -> 395.80 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 26, 2026
@gurry
Copy link
Copy Markdown
Contributor Author

gurry commented Apr 2, 2026

@TaKO8Ki Please have another look

@TaKO8Ki
Copy link
Copy Markdown
Member

TaKO8Ki commented Apr 17, 2026

Sorry, I completely overlooked this PR. Given my current review capacity, I’m going to reroll it. @rustbot reroll

@rustbot rustbot assigned chenyukang and unassigned TaKO8Ki Apr 17, 2026
Comment thread compiler/rustc_parse_format/src/lib.rs Outdated
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 19, 2026

⚠️ Warning ⚠️

@chenyukang
Copy link
Copy Markdown
Member

Thanks!
@bors r=chenyukang

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 2, 2026

📌 Commit 43c78ad has been approved by chenyukang

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 2, 2026
@JonathanBrouwer
Copy link
Copy Markdown
Contributor

@bors rollup
Perf is noise

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request May 2, 2026
…enyukang

Validate source snippet when format input is raw string

Fixes rust-lang#114865

The issue occurred because the user's proc macro respanned the format arg to an unrelated multi-byte string and we ICE'd by landing in the middle of a multi-byte char.

This PR adds validation that prevents the parser from trying to walk such obviously wrong snippets. Such validation already existed for non-raw strings. This PR adds it for raw strings as well.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request May 2, 2026
…enyukang

Validate source snippet when format input is raw string

Fixes rust-lang#114865

The issue occurred because the user's proc macro respanned the format arg to an unrelated multi-byte string and we ICE'd by landing in the middle of a multi-byte char.

This PR adds validation that prevents the parser from trying to walk such obviously wrong snippets. Such validation already existed for non-raw strings. This PR adds it for raw strings as well.
rust-bors Bot pushed a commit that referenced this pull request May 3, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - #152277 (Validate source snippet when format input is raw string)
 - #155940 (refactor rustc_on_unimplemented's filtering)
 - #156065 (Remove unused spans from AttributeKind)
 - #156079 (Move and rename the `clone-never.rs` test)
 - #156091 (change field `tools` on `AttributeParser` to hold `&'tcx RegisteredTools`)
@rust-bors

This comment has been minimized.

@rust-bors rust-bors Bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 3, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 3, 2026

☀️ Test successful - CI
Approved by: chenyukang
Duration: 3h 14m 51s
Pushing 44860d3 to main...

@rust-bors rust-bors Bot merged commit 44860d3 into rust-lang:main May 3, 2026
12 checks passed
@rustbot rustbot added this to the 1.97.0 milestone May 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing a3e96d8 (parent) -> 44860d3 (this PR)

Test differences

Show 4 test diffs

Stage 1

  • [ui] tests/ui/proc-macro/ice-wrong-span-114865.rs: [missing] -> pass (J0)

Stage 2

  • [ui] tests/ui/proc-macro/ice-wrong-span-114865.rs: [missing] -> pass (J1)

Additionally, 2 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 44860d3e9ef700cac0b4a61d924f41f46bf1b447 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. x86_64-gnu-debug: 1h 31m -> 2h 4m (+35.4%)
  2. i686-gnu-nopt-1: 1h 46m -> 2h 18m (+30.4%)
  3. dist-i686-linux: 1h 26m -> 1h 50m (+28.5%)
  4. dist-x86_64-apple: 1h 43m -> 2h 6m (+22.1%)
  5. dist-apple-various: 1h 29m -> 1h 47m (+20.3%)
  6. arm-android: 1h 44m -> 1h 26m (-16.6%)
  7. aarch64-apple: 2h 28m -> 2h 51m (+14.9%)
  8. x86_64-gnu-llvm-22-1: 1h 7m -> 1h 16m (+13.5%)
  9. dist-aarch64-apple: 1h 48m -> 2h (+11.9%)
  10. pr-check-2: 38m 1s -> 42m 29s (+11.8%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (44860d3): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

Results (secondary 5.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
5.2% [5.2%, 5.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results (secondary -0.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.7% [0.4%, 1.1%] 5
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.0% [-7.3%, -0.7%] 2
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 498.188s -> 495.993s (-0.44%)
Artifact size: 394.46 MiB -> 394.50 MiB (0.01%)

@gurry gurry deleted the 114865-ice-format-args branch May 4, 2026 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

6 participants