-
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
Introduce ~const
#88328
Introduce ~const
#88328
Conversation
Some changes occurred in src/tools/rustfmt. |
This comment has been minimized.
This comment has been minimized.
Why are you changing this? ~ seems inconsistent with traits; I guess this isn't a trait, but I think at the very least T-lang should be involved somehow. |
@rust-lang/wg-const-eval has permission to experiment with |
This comment has been minimized.
This comment has been minimized.
- [x] Removed `?const` and change uses of `?const` - [x] Added `~const` to the AST. It is gated behind const_trait_impl. - [x] Validate `~const` in ast_validation. - [ ] Add enum `BoundConstness` to the HIR. (With variants `NotConst` and `ConstIfConst` allowing future extensions) - [ ] Adjust trait selection and pre-existing code to use `BoundConstness`. - [ ] Optional steps (*for this PR, obviously*) - [ ] Fix rust-lang#88155 - [ ] Do something with constness bounds in chalk
3f7bbb5
to
b057f96
Compare
This comment has been minimized.
This comment has been minimized.
b057f96
to
80e1ee5
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@@ -609,6 +609,7 @@ impl<'a> Parser<'a> { | |||
|| self.check_lifetime() | |||
|| self.check(&token::Not) // Used for error reporting only. | |||
|| self.check(&token::Question) | |||
|| self.check(&token::Tilde) |
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.
I guess this can be a breaking change for some weird macro like
macro_rules! weird {
($x:ty) => { println!("ty"); };
(dyn ~const Trait) => { println!("~"); };
}
fn main() {
weird!(dyn Trait);
weird!(dyn ?const Trait);
weird!(dyn ~const Trait);
}
but... in hindsight, the same was true for ?const
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.
It is gated behind const_trait_impl
. Do we have a policy for AST changes like this?
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.
the problem is that it works on stable and errors on your branch (or if the feature gate is stabilized, picks the first macro pattern instead of the second)
I think we can do this, but I don't really know the policy. I think we have some way of not breaking macros with syntax changes like this. Maybe @petrochenkov knows?
src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/without-question-mark.rs
Show resolved
Hide resolved
src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/opt-out-twice.rs
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
ed5a25f
to
0a3a608
Compare
This comment has been minimized.
This comment has been minimized.
@bors r+ rollup=never (for bisection in case we break sth) |
📌 Commit 2d7dbf2 has been approved by |
☀️ Test successful - checks-actions |
?const
and change uses of?const
~const
to the AST. It is gated behind const_trait_impl.~const
in ast_validation.BoundConstness
(With variantsNotConst
andConstIfConst
allowing future extensions)BoundConstness
.Do something with constness bounds in chalkMust be done to rust-lang/chalk (just tried to refactor, there are a lot of errors to resolve :( )~const
bounds that can't be satisfied.r? @oli-obk