Skip to content

Commit b26e3c5

Browse files
committed
format
1 parent cd73914 commit b26e3c5

File tree

6 files changed

+51
-31
lines changed

6 files changed

+51
-31
lines changed

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
10071007
ResolutionError::ParamInTyOfConstParam { name } => {
10081008
self.dcx().create_err(errs::ParamInTyOfConstParam { span, name })
10091009
}
1010-
ResolutionError::ParamInNonTrivialAnonConst { name, param_kind: is_type , place} => {
1010+
ResolutionError::ParamInNonTrivialAnonConst { name, param_kind: is_type, place } => {
10111011
self.dcx().create_err(errs::ParamInNonTrivialAnonConst {
10121012
span,
10131013
name,

compiler/rustc_resolve/src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ pub(crate) struct ParamInNonTrivialAnonConst {
387387
pub(crate) param_kind: ParamKindInNonTrivialAnonConst,
388388
#[subdiagnostic]
389389
pub(crate) help: Option<ParamInNonTrivialAnonConstHelp>,
390-
pub(crate) place: AnonConstKind
390+
pub(crate) place: AnonConstKind,
391391
}
392392

393393
#[derive(Subdiagnostic)]

compiler/rustc_resolve/src/ident.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
13721372
param_kind:
13731373
ParamKindInNonTrivialAnonConst::Type,
13741374
place: kind,
1375-
13761375
}
13771376
}
13781377
};

compiler/rustc_resolve/src/late.rs

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,10 @@ impl IntoDiagArg for AnonConstKind {
8888
AnonConstKind::FieldDefaultValue => "field default value",
8989
AnonConstKind::InlineConst => "inline const",
9090
AnonConstKind::ConstArg(is_repeat_expr) => match is_repeat_expr {
91-
IsRepeatExpr::No => "array repeat expression",
92-
IsRepeatExpr::Yes => "const generic args",
93-
}
91+
IsRepeatExpr::No => "array repeat expression",
92+
IsRepeatExpr::Yes => "const generic args",
9493
},
95-
))
94+
}))
9695
}
9796
}
9897

@@ -3009,19 +3008,26 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
30093008
f: impl FnOnce(&mut Self),
30103009
) {
30113010
let f = |this: &mut Self| {
3012-
this.with_rib(ValueNS, RibKind::ConstantItem(may_use_generics, item, anon_const_kind), |this| {
3013-
this.with_rib(
3014-
TypeNS,
3015-
RibKind::ConstantItem(
3016-
may_use_generics.force_yes_if(is_repeat == IsRepeatExpr::Yes),
3017-
item,
3018-
anon_const_kind,
3019-
),
3020-
|this| {
3021-
this.with_label_rib(RibKind::ConstantItem(may_use_generics, item, anon_const_kind), f);
3022-
},
3023-
)
3024-
})
3011+
this.with_rib(
3012+
ValueNS,
3013+
RibKind::ConstantItem(may_use_generics, item, anon_const_kind),
3014+
|this| {
3015+
this.with_rib(
3016+
TypeNS,
3017+
RibKind::ConstantItem(
3018+
may_use_generics.force_yes_if(is_repeat == IsRepeatExpr::Yes),
3019+
item,
3020+
anon_const_kind,
3021+
),
3022+
|this| {
3023+
this.with_label_rib(
3024+
RibKind::ConstantItem(may_use_generics, item, anon_const_kind),
3025+
f,
3026+
);
3027+
},
3028+
)
3029+
},
3030+
)
30253031
};
30263032

30273033
if let ConstantHasGenerics::No(cause) = may_use_generics {
@@ -3535,9 +3541,13 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
35353541

35363542
fn resolve_const_body(&mut self, expr: &'ast Expr, item: Option<(Ident, ConstantItemKind)>) {
35373543
self.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| {
3538-
this.with_constant_rib(IsRepeatExpr::No, ConstantHasGenerics::Yes, None, item, |this| {
3539-
this.visit_expr(expr)
3540-
});
3544+
this.with_constant_rib(
3545+
IsRepeatExpr::No,
3546+
ConstantHasGenerics::Yes,
3547+
None,
3548+
item,
3549+
|this| this.visit_expr(expr),
3550+
);
35413551
})
35423552
}
35433553

@@ -4745,11 +4755,17 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
47454755
}
47464756
};
47474757

4748-
self.with_constant_rib(is_repeat_expr, may_use_generics, Some(anon_const_kind), None, |this| {
4749-
this.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| {
4750-
resolve_expr(this);
4751-
});
4752-
});
4758+
self.with_constant_rib(
4759+
is_repeat_expr,
4760+
may_use_generics,
4761+
Some(anon_const_kind),
4762+
None,
4763+
|this| {
4764+
this.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| {
4765+
resolve_expr(this);
4766+
});
4767+
},
4768+
);
47534769
}
47544770

47554771
fn resolve_expr_field(&mut self, f: &'ast ExprField, e: &'ast Expr) {

compiler/rustc_resolve/src/late/diagnostics.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ use tracing::debug;
3333
use super::NoConstantGenericsReason;
3434
use crate::diagnostics::{ImportSuggestion, LabelSuggestion, TypoSuggestion};
3535
use crate::late::{
36-
AliasPossibility, AnonConstKind, LateResolutionVisitor, LifetimeBinderKind, LifetimeRes, LifetimeRibKind, LifetimeUseSet, QSelf, RibKind
36+
AliasPossibility, AnonConstKind, LateResolutionVisitor, LifetimeBinderKind, LifetimeRes,
37+
LifetimeRibKind, LifetimeUseSet, QSelf, RibKind,
3738
};
3839
use crate::ty::fast_reject::SimplifiedType;
3940
use crate::{

compiler/rustc_resolve/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ use rustc_middle::query::Providers;
7070
use rustc_middle::span_bug;
7171
use rustc_middle::ty::{
7272
self, DelegationFnSig, Feed, MainDefinition, RegisteredTools, ResolverAstLowering,
73-
ResolverGlobalCtxt, TyCtxt, TyCtxtFeed, Visibility,
73+
ResolverGlobalCtxt, TyCtxt, TyCtxtFeed, Visibility
7474
};
7575
use rustc_query_system::ich::StableHashingContext;
7676
use rustc_session::lint::BuiltinLintDiag;
@@ -302,7 +302,11 @@ enum ResolutionError<'ra> {
302302
/// generic parameters must not be used inside const evaluations.
303303
///
304304
/// This error is only emitted when using `min_const_generics`.
305-
ParamInNonTrivialAnonConst { name: Symbol, param_kind: ParamKindInNonTrivialAnonConst, place: Option<AnonConstKind> },
305+
ParamInNonTrivialAnonConst {
306+
name: Symbol,
307+
param_kind: ParamKindInNonTrivialAnonConst,
308+
place: Option<AnonConstKind>,
309+
},
306310
/// generic parameters must not be used inside enum discriminants.
307311
///
308312
/// This error is emitted even with `generic_const_exprs`.

0 commit comments

Comments
 (0)