mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +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
|
// 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<'_>) {
|
pub(super) fn bounds(p: &mut Parser<'_>) {
|
||||||
p.expect(T![:]);
|
p.expect(T![:]);
|
||||||
bounds_without_colon(p);
|
bounds_without_colon(p);
|
||||||
@ -187,6 +187,11 @@ fn type_bound(p: &mut Parser<'_>) -> bool {
|
|||||||
p.bump_any();
|
p.bump_any();
|
||||||
p.expect(T![const]);
|
p.expect(T![const]);
|
||||||
}
|
}
|
||||||
|
T!['['] => {
|
||||||
|
p.bump_any();
|
||||||
|
p.expect(T![const]);
|
||||||
|
p.expect(T![']']);
|
||||||
|
}
|
||||||
// test const_trait_bound
|
// test const_trait_bound
|
||||||
// const fn foo(_: impl const Trait) {}
|
// const fn foo(_: impl const Trait) {}
|
||||||
T![const] => {
|
T![const] => {
|
||||||
|
@ -40,8 +40,9 @@ SOURCE_FILE
|
|||||||
PLUS "+"
|
PLUS "+"
|
||||||
WHITESPACE " "
|
WHITESPACE " "
|
||||||
TYPE_BOUND
|
TYPE_BOUND
|
||||||
TILDE "~"
|
L_BRACK "["
|
||||||
CONST_KW "const"
|
CONST_KW "const"
|
||||||
|
R_BRACK "]"
|
||||||
WHITESPACE " "
|
WHITESPACE " "
|
||||||
PATH_TYPE
|
PATH_TYPE
|
||||||
PATH
|
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 =
|
TypeBound =
|
||||||
Lifetime
|
Lifetime
|
||||||
| ('~' 'const' | 'const')? 'async'? '?'? Type
|
| ('~' 'const' | '[' 'const' ']' | 'const')? 'async'? '?'? Type
|
||||||
| 'use' UseBoundGenericArgs
|
| 'use' UseBoundGenericArgs
|
||||||
|
|
||||||
UseBoundGenericArgs =
|
UseBoundGenericArgs =
|
||||||
|
@ -1766,6 +1766,10 @@ impl TypeBound {
|
|||||||
support::child(&self.syntax)
|
support::child(&self.syntax)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[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![?]) }
|
pub fn question_mark_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![?]) }
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
|
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")]
|
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")]
|
||||||
impl<A: Tuple, F: ?Sized> const Fn<A> for &F
|
impl<A: Tuple, F: ?Sized> const Fn<A> for &F
|
||||||
where
|
where
|
||||||
F: ~const Fn<A>,
|
F: [const] Fn<A>,
|
||||||
{
|
{
|
||||||
extern "rust-call" fn call(&self, args: A) -> F::Output {
|
extern "rust-call" fn call(&self, args: A) -> F::Output {
|
||||||
(**self).call(args)
|
(**self).call(args)
|
||||||
@ -697,7 +697,7 @@ pub mod ops {
|
|||||||
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")]
|
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")]
|
||||||
impl<A: Tuple, F: ?Sized> const FnMut<A> for &F
|
impl<A: Tuple, F: ?Sized> const FnMut<A> for &F
|
||||||
where
|
where
|
||||||
F: ~const Fn<A>,
|
F: [const] Fn<A>,
|
||||||
{
|
{
|
||||||
extern "rust-call" fn call_mut(&mut self, args: A) -> F::Output {
|
extern "rust-call" fn call_mut(&mut self, args: A) -> F::Output {
|
||||||
(**self).call(args)
|
(**self).call(args)
|
||||||
@ -708,7 +708,7 @@ pub mod ops {
|
|||||||
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")]
|
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")]
|
||||||
impl<A: Tuple, F: ?Sized> const FnOnce<A> for &F
|
impl<A: Tuple, F: ?Sized> const FnOnce<A> for &F
|
||||||
where
|
where
|
||||||
F: ~const Fn<A>,
|
F: [const] Fn<A>,
|
||||||
{
|
{
|
||||||
type Output = F::Output;
|
type Output = F::Output;
|
||||||
|
|
||||||
@ -721,7 +721,7 @@ pub mod ops {
|
|||||||
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")]
|
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")]
|
||||||
impl<A: Tuple, F: ?Sized> const FnMut<A> for &mut F
|
impl<A: Tuple, F: ?Sized> const FnMut<A> for &mut F
|
||||||
where
|
where
|
||||||
F: ~const FnMut<A>,
|
F: [const] FnMut<A>,
|
||||||
{
|
{
|
||||||
extern "rust-call" fn call_mut(&mut self, args: A) -> F::Output {
|
extern "rust-call" fn call_mut(&mut self, args: A) -> F::Output {
|
||||||
(*self).call_mut(args)
|
(*self).call_mut(args)
|
||||||
@ -732,7 +732,7 @@ pub mod ops {
|
|||||||
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")]
|
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")]
|
||||||
impl<A: Tuple, F: ?Sized> const FnOnce<A> for &mut F
|
impl<A: Tuple, F: ?Sized> const FnOnce<A> for &mut F
|
||||||
where
|
where
|
||||||
F: ~const FnMut<A>,
|
F: [const] FnMut<A>,
|
||||||
{
|
{
|
||||||
type Output = F::Output;
|
type Output = F::Output;
|
||||||
extern "rust-call" fn call_once(self, args: A) -> F::Output {
|
extern "rust-call" fn call_once(self, args: A) -> F::Output {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user