Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e80f33b

Browse files
committedFeb 4, 2024
fmt
1 parent 4b0afe4 commit e80f33b

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed
 

‎compiler/rustc_ast_lowering/src/item.rs

+18-6
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
585585
hir::Constness::NotConst => Const::No,
586586
}
587587
}
588-
hir::ItemKind::Trait(_, _, _, _, _) => {
589-
parent_hir.attrs.get(parent_item.hir_id().local_id).iter().find(|attr| attr.has_name(sym::const_trait)).map_or(Const::No, |attr| Const::Yes(attr.span))
590-
},
588+
hir::ItemKind::Trait(_, _, _, _, _) => parent_hir
589+
.attrs
590+
.get(parent_item.hir_id().local_id)
591+
.iter()
592+
.find(|attr| attr.has_name(sym::const_trait))
593+
.map_or(Const::No, |attr| Const::Yes(attr.span)),
591594
kind => {
592595
span_bug!(item.span, "assoc item has unexpected kind of parent: {}", kind.descr())
593596
}
@@ -722,7 +725,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
722725
}
723726
}
724727

725-
fn lower_trait_item(&mut self, i: &AssocItem, trait_constness: Const) -> &'hir hir::TraitItem<'hir> {
728+
fn lower_trait_item(
729+
&mut self,
730+
i: &AssocItem,
731+
trait_constness: Const,
732+
) -> &'hir hir::TraitItem<'hir> {
726733
let hir_id = self.lower_node_id(i.id);
727734
self.lower_attrs(hir_id, &i.attrs);
728735
let trait_item_def_id = hir_id.expect_owner();
@@ -850,7 +857,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
850857
self.expr(span, hir::ExprKind::Err(guar))
851858
}
852859

853-
fn lower_impl_item(&mut self, i: &AssocItem, impl_constness: Const) -> &'hir hir::ImplItem<'hir> {
860+
fn lower_impl_item(
861+
&mut self,
862+
i: &AssocItem,
863+
impl_constness: Const,
864+
) -> &'hir hir::ImplItem<'hir> {
854865
// Since `default impl` is not yet implemented, this is always true in impls.
855866
let has_value = true;
856867
let (defaultness, _) = self.lower_defaultness(i.kind.defaultness(), has_value);
@@ -1304,7 +1315,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
13041315
let header = self.lower_fn_header(sig.header);
13051316
// Don't pass along the user-provided constness of trait associated functions; we don't want to
13061317
// synthesize a host effect param for them. We reject `const` on them during AST validation.
1307-
let constness = if kind == FnDeclKind::Inherent { sig.header.constness } else { parent_constness };
1318+
let constness =
1319+
if kind == FnDeclKind::Inherent { sig.header.constness } else { parent_constness };
13081320
let itctx = ImplTraitContext::Universal;
13091321
let (generics, decl) = self.lower_generics(generics, constness, id, &itctx, |this| {
13101322
this.lower_fn_decl(&sig.decl, id, sig.span, kind, coroutine_kind)

‎compiler/rustc_hir_analysis/src/astconv/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
734734
args,
735735
trait_segment.infer_args,
736736
Some(self_ty),
737-
// RIP APART THIS!!!
737+
// TODO remove this
738738
ty::BoundConstness::NotConst,
739739
);
740740

‎compiler/rustc_hir_analysis/src/bounds.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,12 @@ impl<'tcx> Bounds<'tcx> {
6868
let assoc = tcx.associated_type_for_effects(trait_ref.def_id()).unwrap();
6969
let self_ty = Ty::new_projection(tcx, assoc, trait_ref.skip_binder().args);
7070
// make `<T as Tr>::Effects: Compat<runtime>`
71-
let new_trait_ref = ty::TraitRef::new(tcx, tcx.require_lang_item(LangItem::EffectsCompat, Some(span)), [ty::GenericArg::from(self_ty), compat_val.into()]);
72-
self.clauses.push((
73-
trait_ref
74-
.rebind(new_trait_ref)
75-
.to_predicate(tcx),
76-
span,
77-
));
71+
let new_trait_ref = ty::TraitRef::new(
72+
tcx,
73+
tcx.require_lang_item(LangItem::EffectsCompat, Some(span)),
74+
[ty::GenericArg::from(self_ty), compat_val.into()],
75+
);
76+
self.clauses.push((trait_ref.rebind(new_trait_ref).to_predicate(tcx), span));
7877
}
7978
}
8079

‎compiler/rustc_middle/src/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2232,7 +2232,7 @@ impl<'tcx> TyCtxt<'tcx> {
22322232
}
22332233
}
22342234

2235-
/// If the `def_id`` is an associated type that was desugared from a
2235+
/// If the `def_id` is an associated type that was desugared from a
22362236
/// return-position `impl Trait` from a trait, then provide the source info
22372237
/// about where that RPITIT came from.
22382238
pub fn opt_rpitit_info(self, def_id: DefId) -> Option<ImplTraitInTraitData> {

0 commit comments

Comments
 (0)
Please sign in to comment.