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

Open
wants to merge 5 commits into
base: master
from

Conversation

@SimonSapin
Copy link
Contributor

SimonSapin commented Feb 8, 2019

This is the plan proposed in #33417 (comment)

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Feb 8, 2019

r? @rkruppe

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

@SimonSapin

This comment has been minimized.

Copy link
Contributor Author

SimonSapin commented Feb 8, 2019

@rfcbot fcp merge

@rfcbot

This comment has been minimized.

Copy link

rfcbot commented Feb 8, 2019

Team member @SimonSapin has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Feb 8, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:04d689f0:start=1549634997151285181,finish=1549635146244413755,duration=149093128574
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
[00:58:49]     Checking compiler_builtins v0.1.5
[00:58:50]  Documenting alloc v0.0.0 (/checkout/src/liballoc)
[00:58:55]     Finished release [optimized] target(s) in 35.92s
[00:58:56]  Documenting core v0.0.0 (/checkout/src/libcore)
[00:59:12] warning: `[never]` cannot be resolved, ignoring it...
[00:59:12]     |
[00:59:12]     |
[00:59:12] 529 | /// This enum has the same role as [the `!` “never” type][never],
[00:59:12]     |
[00:59:12] note: lint level defined here
[00:59:12]    --> src/libcore/lib.rs:63:9
[00:59:12]     |
[00:59:12]     |
[00:59:12] 63  | #![warn(intra_doc_link_resolution_failure)]
[00:59:12]     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[00:59:12]     = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
[00:59:12] 
[00:59:12] warning: `[never]` cannot be resolved, ignoring it...
[00:59:12]     |
[00:59:12]     |
[00:59:12] 529 | /// This enum has the same role as [the `!` “never” type][never],
[00:59:12]     |
[00:59:12]     = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
[00:59:12] 
[00:59:18]     Finished release [optimized] target(s) in 23.19s
---
[00:59:24]     Checking rustc_tsan v0.0.0 (/checkout/src/librustc_tsan)
[00:59:24]     Checking rustc_msan v0.0.0 (/checkout/src/librustc_msan)
[00:59:24]     Checking rustc_asan v0.0.0 (/checkout/src/librustc_asan)
[00:59:24]  Documenting std v0.0.0 (/checkout/src/libstd)
[00:59:31] error: `[never]` cannot be resolved, ignoring it...
[00:59:31]     |
[00:59:31]     |
[00:59:31] 529 | /// This enum has the same role as [the `!` “never” type][never],
[00:59:31]     |
[00:59:31] note: lint level defined here
[00:59:31]    --> src/libstd/lib.rs:209:9
[00:59:31]     |
[00:59:31]     |
[00:59:31] 209 | #![deny(intra_doc_link_resolution_failure)]
[00:59:31]     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[00:59:31]     = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
[00:59:31] 
[00:59:31] error: `[never]` cannot be resolved, ignoring it...
[00:59:31]     |
[00:59:31]     |
[00:59:31] 529 | /// This enum has the same role as [the `!` “never” type][never],
[00:59:31]     |
[00:59:31]     = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
[00:59:31] 
[00:59:31] error: Could not document `std`.
[00:59:31] error: Could not document `std`.
[00:59:31] 
[00:59:31] Caused by:
[00:59:31]   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustdoc --crate-name std src/libstd/lib.rs --color always --target x86_64-unknown-linux-gnu -o /checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/doc --cfg 'feature="backtrace"' --cfg 'feature="backtrace-sys"' --cfg 'feature="compiler_builtins"' --cfg 'feature="compiler_builtins_c"' --cfg 'feature="default"' --cfg 'feature="panic-unwind"' --cfg 'feature="panic_unwind"' --markdown-css rust.css --markdown-no-toc --index-page /checkout/src/doc/index.md -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/release/deps --extern alloc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/liballoc-9e6c0311b71511c6.rmeta --extern backtrace_sys=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libbacktrace_sys-f13b165ed9b4dd57.rmeta --extern compiler_builtins=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libcompiler_builtins-d54fe968dea87029.rmeta --extern core=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libcore-84e5b9599b1b7754.rmeta --extern libc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/liblibc-a69fda92b07aedd5.rmeta --extern panic_abort=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libpanic_abort-349a3e5cce9f18ee.rmeta --extern panic_unwind=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libpanic_unwind-d7c48504ff1056b6.rmeta --extern rustc_demangle=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/librustc_demangle-20814bca47e9a554.rmeta --extern rustc_asan=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/librustc_asan-8bc4c4bf1d4ec8f0.rmeta --extern rustc_lsan=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/librustc_lsan-0814373332ff833c.rmeta --extern rustc_msan=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/librustc_msan-655667bc8a1522d0.rmeta --extern rustc_tsan=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/librustc_tsan-5756fbda854daecf.rmeta --extern unwind=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libunwind-5e31c590860d0940.rmeta` (exit code: 1)
[00:59:31] 
[00:59:31] 
[00:59:31] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "rustdoc" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-Z" "unstable-options" "-p" "std" "--" "--markdown-css" "rust.css" "--markdown-no-toc" "--index-page" "/checkout/src/doc/index.md"
[00:59:31] 
[00:59:31] 
[00:59:31] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap doc
[00:59:31] Build completed unsuccessfully in 0:06:12
[00:59:31] Build completed unsuccessfully in 0:06:12
[00:59:31] Makefile:18: recipe for target 'all' failed
[00:59:31] make: *** [all] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0e0d8a6d
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Fri Feb  8 15:12:07 UTC 2019
---
travis_time:end:0b378bfe:start=1549638728629181498,finish=1549638728633904520,duration=4723022
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0103429f
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:0a0f6eff
travis_time:start:0a0f6eff
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0503f1e2
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

/// With `Infallible` being an enum, this code is valid.
/// However when `Infallible` becomes an alias for the never type,
/// the two `impl`s will start to overlap
/// and therefore will be disallowed by the language’s trait coherence rules.

This comment has been minimized.

@SimonSapin

SimonSapin Feb 8, 2019

Author Contributor

I think we want to add something here that says “so, uh, don’t do this?”. Wording suggestions welcome.

This comment has been minimized.

@dwijnand

dwijnand Feb 13, 2019

Member

Is using one over the other preferable? Either way, maybe the answer to that should be in the docs.

@SimonSapin SimonSapin force-pushed the SimonSapin:tryfrom branch from 8caea7f to 1203b24 Feb 9, 2019

@alexcrichton
Copy link
Member

alexcrichton left a comment

r=me on the code changes, thanks @SimonSapin!

}
}

use fmt;

This comment has been minimized.

@alexcrichton

alexcrichton Feb 11, 2019

Member

Could this be moved up to the top of the file?

}

#[stable(feature = "convert_infallible", since = "1.34.0")]
impl Eq for Infallible {}

This comment has been minimized.

@alexcrichton

alexcrichton Feb 11, 2019

Member

With PartialEq and Eq perhaps the Ord-style traits could be included as well?

@Centril Centril added the relnotes label Feb 11, 2019

@scottmcm

This comment has been minimized.

Copy link
Member

scottmcm commented Feb 11, 2019

🎉 Huzzah! 🎉

Hopefully it sticks this time.

(Aside: #33417 (comment))

@rfcbot

This comment has been minimized.

Copy link

rfcbot commented Feb 12, 2019

🔔 This is now entering its final comment period, as per the review above. 🔔

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 12, 2019

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

@SimonSapin SimonSapin force-pushed the SimonSapin:tryfrom branch from 1203b24 to 8413a31 Feb 12, 2019

///
/// # Future compatibility
///
/// This enum has the same role as [the `!` “never” type][never],

This comment has been minimized.

@hellow554

hellow554 Feb 13, 2019

Contributor

Maybe using regular quotes instead? "never"

/// pub type Infallible = !;
/// ```
///
/// … and eventually deprecate `Infallible`.

This comment has been minimized.

@hellow554

hellow554 Feb 13, 2019

Contributor

Maybe using three plain dots

///
///
/// However there is one case where `!` syntax can be used
/// before `!` is stabilized as a full-fleged type: in the position of a function’s return type.

This comment has been minimized.

@hellow554
/// With `Infallible` being an enum, this code is valid.
/// However when `Infallible` becomes an alias for the never type,
/// the two `impl`s will start to overlap
/// and therefore will be disallowed by the language’s trait coherence rules.

This comment has been minimized.

@hellow554
@SimonSapin

This comment has been minimized.

Copy link
Contributor Author

SimonSapin commented Feb 13, 2019

@rust-lang/docs, any opinion on the use of non-ASCII v.s. ASCII punctuation in docs? I use the former out of habit.

@GuillaumeGomez

This comment has been minimized.

Copy link
Member

GuillaumeGomez commented Feb 13, 2019

We use it everywhere else in the doc so please use the ascii version of it. :)

@frewsxcv

This comment has been minimized.

Copy link
Member

frewsxcv commented Feb 13, 2019

To my knowledge, the docs team has no agreed upon preference for smart quotes or ASCII quotes, so either is fine! I personally use smart quotes.

@glaebhoerl glaebhoerl referenced this pull request Feb 13, 2019

Open

Tracking issue for TryFrom/TryInto traits #33417

1 of 3 tasks complete
///
///
/// However there is one case where `!` syntax can be used
/// before `!` is stabilized as a full-fleged type: in the position of a function’s return type.

This comment has been minimized.

@Nemo157

Nemo157 Feb 13, 2019

Contributor
Suggested change Beta
/// before `!` is stabilized as a full-fleged type: in the position of a function’s return type.
/// before `!` is stabilized as a full-fledged type: in the position of a function’s return type.

"full-fledged" still looks wrong to me as a NZer, but Merriam-Webster seems to imply that "fully-fledged" is only a British thing.

@jethrogb

This comment has been minimized.

Copy link
Contributor

jethrogb commented Feb 13, 2019

It seems to me stabilizing the never type is close (#57012/#58184). Is it really necessary to do this now or can we wait just a little bit longer?

@SimonSapin SimonSapin force-pushed the SimonSapin:tryfrom branch from 8413a31 to cea8d77 Feb 13, 2019

@SimonSapin

This comment has been minimized.

Copy link
Contributor Author

SimonSapin commented Feb 13, 2019

A couple weeks ago I was very hopeful that the never type would indeed be close. However since then another concern was added in #57012, and we didn’t find consensus on the related type inference fallback change.

TryFrom was overdue when we first tried to stabilize it a year ago. There was “not much needed to unblock this one” 18 months ago. I personally feel we’ve done enough of waiting just a little bit longer.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Feb 13, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:13c999e6:start=1550077800321475949,finish=1550077803247153220,duration=2925677271
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
[00:07:02]    Compiling rustc_errors v0.0.0 (/checkout/src/librustc_errors)
[00:08:07]    Compiling syntax_ext v0.0.0 (/checkout/src/libsyntax_ext)
[00:13:16]    Compiling rustc_mir v0.0.0 (/checkout/src/librustc_mir)
[00:13:16]    Compiling rustc_typeck v0.0.0 (/checkout/src/librustc_typeck)
[00:13:17] error[E0277]: the trait bound `!: std::convert::From<()>` is not satisfied
[00:13:17]    --> src/librustc_metadata/encoder.rs:105:9
[00:13:17]     |
[00:13:17] 105 |         self.emit_usize(seq.len)?;
[00:13:17]     |         ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<()>` is not implemented for `!`
[00:13:17]     = help: the following implementations were found:
[00:13:17]     = help: the following implementations were found:
[00:13:17]               <! as std::convert::From<std::convert::Infallible>>
[00:13:17]     = note: the trait is implemented for `()`. Possibly this error has been caused by changes to Rust's type-inference algorithm (see: https://github.com/rust-lang/rust/issues/48950 for more info). Consider whether you meant to use the type `()` here instead.
[00:13:17] 
[00:13:17] 
[00:13:17] error[E0277]: the trait bound `!: std::convert::From<()>` is not satisfied
[00:13:17]    --> src/librustc_metadata/encoder.rs:128:9
[00:13:17]     |
[00:13:17] 128 |         krate.encode(self)?;
[00:13:17]     |         ^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<()>` is not implemented for `!`
[00:13:17]     = help: the following implementations were found:
[00:13:17]     = help: the following implementations were found:
[00:13:17]               <! as std::convert::From<std::convert::Infallible>>
[00:13:17]     = note: the trait is implemented for `()`. Possibly this error has been caused by changes to Rust's type-inference algorithm (see: https://github.com/rust-lang/rust/issues/48950 for more info). Consider whether you meant to use the type `()` here instead.
[00:13:17] 
[00:13:17] 
[00:13:17] error[E0277]: the trait bound `!: std::convert::From<()>` is not satisfied
[00:13:17]    --> src/librustc_metadata/encoder.rs:163:9
[00:13:17]     |
[00:13:17] 163 |         TAG_VALID_SPAN.encode(self)?;
[00:13:17]     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<()>` is not implemented for `!`
[00:13:17]     = help: the following implementations were found:
[00:13:17]     = help: the following implementations were found:
[00:13:17]               <! as std::convert::From<std::convert::Infallible>>
[00:13:17]     = note: the trait is implemented for `()`. Possibly this error has been caused by changes to Rust's type-inference algorithm (see: https://github.com/rust-lang/rust/issues/48950 for more info). Consider whether you meant to use the type `()` here instead.
[00:13:17] 
[00:13:17] 
[00:13:17] error[E0277]: the trait bound `!: std::convert::From<()>` is not satisfied
[00:13:17]    --> src/librustc_metadata/encoder.rs:164:9
[00:13:17]     |
[00:13:17] 164 |         span.lo.encode(self)?;
[00:13:17]     |         ^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<()>` is not implemented for `!`
[00:13:17]     = help: the following implementations were found:
[00:13:17]     = help: the following implementations were found:
[00:13:17]               <! as std::convert::From<std::convert::Infallible>>
[00:13:17]     = note: the trait is implemented for `()`. Possibly this error has been caused by changes to Rust's type-inference algorithm (see: https://github.com/rust-lang/rust/issues/48950 for more info). Consider whether you meant to use the type `()` here instead.
[00:13:17] 
[00:13:18] error: aborting due to 4 previous errors
[00:13:18] 
[00:13:18] For more information about this error, try `rustc --explain E0277`.
[00:13:18] For more information about this error, try `rustc --explain E0277`.
[00:13:18] error: Could not compile `rustc_metadata`.
[00:13:18] warning: build failed, waiting for other jobs to finish...
[00:17:37] error: build failed
[00:17:37] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" "" "--manifest-path" "/checkout/src/rustc/Cargo.toml" "--message-format" "json"
[00:17:37] expected success, got: exit code: 101
[00:17:37] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap build
[00:17:37] Build completed unsuccessfully in 0:12:35
[00:17:37] Makefile:18: recipe for target 'all' failed
[00:17:37] make: *** [all] Error 1
69832 ./src/test
69060 ./obj/build/x86_64-unknown-linux-gnu/stage0-std
60756 ./obj/build/x86_64-unknown-linux-gnu/stage0/bin
58884 ./.git/modules/src/tools
---
travis_fold:end:after_failure.1
travis_fold:start:after_failure.2
travis_time:start:028b1ec2
$ ls -lat $HOME/Library/Logs/DiagnosticReports/
ls: cannot access '/home/travis/Librarers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:04593987
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

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: #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 SimonSapin force-pushed the SimonSapin:tryfrom branch from cea8d77 to b2cf9a0 Feb 13, 2019

@SimonSapin

This comment has been minimized.

Copy link
Contributor Author

SimonSapin commented Feb 13, 2019

I’ve added impl From<!> for Infallible. I initially also added the reverse but had to remove it because caused 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: https://github.com/rust-lang/rust/issues/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?

impl fmt::Display for TryFromIntError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
self.__description().fmt(fmt)
}
}

#[unstable(feature = "try_from", issue = "33417")]
#[stable(feature = "try_from", since = "1.34.0")]
impl From<Infallible> for TryFromIntError {

This comment has been minimized.

@Centril

Centril Feb 20, 2019

Contributor

@eddyb @arielb1 Can you double check that this impl isn't problematic re. coherence and adding From<!> for T later when type Infallible = !; (e.g. re. #57012 (comment))? -- I think it should be OK but I'd like to be more certain.

This comment has been minimized.

@SimonSapin

SimonSapin Feb 20, 2019

Author Contributor

Since this impl is in the standard library, we get to remove it at the same time as whenever we add From<!> for T. It’s only compat with impls in other crates that we need to be worried about.

@rfcbot

This comment has been minimized.

Copy link

rfcbot commented Feb 22, 2019

The final comment period, with a disposition to merge, as per the review above, is now complete.

@SimonSapin

This comment has been minimized.

Copy link
Contributor Author

SimonSapin commented Feb 22, 2019

r? @alexcrichton, I’ve added b2cf9a0 after you last approved the code changes.

@Centril

This comment has been minimized.

Copy link
Contributor

Centril commented on src/libcore/convert.rs in b2cf9a0 Feb 22, 2019

Not that this attribute has any effect, but... it isn't really stable :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment