Skip to content

Commit 3d42053

Browse files
committed
format
1 parent f08767a commit 3d42053

File tree

6 files changed

+52
-31
lines changed

6 files changed

+52
-31
lines changed

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
900900
ResolutionError::ParamInTyOfConstParam { name } => {
901901
self.dcx().create_err(errs::ParamInTyOfConstParam { span, name })
902902
}
903-
ResolutionError::ParamInNonTrivialAnonConst { name, param_kind: is_type , place} => {
903+
ResolutionError::ParamInNonTrivialAnonConst { name, param_kind: is_type, place } => {
904904
self.dcx().create_err(errs::ParamInNonTrivialAnonConst {
905905
span,
906906
name,

compiler/rustc_resolve/src/errors.rs

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

390390
#[derive(Subdiagnostic)]

compiler/rustc_resolve/src/ident.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
13071307
param_kind:
13081308
ParamKindInNonTrivialAnonConst::Type,
13091309
place: kind,
1310-
13111310
}
13121311
}
13131312
};

compiler/rustc_resolve/src/late.rs

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,10 @@ impl IntoDiagArg for AnonConstKind {
9090
AnonConstKind::FieldDefaultValue => "field default value",
9191
AnonConstKind::InlineConst => "inline const",
9292
AnonConstKind::ConstArg(is_repeat_expr) => match is_repeat_expr {
93-
IsRepeatExpr::No => "array repeat expression",
94-
IsRepeatExpr::Yes => "const generic args",
95-
}
93+
IsRepeatExpr::No => "array repeat expression",
94+
IsRepeatExpr::Yes => "const generic args",
9695
},
97-
))
96+
}))
9897
}
9998
}
10099

@@ -3037,19 +3036,26 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
30373036
f: impl FnOnce(&mut Self),
30383037
) {
30393038
let f = |this: &mut Self| {
3040-
this.with_rib(ValueNS, RibKind::ConstantItem(may_use_generics, item, anon_const_kind), |this| {
3041-
this.with_rib(
3042-
TypeNS,
3043-
RibKind::ConstantItem(
3044-
may_use_generics.force_yes_if(is_repeat == IsRepeatExpr::Yes),
3045-
item,
3046-
anon_const_kind,
3047-
),
3048-
|this| {
3049-
this.with_label_rib(RibKind::ConstantItem(may_use_generics, item, anon_const_kind), f);
3050-
},
3051-
)
3052-
})
3039+
this.with_rib(
3040+
ValueNS,
3041+
RibKind::ConstantItem(may_use_generics, item, anon_const_kind),
3042+
|this| {
3043+
this.with_rib(
3044+
TypeNS,
3045+
RibKind::ConstantItem(
3046+
may_use_generics.force_yes_if(is_repeat == IsRepeatExpr::Yes),
3047+
item,
3048+
anon_const_kind,
3049+
),
3050+
|this| {
3051+
this.with_label_rib(
3052+
RibKind::ConstantItem(may_use_generics, item, anon_const_kind),
3053+
f,
3054+
);
3055+
},
3056+
)
3057+
},
3058+
)
30533059
};
30543060

30553061
if let ConstantHasGenerics::No(cause) = may_use_generics {
@@ -3565,9 +3571,13 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
35653571

35663572
fn resolve_const_body(&mut self, expr: &'ast Expr, item: Option<(Ident, ConstantItemKind)>) {
35673573
self.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| {
3568-
this.with_constant_rib(IsRepeatExpr::No, ConstantHasGenerics::Yes, None, item, |this| {
3569-
this.visit_expr(expr)
3570-
});
3574+
this.with_constant_rib(
3575+
IsRepeatExpr::No,
3576+
ConstantHasGenerics::Yes,
3577+
None,
3578+
item,
3579+
|this| this.visit_expr(expr),
3580+
);
35713581
})
35723582
}
35733583

@@ -4774,11 +4784,17 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
47744784
}
47754785
};
47764786

4777-
self.with_constant_rib(is_repeat_expr, may_use_generics, Some(anon_const_kind), None, |this| {
4778-
this.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| {
4779-
resolve_expr(this);
4780-
});
4781-
});
4787+
self.with_constant_rib(
4788+
is_repeat_expr,
4789+
may_use_generics,
4790+
Some(anon_const_kind),
4791+
None,
4792+
|this| {
4793+
this.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| {
4794+
resolve_expr(this);
4795+
});
4796+
},
4797+
);
47824798
}
47834799

47844800
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
@@ -35,7 +35,8 @@ use tracing::debug;
3535
use super::NoConstantGenericsReason;
3636
use crate::diagnostics::{ImportSuggestion, LabelSuggestion, TypoSuggestion};
3737
use crate::late::{
38-
AliasPossibility, AnonConstKind, LateResolutionVisitor, LifetimeBinderKind, LifetimeRes, LifetimeRibKind, LifetimeUseSet, QSelf, RibKind
38+
AliasPossibility, AnonConstKind, LateResolutionVisitor, LifetimeBinderKind, LifetimeRes,
39+
LifetimeRibKind, LifetimeUseSet, QSelf, RibKind,
3940
};
4041
use crate::ty::fast_reject::SimplifiedType;
4142
use crate::{

compiler/rustc_resolve/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ use rustc_middle::middle::privacy::EffectiveVisibilities;
6464
use rustc_middle::query::Providers;
6565
use rustc_middle::span_bug;
6666
use rustc_middle::ty::{
67-
self, DelegationFnSig, Feed, MainDefinition, RegisteredTools, ResolverGlobalCtxt, ResolverOutputs, TyCtxt, TyCtxtFeed, Visibility
67+
self, DelegationFnSig, Feed, MainDefinition, RegisteredTools, ResolverGlobalCtxt,
68+
ResolverOutputs, TyCtxt, TyCtxtFeed, Visibility,
6869
};
6970
use rustc_query_system::ich::StableHashingContext;
7071
use rustc_session::lint::builtin::PRIVATE_MACRO_USE;
@@ -287,7 +288,11 @@ enum ResolutionError<'ra> {
287288
/// generic parameters must not be used inside const evaluations.
288289
///
289290
/// This error is only emitted when using `min_const_generics`.
290-
ParamInNonTrivialAnonConst { name: Symbol, param_kind: ParamKindInNonTrivialAnonConst, place: Option<AnonConstKind> },
291+
ParamInNonTrivialAnonConst {
292+
name: Symbol,
293+
param_kind: ParamKindInNonTrivialAnonConst,
294+
place: Option<AnonConstKind>,
295+
},
291296
/// generic parameters must not be used inside enum discriminants.
292297
///
293298
/// This error is emitted even with `generic_const_exprs`.

0 commit comments

Comments
 (0)