Skip to content

Commit

Permalink
Auto merge of rust-lang#128165 - saethlin:optimize-clone-shims, r=com…
Browse files Browse the repository at this point in the history
…piler-errors

Let InstCombine remove Clone shims inside Clone shims

The Clone shims that we generate tend to recurse into other Clone shims, which gets very silly very quickly. Here's our current state: https://godbolt.org/z/E69YeY8eq

So I've added InstSimplify to the shims optimization passes, and improved `is_trivially_pure_clone_copy` so that it can delete those calls inside the shim. This makes the shim way smaller because most of its size is the required ceremony for unwinding.

This change also completely breaks the UI test added for rust-lang#104870. With this PR, that program ICEs in MIR type checking because `is_trivially_pure_clone_copy` and the trait solver disagree on whether `*mut u8` is `Copy`. And adding the requisite `Copy` impl to make them agree makes the test not generate any diagnostics. Considering that I spent most of my time on this PR fixing `#![no_core]` tests, I would prefer to just delete this one. The maintenance burden of `#![no_core]` is uniquely high because when they break they tend to break in very confusing ways.

try-job: x86_64-mingw
  • Loading branch information
bors committed Jul 26, 2024
2 parents a152820 + 92c0ad7 commit 22ce603
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rtstartup/rsbegin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ trait Copy {}
#[lang = "freeze"]
auto trait Freeze {}

impl<T: ?Sized> Copy for *mut T {}

#[lang = "drop_in_place"]
#[inline]
#[allow(unconditional_recursion)]
Expand Down
2 changes: 2 additions & 0 deletions rtstartup/rsend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ trait Copy {}
#[lang = "freeze"]
auto trait Freeze {}

impl<T: ?Sized> Copy for *mut T {}

#[lang = "drop_in_place"]
#[inline]
#[allow(unconditional_recursion)]
Expand Down

0 comments on commit 22ce603

Please sign in to comment.