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 partialeq implementation for TryFromIntError type #53476

Merged
merged 1 commit into from
Aug 31, 2018

Conversation

GuillaumeGomez
Copy link
Member

Fixes #53458.

@rust-highfive
Copy link
Collaborator

r? @shepmaster

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 18, 2018
Copy link
Member

@shepmaster shepmaster left a comment

Choose a reason for hiding this comment

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

My thoughts...

  • I am a big fan of comparable error types for the reasons outlined in the issue.

  • This is unstable, so doesn't seem like a big risk

  • We are already deriving Copy which feels like more of a forwards-compatibility hazard than PartialEq.

  • But it's still a forwards-compatibility hazard, so I don't feel qualified approving.

fn main() {
let x: u32 = 125;
let y: Result<u8, TryFromIntError> = u8::try_from(x);
let _ = y == Ok(125);
Copy link
Member

Choose a reason for hiding this comment

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

Can't this just be y == Ok(125)?

@shepmaster
Copy link
Member

r? @KodrAus

@rust-highfive rust-highfive assigned KodrAus and unassigned shepmaster Aug 26, 2018
@@ -4248,7 +4248,7 @@ from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 }

/// The error type returned when a checked integral type conversion fails.
#[unstable(feature = "try_from", issue = "33417")]
#[derive(Debug, Copy, Clone)]
#[derive(Debug, Copy, Clone, PartialEq)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason not to go full Eq here since we should satisfy the trait's requirements?

Copy link
Member Author

Choose a reason for hiding this comment

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

None indeed. Adding it.

@GuillaumeGomez GuillaumeGomez force-pushed the try-from-int-error-partial-eq branch from 75cf431 to da4febd Compare August 28, 2018 18:40
@GuillaumeGomez
Copy link
Member Author

Updated.

@KodrAus
Copy link
Contributor

KodrAus commented Aug 29, 2018

So as far as I know this error type is only attempting to communicate a conversion from one integral type to another where the value is outside of its possible range so I think from a forwards-compatibility perspective we're ok.

Thanks, this looks good to me @GuillaumeGomez!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 29, 2018

📌 Commit da4febd has been approved by KodrAus

@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 Aug 29, 2018
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Aug 29, 2018
…artial-eq, r=KodrAus

Add partialeq implementation for TryFromIntError type

Fixes rust-lang#53458.
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Aug 29, 2018
…artial-eq, r=KodrAus

Add partialeq implementation for TryFromIntError type

Fixes rust-lang#53458.
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Aug 30, 2018
…artial-eq, r=KodrAus

Add partialeq implementation for TryFromIntError type

Fixes rust-lang#53458.
bors added a commit that referenced this pull request Aug 31, 2018
Rollup of 20 pull requests

Successful merges:

 - #51760 (Add another PartialEq example)
 - #53113 (Add example for Cow)
 - #53129 (remove `let x = baz` which was obscuring the real error)
 - #53389 (document effect of join on memory ordering)
 - #53472 (Use FxHash{Map,Set} instead of the default Hash{Map,Set} everywhere in rustc.)
 - #53476 (Add partialeq implementation for TryFromIntError type)
 - #53513 (Force-inline `shallow_resolve` at its hottest call site.)
 - #53655 (set applicability)
 - #53702 (Fix stabilisation version for macro_vis_matcher.)
 - #53727 (Do not suggest dereferencing in macro)
 - #53732 (save-analysis: Differentiate foreign functions and statics.)
 - #53740 (add llvm-readobj to llvm-tools-preview)
 - #53743 (fix a typo: taget_env -> target_env)
 - #53747 (Rustdoc fixes)
 - #53753 (expand keep-stage --help text)
 - #53756 (Fix typo in comment)
 - #53768 (move file-extension based .gitignore down to src/)
 - #53785 (Fix a comment in src/libcore/slice/mod.rs)
 - #53786 (Replace usages of 'bad_style' with 'nonstandard_style'.)
 - #53806 (Fix UI issues on Implementations on Foreign types)

Failed merges:

r? @ghost
@bors bors merged commit da4febd into rust-lang:master Aug 31, 2018
@GuillaumeGomez GuillaumeGomez deleted the try-from-int-error-partial-eq branch August 31, 2018 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants