Skip to content

Constify Try, From, TryFrom and relevant traits #143768

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 4 commits into
base: master
Choose a base branch
from

Conversation

Randl
Copy link
Contributor

@Randl Randl commented Jul 11, 2025

No description provided.

@rustbot
Copy link
Collaborator

rustbot commented Jul 11, 2025

r? @davidtwco

rustbot has assigned @davidtwco.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 11, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-19-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
failures:

---- [ui] tests/ui/consts/const-try.rs stdout ----

thread '[ui] tests/ui/consts/const-try.rs' panicked at src/tools/compiletest/src/runtest.rs:1463:33:
failed to exec `cd "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/consts/const-try" && LD_LIBRARY_PATH="/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-unknown-linux-gnu/lib:/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/consts/const-try/auxiliary:/checkout/obj/build/aarch64-unknown-linux-gnu/bootstrap-tools/aarch64-unknown-linux-gnu/release/deps" RUSTC="/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" RUST_TEST_THREADS="4" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/consts/const-try/a"`: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }


failures:
    [ui] tests/ui/consts/const-try.rs

@Randl
Copy link
Contributor Author

Randl commented Jul 11, 2025

I can reproduce the fail locally but I do not understand why it happens and how it is related to the changes.

@bors
Copy link
Collaborator

bors commented Jul 13, 2025

☔ The latest upstream changes (presumably #143888) made this pull request unmergeable. Please resolve the merge conflicts.

@@ -1,11 +1,11 @@
// The `?` operator is still not const-evaluatable because it calls `From::from` on the error
// variant.
//@ run-pass
Copy link
Contributor

Choose a reason for hiding this comment

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

This should not be run-pass, it doesn't have anything in its main function. It could be check-pass, but you'll still need more feature gates to make it compile

where
T: Clone,
T: ~const Clone + ~const Destruct,
Copy link
Contributor

Choose a reason for hiding this comment

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

~const Destruct is a where bound on the clone_from method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I put

fn clone_from(&mut self, source: &Self)
where T: ~const Destruct

instead, I get

error[E0276]: impl has stricter requirements than trait
    --> library/core/src/option.rs:2161:55
     |
2161 |       fn clone_from(&mut self, source: &Self) where  T: ~const Destruct {
     |                                                         ^^^^^^^^^^^^^^^ impl has extra requirement `T: [const] Destruct`
     |
    ::: library/core/src/clone.rs:213:5
     |
213  | /     fn clone_from(&mut self, source: &Self)
214  | |     where
215  | |         Self: ~const Destruct,
     | |______________________________- definition of `clone_from` from trait

@@ -198,7 +198,8 @@ impl Error for TryFromSliceError {
}

#[stable(feature = "try_from_slice_error", since = "1.36.0")]
impl From<Infallible> for TryFromSliceError {
#[rustc_const_unstable(feature = "const_trait_impl", issue = "67792")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#[rustc_const_unstable(feature = "const_trait_impl", issue = "67792")]
#[rustc_const_unstable(feature = "const_try", issue = "74935")]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I put everything in this PR under that feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. T-libs Relevant to the library 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