Skip to content

rustc recommends a compiler_builtin on stable, and not on nightly. #73666

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

Closed
b4skyx opened this issue Jun 23, 2020 · 2 comments
Closed

rustc recommends a compiler_builtin on stable, and not on nightly. #73666

b4skyx opened this issue Jun 23, 2020 · 2 comments
Labels
C-bug Category: This is a bug.

Comments

@b4skyx
Copy link

b4skyx commented Jun 23, 2020

While working on generic struct, I ran into the following error

20 |             val: T::max_value(),
   |                     ^^^^^^^^^ function or associated item not found in `T`
   |
   = help: items from traits can only be used if the type parameter is bounded by the trait
help: the following trait defines an item `max_value`, perhaps you need to restrict type parameter `T` with it:
   |
14 | impl<T: compiler_builtins::int::Int + Signed + Ord> Tree<T> {
   |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

To reproduce this using the minimal example, I ran the code

fn test<T>(a: T) -> T {
    a.max_value()
}

I expected this to fail building and not suggest me to use compiler_builtins as i'm on rustc stable,.

Instead, this happened:

2 |     T::max_value()
  |        ^^^^^^^^^ function or associated item not found in `T`
  |
  = help: items from traits can only be used if the type parameter is bounded by the trait
help: the following trait defines an item `max_value`, perhaps you need to restrict type parameter `T` with it:
  |
1 | fn test<T: compiler_builtins::int::Int>(a: T) -> T {
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

However when using nightly, it wouldn't suggest me compiler_builtins.

  |
2 |     T::max_value()
  |        ^^^^^^^^^ function or associated item not found in `T`

error: aborting due to previous error

Meta

rustc --version --verbose:

rustc 1.44.1 (c7087fe00 2020-06-17)
binary: rustc
commit-hash: c7087fe00d2ba919df1d813c040a5d47e43b0fe7
commit-date: 2020-06-17
host: x86_64-unknown-linux-gnu
release: 1.44.1
LLVM version: 9.0

rustc +nightly --version --verbose:

rustc 1.46.0-nightly (6bb3dbfc6 2020-06-22)
binary: rustc
commit-hash: 6bb3dbfc6c6d8992d08431f320ba296a0c2f7498
commit-date: 2020-06-22
host: x86_64-unknown-linux-gnu
release: 1.46.0-nightly
LLVM version: 10.0
@b4skyx b4skyx added the C-bug Category: This is a bug. label Jun 23, 2020
@tmiasko
Copy link
Contributor

tmiasko commented Jun 23, 2020

The difference arise from the fact that this was already fixed in #72759 (it shouldn't be suggested in either case since it is an implementation detail of compiler builtins).

@RalfJung
Copy link
Member

RalfJung commented Jun 24, 2020

Closing as already fixed. Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants