Skip to content
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

Add From<{integer}> for f16/f128 impls #138363

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

beetrees
Copy link
Contributor

@beetrees beetrees commented Mar 11, 2025

This PR adds impl From<{bool,i8,u8}> for f16 and impl From<{bool,i8,u8,i16,u16,i32,u32}> for f128.

The From<{i64,u64}> for f128 impls are left commented out as adding them would allow using f128 on stable before it is stabilised like in the following example:

fn f<T: From<u64>>(x: T) -> T { x }

fn main() {
    let x = f(1.0); // the type of the literal is inferred to be `f128`
}

None of the impls added in this PR have this issue as they are all, at minimum, also implemented by f64.

This PR will need a crater run for the From<{i32,u32}> impls, as f64 is no longer the only float type to implement them (similar to the cause of #125198).

cc @bjoernager
r? @tgross35

Tracking issue: #116909

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Mar 11, 2025
@rust-log-analyzer

This comment has been minimized.

@beetrees beetrees force-pushed the f16-f128-integer-convert branch from 8767c41 to 7c07265 Compare March 11, 2025 19:00
@compiler-errors
Copy link
Member

compiler-errors commented Mar 11, 2025

Obligatory crater run since we've had trouble with f16/f128 stdlib impls in the past :)

edit: oh i just read that you also asked for a crater run; yep, agreed lol

@bors try

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 11, 2025
…=<try>

Add `From<{integer}>` for `f16`/`f128` impls

This PR adds `impl From<{bool,i8,u8}> for f16` and `impl From<{bool,i8,u8,i16,u16,i32,u32}> for f128`.

The `From<{i64,u64}> for f128` impls are left commented out as adding them would allow using `f128` on stable before it is stabilised like in the following example:
```rust
fn f<T: From<u64>>(x: T) -> T { x }

fn main() {
    let x = f(1.0); // the type of the literal is inferred to be `f128`
}
```
None of the impls added in this PR have this issue as they are all, at minimum, also implemented by `f64`.

This PR will need a crater run for the `From<{i32,u32}>` impls, as `f64` is no longer the only float type to implement them (similar to the cause of rust-lang#125198).

cc `@bjoernager`
r? `@tgross35`

Tracking issue: rust-lang#116909
@bors
Copy link
Contributor

bors commented Mar 11, 2025

⌛ Trying commit 7c07265 with merge 5e7498e...

@bors
Copy link
Contributor

bors commented Mar 11, 2025

☀️ Try build successful - checks-actions
Build commit: 5e7498e (5e7498e6740d105521420ac0ab146e2c7a21596d)

@tgross35
Copy link
Contributor

@craterbot check

@craterbot
Copy link
Collaborator

👌 Experiment pr-138363 created and queued.
🤖 Automatically detected try build 5e7498e
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 11, 2025
@tgross35
Copy link
Contributor

This LGTM assuming crater is okay, but somebody from libs-api will need to approve

r? @Amanieu

@rustbot rustbot assigned Amanieu and unassigned tgross35 Mar 11, 2025
@tgross35 tgross35 added F-f16_and_f128 `#![feature(f16)]`, `#![feature(f128)]` T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-f16_and_f128 `#![feature(f16)]`, `#![feature(f128)]` S-waiting-on-crater Status: Waiting on a crater run to be completed. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants