mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 11:20:54 +00:00
Merge pull request #20105 from Veykril/push-qtmwnuqvsruw
Parse new const trait syntax
This commit is contained in:
commit
d2691ac24b
@ -122,7 +122,7 @@ fn lifetime_bounds(p: &mut Parser<'_>) {
|
||||
}
|
||||
|
||||
// test type_param_bounds
|
||||
// struct S<T: 'a + ?Sized + (Copy) + ~const Drop>;
|
||||
// struct S<T: 'a + ?Sized + (Copy) + [const] Drop>;
|
||||
pub(super) fn bounds(p: &mut Parser<'_>) {
|
||||
p.expect(T![:]);
|
||||
bounds_without_colon(p);
|
||||
@ -187,6 +187,11 @@ fn type_bound(p: &mut Parser<'_>) -> bool {
|
||||
p.bump_any();
|
||||
p.expect(T![const]);
|
||||
}
|
||||
T!['['] => {
|
||||
p.bump_any();
|
||||
p.expect(T![const]);
|
||||
p.expect(T![']']);
|
||||
}
|
||||
// test const_trait_bound
|
||||
// const fn foo(_: impl const Trait) {}
|
||||
T![const] => {
|
||||
|
@ -40,8 +40,9 @@ SOURCE_FILE
|
||||
PLUS "+"
|
||||
WHITESPACE " "
|
||||
TYPE_BOUND
|
||||
TILDE "~"
|
||||
L_BRACK "["
|
||||
CONST_KW "const"
|
||||
R_BRACK "]"
|
||||
WHITESPACE " "
|
||||
PATH_TYPE
|
||||
PATH
|
||||
|
@ -1 +1 @@
|
||||
struct S<T: 'a + ?Sized + (Copy) + ~const Drop>;
|
||||
struct S<T: 'a + ?Sized + (Copy) + [const] Drop>;
|
||||
|
@ -669,7 +669,7 @@ TypeBoundList =
|
||||
|
||||
TypeBound =
|
||||
Lifetime
|
||||
| ('~' 'const' | 'const')? 'async'? '?'? Type
|
||||
| ('~' 'const' | '[' 'const' ']' | 'const')? 'async'? '?'? Type
|
||||
| 'use' UseBoundGenericArgs
|
||||
|
||||
UseBoundGenericArgs =
|
||||
|
@ -1766,6 +1766,10 @@ impl TypeBound {
|
||||
support::child(&self.syntax)
|
||||
}
|
||||
#[inline]
|
||||
pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
|
||||
#[inline]
|
||||
pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
|
||||
#[inline]
|
||||
pub fn question_mark_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![?]) }
|
||||
#[inline]
|
||||
pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
|
||||
|
@ -686,7 +686,7 @@ pub mod ops {
|
||||
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")]
|
||||
impl<A: Tuple, F: ?Sized> const Fn<A> for &F
|
||||
where
|
||||
F: ~const Fn<A>,
|
||||
F: [const] Fn<A>,
|
||||
{
|
||||
extern "rust-call" fn call(&self, args: A) -> F::Output {
|
||||
(**self).call(args)
|
||||
@ -697,7 +697,7 @@ pub mod ops {
|
||||
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")]
|
||||
impl<A: Tuple, F: ?Sized> const FnMut<A> for &F
|
||||
where
|
||||
F: ~const Fn<A>,
|
||||
F: [const] Fn<A>,
|
||||
{
|
||||
extern "rust-call" fn call_mut(&mut self, args: A) -> F::Output {
|
||||
(**self).call(args)
|
||||
@ -708,7 +708,7 @@ pub mod ops {
|
||||
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")]
|
||||
impl<A: Tuple, F: ?Sized> const FnOnce<A> for &F
|
||||
where
|
||||
F: ~const Fn<A>,
|
||||
F: [const] Fn<A>,
|
||||
{
|
||||
type Output = F::Output;
|
||||
|
||||
@ -721,7 +721,7 @@ pub mod ops {
|
||||
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")]
|
||||
impl<A: Tuple, F: ?Sized> const FnMut<A> for &mut F
|
||||
where
|
||||
F: ~const FnMut<A>,
|
||||
F: [const] FnMut<A>,
|
||||
{
|
||||
extern "rust-call" fn call_mut(&mut self, args: A) -> F::Output {
|
||||
(*self).call_mut(args)
|
||||
@ -732,7 +732,7 @@ pub mod ops {
|
||||
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")]
|
||||
impl<A: Tuple, F: ?Sized> const FnOnce<A> for &mut F
|
||||
where
|
||||
F: ~const FnMut<A>,
|
||||
F: [const] FnMut<A>,
|
||||
{
|
||||
type Output = F::Output;
|
||||
extern "rust-call" fn call_once(self, args: A) -> F::Output {
|
||||
|
Loading…
x
Reference in New Issue
Block a user