Skip to content

Only copy visible content in clipboard in source code pages#158137

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
GuillaumeGomez:copy-source-code
Jun 20, 2026
Merged

Only copy visible content in clipboard in source code pages#158137
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
GuillaumeGomez:copy-source-code

Conversation

@GuillaumeGomez

@GuillaumeGomez GuillaumeGomez commented Jun 19, 2026

Copy link
Copy Markdown
Member

You can see this bug but enabling the --generate-macro-expansion rustdoc option. When selecting text which contains a macro expansion, it'll copy all the code, both displayed and hidden. To reproduce it, take a look here.

This PR fixes it.

I'm currently adding the missing bits in browser-ui-test to be able to add a GUI regression test for it (selecting text and doing "ctrl-c").

The code I removed was added to fix both #146816 and #142354. However, I couldn't reproduce the bug in firefox 152 and in chromium 149. So instead of trying to handle more corner-cases, it's better to just remove the whole code. :)

r? @Urgau

@rustbot

rustbot commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in HTML/CSS/JS.

cc @lolbinarycat

@rustbot rustbot added A-rustdoc-js Area: Rustdoc's JS front-end S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 19, 2026
@rustbot rustbot added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Jun 19, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@Urgau

Urgau commented Jun 19, 2026

Copy link
Copy Markdown
Member

However, I couldn't reproduce the bug in firefox 152 and in chromium 149

I'm very surprised you couldn't reproduce it, Ralf and I were able to reproduce it just a few months ago. Ralf even commented on the Firefox issue.

But indeed, seems like the bug is fixed, for some reproduction at least.

I will check if I can still reproduce on our GHA Logs viewer, where we have had a similar workaround.

@Urgau

Urgau commented Jun 19, 2026

Copy link
Copy Markdown
Member

I will check if I can still reproduce on our GHA Logs viewer, where we have had a similar workaround.

The bug still reproduce on triagebot. Although now that I look more at it, it might not be the same.

Details
             at /rustc/0417c25868d6dfbd1c291dfeae950504faa6f790/library/core/src/ops/function.rs:250:5
	  14: std::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()>
	             at /rustc/0417c25868d6dfbd1c291dfeae950504faa6f790/library/std/src/sys/backtrace.rs:166:18
	  15: std::rt::lang_start::<()>::{closure#0}
	             at /rustc/0417c25868d6dfbd1c291dfeae950504faa6f790/library/std/src/rt.rs:206:18
	  16: <&dyn core::ops::function::Fn<(), Output = i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe as core::ops::function::FnOnce<()>>::call_once
	             at /rustc/0417c25868d6dfbd1c291dfeae950504faa6f790/library/core/src/ops/function.rs:287:21
	  17: std::panicking::catch_unwind::do_call::<&dyn core::ops::function::Fn<(), Output = i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe, i32>

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

Dark magic.

@Urgau

Urgau commented Jun 19, 2026

Copy link
Copy Markdown
Member

I take it back, I wasn't testing the right thing. I (locally) removed the workaround on the timestamps (data-pseudo-content) and added the user-select: none and it also doesn't reproduce anymore.

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

Dark magic intensifies.

@Urgau

Urgau commented Jun 20, 2026

Copy link
Copy Markdown
Member

Alright, I just spend a bunch of time on BrowserStack Live feature testing various configurations (old docs, 1.90 and this PR) with different versions...

The bottom line is that the both issues from Firefox and Chrome do not reproduce anymore on the latest version (Firefox 151 and Chrome 149).

The Chrome issue seems to have been fixed in Chrome 144, while the Firefox issue seems to have been fixed before Firefox 140.

As for the issue reported here, I can also confirm it is fixed by this PR.

I created a gist with the tests I did.

@Urgau Urgau left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Glad to see this ugly workaround being removed.

View changes since this review

@Urgau

Urgau commented Jun 20, 2026

Copy link
Copy Markdown
Member

@bors r+ rollup

@rust-bors

rust-bors Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

📌 Commit ef8c9ed has been approved by Urgau

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 Jun 20, 2026
@rust-bors

rust-bors Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

rust-bors Bot pushed a commit that referenced this pull request Jun 20, 2026
Only copy visible content in clipboard in source code pages

You can see this bug but enabling the `--generate-macro-expansion` rustdoc option. When selecting text which contains a macro expansion, it'll copy all the code, both displayed and hidden. To reproduce it, take a look [here](https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_middle/hir/mod.rs.html#26-27).

This PR fixes it.

I'm currently adding the missing bits in `browser-ui-test` to be able to add a GUI regression test for it (selecting text and doing "ctrl-c").

The code I removed was added to fix both #146816 and #142354. However, I couldn't reproduce the bug in firefox 152 and in chromium 149. So instead of trying to handle more corner-cases, it's better to just remove the whole code. :) 

r? @Urgau
@JonathanBrouwer

Copy link
Copy Markdown
Contributor

@bors yield
Scheduling

@rust-bors

rust-bors Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Auto build was cancelled. Cancelled workflows:

The next pull request likely to be tested is #158164.

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 20, 2026
…=Urgau

Only copy visible content in clipboard in source code pages

You can see this bug but enabling the `--generate-macro-expansion` rustdoc option. When selecting text which contains a macro expansion, it'll copy all the code, both displayed and hidden. To reproduce it, take a look [here](https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_middle/hir/mod.rs.html#26-27).

This PR fixes it.

I'm currently adding the missing bits in `browser-ui-test` to be able to add a GUI regression test for it (selecting text and doing "ctrl-c").

The code I removed was added to fix both rust-lang#146816 and rust-lang#142354. However, I couldn't reproduce the bug in firefox 152 and in chromium 149. So instead of trying to handle more corner-cases, it's better to just remove the whole code. :)

r? @Urgau
rust-bors Bot pushed a commit that referenced this pull request Jun 20, 2026
…uwer

Rollup of 3 pull requests

Successful merges:

 - #158137 (Only copy visible content in clipboard in source code pages)
 - #158141 ([AArch64] FEAT_SVE implies FEAT_FP16)
 - #158177 (rustc-dev-guide subtree update)
@rust-bors
rust-bors Bot merged commit f58d3e2 into rust-lang:main Jun 20, 2026
13 of 14 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 20, 2026
rust-timer added a commit that referenced this pull request Jun 20, 2026
Rollup merge of #158137 - GuillaumeGomez:copy-source-code, r=Urgau

Only copy visible content in clipboard in source code pages

You can see this bug but enabling the `--generate-macro-expansion` rustdoc option. When selecting text which contains a macro expansion, it'll copy all the code, both displayed and hidden. To reproduce it, take a look [here](https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_middle/hir/mod.rs.html#26-27).

This PR fixes it.

I'm currently adding the missing bits in `browser-ui-test` to be able to add a GUI regression test for it (selecting text and doing "ctrl-c").

The code I removed was added to fix both #146816 and #142354. However, I couldn't reproduce the bug in firefox 152 and in chromium 149. So instead of trying to handle more corner-cases, it's better to just remove the whole code. :)

r? @Urgau
@GuillaumeGomez
GuillaumeGomez deleted the copy-source-code branch June 21, 2026 12:49
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Jun 29, 2026
…uwer

Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#158137 (Only copy visible content in clipboard in source code pages)
 - rust-lang/rust#158141 ([AArch64] FEAT_SVE implies FEAT_FP16)
 - rust-lang/rust#158177 (rustc-dev-guide subtree update)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rustdoc-js Area: Rustdoc's JS front-end S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants