1
Fork 0

Make sure we deny unimplemented RTN on qpath segments

This commit is contained in:
Michael Goulet 2024-06-28 14:10:32 -04:00
parent b1a0c0b123
commit 82b4af7511
5 changed files with 112 additions and 3 deletions

View file

@ -43,6 +43,8 @@ ast_lowering_bad_return_type_notation_output =
return type not allowed with return type notation
.suggestion = remove the return type
ast_lowering_bad_return_type_notation_position = return type notation not allowed in this position yet
ast_lowering_base_expression_double_dot =
base expression required after `..`
.suggestion = add a base expression here

View file

@ -399,6 +399,11 @@ pub enum BadReturnTypeNotation {
#[suggestion(code = "(..)", applicability = "maybe-incorrect")]
span: Span,
},
#[diag(ast_lowering_bad_return_type_notation_position)]
Position {
#[primary_span]
span: Span,
},
}
#[derive(Diagnostic)]

View file

@ -1,7 +1,8 @@
use crate::ImplTraitPosition;
use super::errors::{
AsyncBoundNotOnTrait, AsyncBoundOnlyForFnTraits, GenericTypeWithParentheses, UseAngleBrackets,
AsyncBoundNotOnTrait, AsyncBoundOnlyForFnTraits, BadReturnTypeNotation,
GenericTypeWithParentheses, UseAngleBrackets,
};
use super::ResolverAstLoweringExt;
use super::{GenericArgsCtor, LifetimeRes, ParenthesizedGenericArgs};
@ -276,8 +277,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
)
}
},
GenericArgs::ParenthesizedElided(_span) => {
todo!()
GenericArgs::ParenthesizedElided(span) => {
self.dcx().emit_err(BadReturnTypeNotation::Position { span: *span });
(
GenericArgsCtor {
args: Default::default(),
constraints: &[],
parenthesized: hir::GenericArgsParentheses::ReturnTypeNotation,
span: *span,
},
false,
)
}
}
} else {