Rename ParenthesizedGenericArgs to GenericArgsMode
This commit is contained in:
parent
22572d0994
commit
2db1d2e261
@ -51,7 +51,7 @@
|
|||||||
use rustc_target::spec::abi;
|
use rustc_target::spec::abi;
|
||||||
use {rustc_ast as ast, rustc_hir as hir};
|
use {rustc_ast as ast, rustc_hir as hir};
|
||||||
|
|
||||||
use super::{ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs};
|
use super::{GenericArgsMode, ImplTraitContext, LoweringContext, ParamMode};
|
||||||
use crate::{ImplTraitPosition, ResolverAstLoweringExt};
|
use crate::{ImplTraitPosition, ResolverAstLoweringExt};
|
||||||
|
|
||||||
pub(crate) struct DelegationResults<'hir> {
|
pub(crate) struct DelegationResults<'hir> {
|
||||||
@ -323,7 +323,7 @@ fn finalize_body_lowering(
|
|||||||
delegation.path.span,
|
delegation.path.span,
|
||||||
ast_segment,
|
ast_segment,
|
||||||
ParamMode::Optional,
|
ParamMode::Optional,
|
||||||
ParenthesizedGenericArgs::Err,
|
GenericArgsMode::Err,
|
||||||
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
|
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
NeverPatternWithBody, NeverPatternWithGuard, UnderscoreExprLhsAssign,
|
NeverPatternWithBody, NeverPatternWithGuard, UnderscoreExprLhsAssign,
|
||||||
};
|
};
|
||||||
use super::{
|
use super::{
|
||||||
ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs, ResolverAstLoweringExt,
|
GenericArgsMode, ImplTraitContext, LoweringContext, ParamMode, ResolverAstLoweringExt,
|
||||||
};
|
};
|
||||||
use crate::errors::YieldInClosure;
|
use crate::errors::YieldInClosure;
|
||||||
use crate::{fluent_generated, FnDeclKind, ImplTraitPosition};
|
use crate::{fluent_generated, FnDeclKind, ImplTraitPosition};
|
||||||
@ -107,7 +107,7 @@ pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> {
|
|||||||
e.span,
|
e.span,
|
||||||
seg,
|
seg,
|
||||||
ParamMode::Optional,
|
ParamMode::Optional,
|
||||||
ParenthesizedGenericArgs::Err,
|
GenericArgsMode::Err,
|
||||||
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
|
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
|
||||||
// Method calls can't have bound modifiers
|
// Method calls can't have bound modifiers
|
||||||
None,
|
None,
|
||||||
|
@ -487,7 +487,7 @@ enum ParamMode {
|
|||||||
Optional,
|
Optional,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ParenthesizedGenericArgs {
|
enum GenericArgsMode {
|
||||||
ParenSugar,
|
ParenSugar,
|
||||||
Err,
|
Err,
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
GenericTypeWithParentheses, UseAngleBrackets,
|
GenericTypeWithParentheses, UseAngleBrackets,
|
||||||
};
|
};
|
||||||
use super::{
|
use super::{
|
||||||
GenericArgsCtor, ImplTraitContext, LifetimeRes, LoweringContext, ParamMode,
|
GenericArgsCtor, GenericArgsMode, ImplTraitContext, LifetimeRes, LoweringContext, ParamMode,
|
||||||
ParenthesizedGenericArgs, ResolverAstLoweringExt,
|
ResolverAstLoweringExt,
|
||||||
};
|
};
|
||||||
use crate::ImplTraitPosition;
|
use crate::ImplTraitPosition;
|
||||||
|
|
||||||
@ -90,10 +90,10 @@ pub(crate) fn lower_qpath(
|
|||||||
_ => param_mode,
|
_ => param_mode,
|
||||||
};
|
};
|
||||||
|
|
||||||
let parenthesized_generic_args = match base_res {
|
let generic_args_mode = match base_res {
|
||||||
// `a::b::Trait(Args)`
|
// `a::b::Trait(Args)`
|
||||||
Res::Def(DefKind::Trait, _) if i + 1 == proj_start => {
|
Res::Def(DefKind::Trait, _) if i + 1 == proj_start => {
|
||||||
ParenthesizedGenericArgs::ParenSugar
|
GenericArgsMode::ParenSugar
|
||||||
}
|
}
|
||||||
// `a::b::Trait(Args)::TraitItem`
|
// `a::b::Trait(Args)::TraitItem`
|
||||||
Res::Def(DefKind::AssocFn, _)
|
Res::Def(DefKind::AssocFn, _)
|
||||||
@ -101,19 +101,19 @@ pub(crate) fn lower_qpath(
|
|||||||
| Res::Def(DefKind::AssocTy, _)
|
| Res::Def(DefKind::AssocTy, _)
|
||||||
if i + 2 == proj_start =>
|
if i + 2 == proj_start =>
|
||||||
{
|
{
|
||||||
ParenthesizedGenericArgs::ParenSugar
|
GenericArgsMode::ParenSugar
|
||||||
}
|
}
|
||||||
// Avoid duplicated errors.
|
// Avoid duplicated errors.
|
||||||
Res::Err => ParenthesizedGenericArgs::ParenSugar,
|
Res::Err => GenericArgsMode::ParenSugar,
|
||||||
// An error
|
// An error
|
||||||
_ => ParenthesizedGenericArgs::Err,
|
_ => GenericArgsMode::Err,
|
||||||
};
|
};
|
||||||
|
|
||||||
self.lower_path_segment(
|
self.lower_path_segment(
|
||||||
p.span,
|
p.span,
|
||||||
segment,
|
segment,
|
||||||
param_mode,
|
param_mode,
|
||||||
parenthesized_generic_args,
|
generic_args_mode,
|
||||||
itctx,
|
itctx,
|
||||||
bound_modifier_allowed_features.clone(),
|
bound_modifier_allowed_features.clone(),
|
||||||
)
|
)
|
||||||
@ -168,7 +168,7 @@ pub(crate) fn lower_qpath(
|
|||||||
p.span,
|
p.span,
|
||||||
segment,
|
segment,
|
||||||
param_mode,
|
param_mode,
|
||||||
ParenthesizedGenericArgs::Err,
|
GenericArgsMode::Err,
|
||||||
itctx,
|
itctx,
|
||||||
None,
|
None,
|
||||||
));
|
));
|
||||||
@ -210,7 +210,7 @@ pub(crate) fn lower_use_path(
|
|||||||
p.span,
|
p.span,
|
||||||
segment,
|
segment,
|
||||||
param_mode,
|
param_mode,
|
||||||
ParenthesizedGenericArgs::Err,
|
GenericArgsMode::Err,
|
||||||
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
|
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
@ -224,7 +224,7 @@ pub(crate) fn lower_path_segment(
|
|||||||
path_span: Span,
|
path_span: Span,
|
||||||
segment: &PathSegment,
|
segment: &PathSegment,
|
||||||
param_mode: ParamMode,
|
param_mode: ParamMode,
|
||||||
parenthesized_generic_args: ParenthesizedGenericArgs,
|
generic_args_mode: GenericArgsMode,
|
||||||
itctx: ImplTraitContext,
|
itctx: ImplTraitContext,
|
||||||
// Additional features ungated with a bound modifier like `async`.
|
// Additional features ungated with a bound modifier like `async`.
|
||||||
// This is passed down to the implicit associated type binding in
|
// This is passed down to the implicit associated type binding in
|
||||||
@ -237,14 +237,13 @@ pub(crate) fn lower_path_segment(
|
|||||||
GenericArgs::AngleBracketed(data) => {
|
GenericArgs::AngleBracketed(data) => {
|
||||||
self.lower_angle_bracketed_parameter_data(data, param_mode, itctx)
|
self.lower_angle_bracketed_parameter_data(data, param_mode, itctx)
|
||||||
}
|
}
|
||||||
GenericArgs::Parenthesized(data) => match parenthesized_generic_args {
|
GenericArgs::Parenthesized(data) => match generic_args_mode {
|
||||||
ParenthesizedGenericArgs::ParenSugar => self
|
GenericArgsMode::ParenSugar => self.lower_parenthesized_parameter_data(
|
||||||
.lower_parenthesized_parameter_data(
|
data,
|
||||||
data,
|
itctx,
|
||||||
itctx,
|
bound_modifier_allowed_features,
|
||||||
bound_modifier_allowed_features,
|
),
|
||||||
),
|
GenericArgsMode::Err => {
|
||||||
ParenthesizedGenericArgs::Err => {
|
|
||||||
// Suggest replacing parentheses with angle brackets `Trait(params...)` to `Trait<params...>`
|
// Suggest replacing parentheses with angle brackets `Trait(params...)` to `Trait<params...>`
|
||||||
let sub = if !data.inputs.is_empty() {
|
let sub = if !data.inputs.is_empty() {
|
||||||
// Start of the span to the 1st character of 1st argument
|
// Start of the span to the 1st character of 1st argument
|
||||||
|
Loading…
Reference in New Issue
Block a user