-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Tracking issue for future-incompatibility lint unstable_name_collisions
#48919
Comments
…ust-lang/rust#48919. Additionally, apply rustfmt changes.
…ust-lang/rust#48919. Additionally, apply rustfmt changes.
…ust-lang/rust#48919. Additionally, apply rustfmt changes.
…ust-lang/rust#48919. Additionally, apply rustfmt changes.
…ust-lang/rust#48919. Additionally, apply rustfmt changes.
…ust-lang/rust#48919. Additionally, apply rustfmt changes.
…ust-lang/rust#48919. Additionally, apply rustfmt changes.
…ust-lang/rust#48919. Additionally, apply rustfmt changes.
Tracking issue: rust-lang/rust#48919
Tracking issue: rust-lang/rust#48919
Tracking issue: rust-lang/rust#48919
In the case of |
@infinity0 |
Given that the lint definition itself says: // Note: this item represents future incompatibility of all unstable functions in the
// standard library, and thus should never be removed or changed to an error. it sort of feels like having a tracking issue is somewhat misleading... Should this issue be closed, or is it expected that this issue will instead be permanently open? |
`int_bits_const` feature [1] adds `i32::BITS`, etc. We already have `BitInteger` trait, which has `BitInteger::BITS`, and using it triggers `unstable_name_collision` compatibility lint [2] unless `int_bits_const` is explicitly enabled, gets stabilized or gets rejected and removed from the compiler. [1]: rust-lang/rust#76492 [2]: rust-lang/rust#48919
`int_bits_const` feature [1] adds `i32::BITS`, etc. We already have `BitInteger` trait, which has `BitInteger::BITS`, and using it triggers `unstable_name_collision` compatibility lint [2] unless `int_bits_const` is explicitly enabled, gets stabilized or gets rejected and removed from the compiler. [1]: rust-lang/rust#76492 [2]: rust-lang/rust#48919
`int_bits_const` feature [1] adds `i32::BITS`, etc. We already have `BitInteger` trait, which has `BitInteger::BITS`, and using it triggers `unstable_name_collision` compatibility lint [2] unless `int_bits_const` is explicitly enabled, gets stabilized or gets rejected and removed from the compiler. [1]: rust-lang/rust#76492 [2]: rust-lang/rust#48919
Update `compiler_builtins` to 0.1.36 So, the libc build with cargo's `build-std` feature emits a lot of warnings like: ``` warning: a method with this name may be added to the standard library in the future --> /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.35/src/int/udiv.rs:98:23 | 98 | q = n << (<$ty>::BITS - sr); | ^^^^^^^^^^^ ... 268 | udivmod_inner!(n, d, rem, u128) | ------------------------------- in this macro invocation | = warning: once this method is added to the standard library, the ambiguity may cause an error or change in behavior! = note: for more information, see issue rust-lang#48919 <rust-lang/issues/48919> = help: call with fully qualified syntax `Int::BITS(...)` to keep using the current method = help: add `#![feature(int_bits_const)]` to the crate attributes to enable `num::<impl u128>::BITS` = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) ``` (You can find the full log in https://github.com/rust-lang/libc/runs/1283695796?check_suite_focus=true for example.) 0.1.36 contains rust-lang/compiler-builtins#332 so this version should remove this warning. cc rust-lang/libc#1942
Update `compiler_builtins` to 0.1.36 So, the libc build with cargo's `build-std` feature emits a lot of warnings like: ``` warning: a method with this name may be added to the standard library in the future --> /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.35/src/int/udiv.rs:98:23 | 98 | q = n << (<$ty>::BITS - sr); | ^^^^^^^^^^^ ... 268 | udivmod_inner!(n, d, rem, u128) | ------------------------------- in this macro invocation | = warning: once this method is added to the standard library, the ambiguity may cause an error or change in behavior! = note: for more information, see issue rust-lang#48919 <rust-lang/issues/48919> = help: call with fully qualified syntax `Int::BITS(...)` to keep using the current method = help: add `#![feature(int_bits_const)]` to the crate attributes to enable `num::<impl u128>::BITS` = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) ``` (You can find the full log in https://github.com/rust-lang/libc/runs/1283695796?check_suite_focus=true for example.) 0.1.36 contains rust-lang/compiler-builtins#332 so this version should remove this warning. cc rust-lang/libc#1942
Summary: The name is being taken by stdlib: warning: a method with this name may be added to the standard library in the future --> eden/scm/lib/dag/src/spanset.rs:228:14 | 228 | .binary_search_by(|probe| span.low.cmp(&probe.low)) | ^^^^^^^^^^^^^^^^ | = note: `#[warn(unstable_name_collisions)]` on by default = warning: once this method is added to the standard library, the ambiguity may cause an error or change in behavior! = note: for more information, see issue #48919 <rust-lang/rust#48919> = help: call with fully qualified syntax `BinarySearchBy::binary_search_by(...)` to keep using the current method = help: add `#![feature(vecdeque_binary_search)]` to the crate attributes to enable `VecDeque::<T>::binary_search_by` Reviewed By: sfilipco Differential Revision: D26092424 fbshipit-source-id: d2cdf7d73d2f808f038817c9dc9f4c531ff643bd
Is it possible to suppress this warning only for some specified method? Pseudo code:
If not, I think this warning is too broad. |
The lint suggests calling this with the full method name. It isn't clear to me how to do that in a chained call while keeping the chained syntax. E.g. myIter.filter(...).intersperse(...).map(...).collect(...) Here the warning is about intersperse (Itertools vs unstable standard library). How would I go about calling it as If that is not possible, this seems like a major deficiency in the recommendation from this lint. |
Try itertools::Itertools::intersperse(myIter.filter(...), &item).map(...).collect(...) This is known as fully qualified syntax. |
Thanks, this works but reverses the reading order in the middle of the expression, which is suboptimal. While the solution with a temporary variable keeps the order, it introduces clutter. Neither approach is optimal. |
I would really like to be able to opt-out of this per colliding method. I want to use |
I came here from a warning in my code. I was told to replace Except, if I do that, I then get a compile error. Looking at higher-up issues I can see I'm "doing it wrong", but I do think if possible it would be better to improve the error message to link somewhere how to actually fix your code, as the error doing a simple replace isn't helpful at all:
|
Suggestion: Could clippy's |
(NOT A CONTRIBUTION) I was shown this lint for calling I'm not sure if this is the case because nothing links me to the unstable API that I am in a collision with. Also, the lint suggested I change my code to I found this to be a pretty bad user experience. I was given a lint that I have no realistic choice but to suppress somehow, which the lint provides wrong advice for how to do. This resulted from calling a method in |
* perf: replace `expect` with `unwrap_or_else` The macro/functions in `expect` is not lazy, which means it will always be called * style: remove needless borrowing * perf: remove needless clone * style: remove needless `format!` * style: use `and_then` instead * style: use `?` instead * style: remove needless closure * fix: use fully qualified syntax instead rust-lang/rust#48919 * style: formatted * style: fix some other clippy issues
IMO this lint ought to be withdrawn, and instead the Rust project should commit to finding a better way to deal with this situation. There have been RFCs proposed, including rust-lang/rfcs#3240 The current compiler behaviour is to make complaints with no good solution. (Using the fully qualified syntax is not a good solution.) This keeps coming up in projects I work on and I'm finding myself adding Ie, this lint is not meeting its objective, of allowing std to implement these methods without breaking downstream code. |
@ijackson That's the point of rust-lang/rfcs#3624 |
unstable_name_collision
compatibility lintunstable_name_collisions
I wanted to hide this warning, so I used: #[allow(future_incompatible)] But it brought another problem that newly added annotations would also report warnings, so I had to use the following code to hide the warnings: #[allow(unused_attributes)]
#[allow(future_incompatible)] Is there a better way to hide warnings? |
``` warning: a method with this name may be added to the standard library in the future --> ykbuild/build.rs:202:15 | 202 | lock_file.unlock().unwrap(); | ^^^^^^ | = warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior! = note: for more information, see issue #48919 <rust-lang/rust#48919> = help: call with fully qualified syntax `unlock(...)` to keep using the current method = note: `#[warn(unstable_name_collisions)]` on by default help: add `#![feature(file_lock)]` to the crate attributes to enable `File::unlock` | 3 + #![feature(file_lock)] | ```
This is the summary issue for the
unstable_name_collisions
future-incompatibility lint and other related errors. The goal of this page is describe why this change was made and how you can fix code that is affected by it. It also provides a place to ask questions or register a complaint if you feel the change should not be made. For more information on the policy around future-compatibility warnings, see our breaking change policy guidelines.What is the warning for?
Rust's standard library is evolving, and will sometimes add new functions we found useful, e.g.
Ord::clamp
orIterator::flatten
. Unfortunately, there will often be popular third-party packages already implemented the same function with the same name. The compiler, when seeing the nameflatten
, cannot decide whether you want the one from the standard library or the third-party library, and gives up with the multiple applicable items in scope error.As an inference breakage canary, the compiler will emit a warning whenever it detected a name conflict with an unstable standard library function.
To stop this warning and the future hard error, you could use fully-qualified name to explicitly tell the compiler to use the third-party function:
When will this warning become a hard error?
This warning will be emitted for every unstable library feature having name conflicts. When a particular library feature is stabilized, this name conflict will cause a hard error.
Please follow the tracking issue for each library feature for their stabilization progress. Some current unstable method which is known to cause conflict in the wild are:
Vec::try_reserve
— Tracking issue fortry_reserve
: RFC 2116 fallible collection allocation #48043Ord::clamp
— Tracking issue for clamp RFC #44095The text was updated successfully, but these errors were encountered: