-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add #![rustc_never_type_mode = "..."]
crate-level attribute to allow experimenting
#122543
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
Conversation
This comment has been minimized.
This comment has been minimized.
4e02b7a
to
e8e4ecf
Compare
feature(no_never_type_fallback)
to allow experimentingfeature(no_never_type_fallback)
and feature(no_never_type_spontaneous_decay)
to allow experimenting
I am having trouble finding value in adding these as feature flags. I think they should just be crate-level |
Especially if you plan to add more feature gates, this just seems really unmanageable. |
Well, yes, this is more for testing stuff and making sure T-lang understands what is the proposal with the never type. @compiler-errors do you have a pointer of where a crate-level attribute was added? I made this as feature(s) because it was simpler to do, but I can rewrite this as an attribute, just not sure where those are handled in rustc.. |
We don't really "handle" crate-level attributes anywhere centralized. They are just checked with |
68e6f9c
to
8bfc0c5
Compare
@compiler-errors thanks <3 made this into an attribute. |
feature(no_never_type_fallback)
and feature(no_never_type_spontaneous_decay)
to allow experimentingno_never_type_fallback)
and feature(no_never_type_spontaneous_decay)
to allow experimenting
no_never_type_fallback)
and feature(no_never_type_spontaneous_decay)
to allow experimenting#![rustc_never_type_mode = "..."]
crate-level attribute to allow experimenting
There is a place where I'm not sure what to do: rust/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs Lines 396 to 402 in c5b5713
I have no context on what this does.. |
@@ -580,6 +580,13 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ | |||
"`may_dangle` has unstable semantics and may be removed in the future", | |||
), | |||
|
|||
rustc_attr!( | |||
rustc_never_type_mode, Normal, template!(NameValueStr: "fallback_to_unit|fallback_to_niko|no_fallback"), ErrorFollowing, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rustc_never_type_mode, Normal, template!(NameValueStr: "fallback_to_unit|fallback_to_niko|no_fallback"), ErrorFollowing, | |
rustc_never_type_mode, Normal, template!(NameValueStr: "fallback_to_unit|fallback_to_niko|fallback_to_never|no_fallback"), ErrorFollowing, |
It's for when there's no opaque type inference. Consider something like:
|
495ff00
to
adfdd27
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks waffle ❤️
this is good enough for now though we may want to figure out wtf to do with that opaque type fallback 💀
also lol @ fallback_to_niko
@bors r+ |
…er-errors Add `#![rustc_never_type_mode = "..."]` crate-level attribute to allow experimenting Demonstrating how different approaches with the never type work is somewhat hard when you can't actually provide a runnable example. Let's add features that change the fallback behavior. This adds `#![rustc_never_type_mode = "no_fallback"]` and `#![rustc_never_type_mode = "fallback_to_never"]`, but I also plan to add others (in future PRs). cc `@traviscross` r? `@compiler-errors`
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#122254 (Detect calls to .clone() on T: !Clone types on borrowck errors) - rust-lang#122495 (Visually mark 👻hidden👻 items with document-hidden-items) - rust-lang#122543 (Add `#![rustc_never_type_mode = "..."]` crate-level attribute to allow experimenting) - rust-lang#122560 (Safe Transmute: Use 'not yet supported', not 'unspecified' in errors) - rust-lang#122562 (Mention labelled blocks in `break` docs) - rust-lang#122563 (CI: cache PR CI Docker builds) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#122543 - WaffleLapkin:never-flags, r=compiler-errors Add `#![rustc_never_type_mode = "..."]` crate-level attribute to allow experimenting Demonstrating how different approaches with the never type work is somewhat hard when you can't actually provide a runnable example. Let's add features that change the fallback behavior. This adds `#![rustc_never_type_mode = "no_fallback"]` and `#![rustc_never_type_mode = "fallback_to_never"]`, but I also plan to add others (in future PRs). cc ``@traviscross`` r? ``@compiler-errors``
Demonstrating how different approaches with the never type work is somewhat hard when you can't actually provide a runnable example. Let's add features that change the fallback behavior.
This adds
#![rustc_never_type_mode = "no_fallback"]
and#![rustc_never_type_mode = "fallback_to_never"]
, but I also plan to add others (in future PRs).cc @traviscross
r? @compiler-errors