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

Stabilize TryFrom and TryInto with a convert::Infallible empty enum #58302

Merged
merged 5 commits into from
Feb 25, 2019

Commits on Feb 13, 2019

  1. Configuration menu
    Copy the full SHA
    85f13f0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2f71203 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c80a8f5 View commit details
    Browse the repository at this point in the history
  4. Add impl From<!> for Infallible

    The reverse conversion unfortunately causes unexpected errors like:
    
    ```
    error[E0277]: the trait bound `!: std::convert::From<()>` is not satisfied
       --> src/librustc_metadata/encoder.rs:105:9
        |
    105 |         self.emit_usize(seq.len)?;
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<()>` is not implemented for `!`
        |
        = help: the following implementations were found:
                  <! as std::convert::From<std::convert::Infallible>>
        = note: the trait is implemented for `()`. Possibly this error has been caused by changes to Rust's type-inference algorithm (see: rust-lang#48950 for more info). Consider whether you meant to use the type `()` here instead.
        = note: required by `std::convert::From::from`
    ```
    
    I don’t understand why this error happens.
    If I’m reading the code correctly the return types of `emit_usize`
    and of the method that contains line 105 are both `Result<(), !>`,
    so the expansion of the `?` operator should involve `!: From<!>`,
    not `From<()>`.
    
    Is this a type inference bug?
    SimonSapin committed Feb 13, 2019
    1 Configuration menu
    Copy the full SHA
    b2cf9a0 View commit details
    Browse the repository at this point in the history

Commits on Feb 17, 2019

  1. Review comments

    SimonSapin committed Feb 17, 2019
    Configuration menu
    Copy the full SHA
    cf26754 View commit details
    Browse the repository at this point in the history