diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js
index 7d691f89015d7..47b3fd7a542bc 100644
--- a/src/librustdoc/html/static/js/main.js
+++ b/src/librustdoc/html/static/js/main.js
@@ -2252,42 +2252,3 @@ function preLoadCss(cssUrl) {
elem.addEventListener("click", showHideCodeExampleButtons);
});
}());
-
-
-// Workaround for browser-specific bugs when copying code snippets.
-//
-// * In Firefox, copying text that includes elements with `user-select: none`
-// inserts extra blank lines.
-// - Firefox issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1273836
-// - Rust issue: https://github.com/rust-lang/rust/issues/141464
-//
-// * In Chromium-based browsers, `document.getSelection()` includes elements
-// with `user-select: none`, causing unwanted line numbers to be copied.
-// - Chromium issue: https://issues.chromium.org/issues/446539520
-// - Rust issue: https://github.com/rust-lang/rust/issues/146816
-(function() {
- document.body.addEventListener("copy", event => {
- let target = nonnull(event.target);
- let isInsideCode = false;
- while (target && target !== document.body) {
- // @ts-expect-error
- if (target.tagName === "CODE") {
- isInsideCode = true;
- break;
- }
- // @ts-expect-error
- target = target.parentElement;
- }
- if (!isInsideCode) {
- return;
- }
- const selection = nonnull(document.getSelection());
- const text = Array.from({ length: selection.rangeCount }, (_, i) => {
- const fragment = selection.getRangeAt(i).cloneContents();
- fragment.querySelectorAll("[data-nosnippet]").forEach(el => el.remove());
- return fragment.textContent;
- }).join("");
- nonnull(event.clipboardData).setData("text/plain", text);
- event.preventDefault();
- });
-}());