-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
rustc_on_unimplemented
is not std-agnostic
#112923
Comments
The filters can be extended to also account for |
@estebank I think we should still (eventually) investigate how we can make I'll mark this as
E-easy
InstructionsIf you want to work on this, use Then find all mentions of For example: --- a/library/core/src/convert/mod.rs
+++ b/library/core/src/convert/mod.rs
@@ -534,7 +534,10 @@ pub trait Into<T>: Sized {
#[rustc_on_unimplemented(on(
all(
_Self = "&str",
- T = "std::string::String"
+ any(
+ T = "alloc::string::String",
+ T = "std::string::String",
+ )
),
note = "to coerce a `{T}` into a `{Self}`, use `&*` as a prefix",
))] |
@rustbot claim |
…nted`-std-agnostic, r=WaffleLapkin Make `rustc_on_unimplemented` std-agnostic See rust-lang#112923 r? `@WaffleLapkin`
…nted`-std-agnostic, r=WaffleLapkin Make `rustc_on_unimplemented` std-agnostic See rust-lang#112923 r? ``@WaffleLapkin``
I believe that the way forward is with annotations in the types themselves that influence the E0277 errors. This design will have to be explored as part of the |
…nted`-std-agnostic, r=WaffleLapkin Make `rustc_on_unimplemented` std-agnostic See rust-lang#112923 r? `@WaffleLapkin`
@rustbot claim |
@estebank annotating the types seems backwards, as it would require annotating all types, at which point you re-invented paths, or users won't be able to add " Couldn't we instead resolve paths in " |
…implemented-for-alloc-rc, r=WaffleLapkin Make `rustc_on_unimplemented` std-agnostic for `alloc::rc` See rust-lang#112923 Just a few lines related to `alloc:rc` for `Send` and `Sync`. That seems to be all of the `... = "std::..."` issues found, but there a few notes with `std::` inside them still. r? `@WaffleLapkin`
If
rustc_on_unimplemented
contains a path mentioningstd::
, it won't work in#![no_std]
crates, even if the type exists in thecore
. Similarly if you usecore::
path instead, the diagnostic will only work in#![no_std]
crates.As an example take this annotation for
?
desugaring:rust/library/core/src/ops/try_trait.rs
Lines 250 to 260 in fa06a37
It should (and does) trigger for the following code:
(play;note the use
.ok()?
label)However, if you add
#![no_std]
the label disappears:(play; the error message is also misleading, the function does return option)
rustc in general is not great at being std-agnostic in diagnostics, and this is just another annoying example of that.
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: