Skip to content

tests/ui: A New Order [23/N] #143298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

tests/ui: A New Order [23/N] #143298

wants to merge 2 commits into from

Conversation

Kivooeo
Copy link
Contributor

@Kivooeo Kivooeo commented Jul 1, 2025

Note

Intermediate commits are intended to help review, but will be squashed prior to merge.

Some tests/ui/ housekeeping, to trim down number of tests directly under tests/ui/. Part of #133895.

r? @tgross35

@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 Jul 1, 2025
@rust-log-analyzer

This comment has been minimized.

//! This test checks that expressions like `0 << b` don't accidentally
//! modify the variable `b` due to codegen issues with virtual registers.
//!
//! Regression test for <https://github.com/rust-lang/rust/issues/152>.
Copy link
Contributor

Choose a reason for hiding this comment

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

Wow, old issue! That's only two months after https://www.github.com/rust-lang/rust/issues/1

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

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

LGTM, please squash

@tgross35
Copy link
Contributor

tgross35 commented Jul 4, 2025

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jul 4, 2025

📌 Commit 626521d has been approved by tgross35

It is now in the queue for this repository.

@bors bors 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 Jul 4, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 4, 2025
`tests/ui`: A New Order [23/N]

> [!NOTE]
>
> Intermediate commits are intended to help review, but will be squashed prior to merge.

Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang#133895.

r? `@tgross35`
bors added a commit that referenced this pull request Jul 4, 2025
Rollup of 9 pull requests

Successful merges:

 - #141532 (std: sys: net: uefi: tcp4: Implement write)
 - #143085 (Port `#[non_exhaustive]` to the new attribute parsing infrastructure)
 - #143298 (`tests/ui`: A New Order [23/N])
 - #143372 (Remove names_imported_by_glob_use query.)
 - #143386 (Assign dependency bump PRs to me)
 - #143406 (Remove some unnecessary `unsafe` in VecCache)
 - #143408 (mbe: Gracefully handle macro rules that end after `=>`)
 - #143414 (remove special-casing of boxes from match exhaustiveness/usefulness analysis)
 - #143444 (clean up GVN TypeId test)

r? `@ghost`
`@rustbot` modify labels: rollup
@matthiaskrgr
Copy link
Member

@bors r-
#143454 (comment)

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 4, 2025
}
assert_eq!(8, b);
Copy link
Contributor

Choose a reason for hiding this comment

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

Check size_of::<usize>() rather than a constant, this failed on 32bit.

Also you can update the above std::mem::size_of -> size_of since it's now in the prelude.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

uhm, do you mean like this?

pub fn main() {
    let mut b: usize = 1;
    while b < size_of::<usize>() {
        // This shift operation should not mutate `b`
        let _ = 0_usize << b;
        b <<= 1;
    }
    assert_eq!(size_of::<usize>(), b);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

You can test 32-bit behavior on the playground by replacing usize with u32 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah i know that usize's size is different on different platforms, but I wonder about test above, is that correct now? the reason im asking and not just run ./x test is because it will took 10 minutes and all resoures of my machince which im not ready to give it rn

Copy link
Contributor

Choose a reason for hiding this comment

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

All I was planning to do to validate is put it in the playground anyway, it indeed looks correct https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=3aaf2f28b9cb4e4e60d14ae7624df83c

Noticing one other thing though; I think it might important that we observe the intermediate value so it can't get optimized out. println was doing this before but got deleted here, could you add std::hint::black_box(b); at the end of the while loop?

Copy link
Contributor Author

@Kivooeo Kivooeo Jul 4, 2025

Choose a reason for hiding this comment

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

i dont think that compiler can optimize this loop out, also i could miss understood you, i've added black_box to end of each iteration, and not after the while itself, not sure which one you exactly meant, but both should work fine i guess

@Kivooeo
Copy link
Contributor Author

Kivooeo commented Jul 4, 2025

hm, could this test be platform dependent? im not sure exactly what could cause this but when i was write this assert ive checked it and it was worked fine (its still do work fine in playground tho and CI passed, this is weird)

https://play.rust-lang.org/?version=stable&mode=release&edition=2024&gist=d5c825b667ddbdcfd48c031dcdd0798a

Ah, ok, now i see the answer above

@tgross35
Copy link
Contributor

tgross35 commented Jul 4, 2025

Might as well
@bors2 try jobs=dist-i586-gnu-i586-i686-musl

@rust-bors
Copy link

rust-bors bot commented Jul 4, 2025

⌛ Trying commit 4d4c3e2 with merge 71ca6be

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jul 4, 2025
`tests/ui`: A New Order [23/N]

<!-- homu-ignore:start -->
<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r? <reviewer name>
-->
<!-- homu-ignore:end -->

> [!NOTE]
>
> Intermediate commits are intended to help review, but will be squashed prior to merge.

Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of #133895.

r? `@tgross35`
try-job: dist-i586-gnu-i586-i686-musl
@Kivooeo
Copy link
Contributor Author

Kivooeo commented Jul 4, 2025

not sure if this needed becuase we made it dependable and not hardcoded 8, but let's see

also not sure if i should force push tidy fix now or later, because im not sure what will happen with bors try

@Kivooeo
Copy link
Contributor Author

Kivooeo commented Jul 4, 2025

fixed tidy, maybe need bors try once again

@rust-bors
Copy link

rust-bors bot commented Jul 5, 2025

☀️ Try build successful (CI)
Build commit: 71ca6be (71ca6be428c123c513694880a2b3b612510b964d, parent: e3843659e9f65f589d184d1221ac6149d5fa07b5)

@Kivooeo
Copy link
Contributor Author

Kivooeo commented Jul 5, 2025

yeah, safe to r+

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.

6 participants