Skip to content

Conversation

@chenyukang
Copy link
Member

@chenyukang chenyukang commented Nov 9, 2025

Fixes #148732

There are two issues in this function:

  1. the original issue is caused by a typo error, which is fixed in the first commit
  2. another different ice(Patch span 7..7 is beyond the end of buffer 0) will be reported after fixing the first one, is caused by spans cross file boundaries due to macro expansion. It is fixed in the second commit.

r? @nnethercote

edited: also fixes #148684, added a new testcase for it in the last commit.

@rustbot
Copy link
Collaborator

rustbot commented Nov 9, 2025

rustc_errors::annotate_snippet_emitter_writer was changed

cc @Muscraft

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 9, 2025
Comment on lines +1 to +3
WARN rustc_errors::emitter Invalid span $SRC_DIR/std/src/macros.rs:LL:COL (#4), error=SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "$SRC_DIR/std/src/macros.rs" }) }
WARN rustc_errors::emitter Invalid span $SRC_DIR/std/src/macros.rs:LL:COL (#4), error=SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "$SRC_DIR/std/src/macros.rs" }) }
WARN rustc_errors::emitter Invalid span $SRC_DIR/std/src/macros.rs:LL:COL (#4), error=SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "$SRC_DIR/std/src/macros.rs" }) }
Copy link
Member

Choose a reason for hiding this comment

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

I have worries that this will not pass aarch64-msvc-1 the same way it was in my PR

cc: #general > Windows path normalization in tests

Copy link
Member Author

Choose a reason for hiding this comment

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

ah, it do have the same issue.

Copy link
Member Author

@chenyukang chenyukang Nov 10, 2025

Choose a reason for hiding this comment

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

so, I read the discussion on zulip, seems there is another standalone bug. so is it a temprary way we skip Windows for this testcase(and add it back after that bug is fixed)?

@Kivooeo
Copy link
Member

Kivooeo commented Nov 9, 2025

@bors try jobs=aarch64-msvc-1

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Nov 9, 2025
Fix ICE caused by invalid spans for shrink_file

try-job: aarch64-msvc-1
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Nov 9, 2025

💔 Test for eca91bd failed: CI. Failed jobs:

let hi_byte = spans.iter().map(|s| s.hi()).max()?;
let hi_loc = sm.lookup_char_pos(hi_byte);

if lo_loc.file.name != hi_loc.file.name {
Copy link
Member

@Muscraft Muscraft Nov 9, 2025

Choose a reason for hiding this comment

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

Suggested change
if lo_loc.file.name != hi_loc.file.name {
if lo_loc.file.stable_id != hi_loc.file.stable_id {

Using the stable_id avoids issues with file name collisions when multiple versions of the same crate are present in the dependency graph. In theory, collect_annotations should be ensuring that the stable_ids match but it would be better to have it checked in both places.

Copy link
Member Author

@chenyukang chenyukang Nov 10, 2025

Choose a reason for hiding this comment

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

I found a few other places to use file.name to cmp, maybe we can do a cleanup in another PR?

Copy link
Member

Choose a reason for hiding this comment

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

Doing cleanup for the other places in another PR makes sense. I can open a PR for that in the next few days if you'd like.

Copy link
Member Author

Choose a reason for hiding this comment

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

I just have a check by the way, and can fire a PR later.

@nnethercote
Copy link
Contributor

r=me once the comments are addressed.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 9, 2025
@chenyukang chenyukang force-pushed the yukang-fix-ice-148732 branch from 7262408 to 725b213 Compare November 10, 2025 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE assertion failed: line_index < lines.len() ICE line_index < lines.len()

6 participants