Skip to content

Commit 07003a4

Browse files
committed
fix todo remnants
1 parent aedd3c4 commit 07003a4

File tree

2 files changed

+12
-39
lines changed

2 files changed

+12
-39
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,8 +675,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
675675
args,
676676
trait_segment.infer_args,
677677
Some(self_ty),
678-
// TODO remove this
679-
ty::BoundConstness::NotConst,
678+
constness,
680679
);
681680

682681
let tcx = self.tcx();

compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,45 +1521,19 @@ fn impl_trait_header(
15211521
let icx = ItemCtxt::new(tcx, def_id);
15221522
let item = tcx.hir().expect_item(def_id);
15231523
let impl_ = item.expect_impl();
1524-
impl_
1525-
.of_trait
1526-
.as_ref()
1527-
.map(|ast_trait_ref| {
1528-
let selfty = tcx.type_of(def_id).instantiate_identity();
1524+
impl_.of_trait.as_ref().map(|ast_trait_ref| {
1525+
let selfty = tcx.type_of(def_id).instantiate_identity();
15291526

1530-
let trait_ref = if let Some(ErrorGuaranteed { .. }) = check_impl_constness(
1531-
tcx,
1532-
tcx.is_const_trait_impl_raw(def_id.to_def_id()),
1533-
ast_trait_ref,
1534-
) {
1535-
// TODO this is wrong
1536-
// we have a const impl, but for a trait without `#[const_trait]`, so
1537-
// without the host param. If we continue with the HIR trait ref, we get
1538-
// ICEs for generic arg count mismatch. We do a little HIR editing to
1539-
// make astconv happy.
1540-
let mut path_segments = ast_trait_ref.path.segments.to_vec();
1541-
let last_segment = path_segments.len() - 1;
1542-
let mut args = *path_segments[last_segment].args();
1543-
let last_arg = args.args.len() - 1;
1544-
assert!(matches!(args.args[last_arg], hir::GenericArg::Const(anon_const) if anon_const.is_desugared_from_effects));
1545-
args.args = &args.args[..args.args.len() - 1];
1546-
path_segments[last_segment].args = Some(tcx.hir_arena.alloc(args));
1547-
let path = hir::Path {
1548-
span: ast_trait_ref.path.span,
1549-
res: ast_trait_ref.path.res,
1550-
segments: tcx.hir_arena.alloc_slice(&path_segments),
1551-
};
1552-
let trait_ref = tcx.hir_arena.alloc(hir::TraitRef { path: tcx.hir_arena.alloc(path), hir_ref_id: ast_trait_ref.hir_ref_id });
1553-
icx.astconv().instantiate_mono_trait_ref(trait_ref, selfty)
1554-
} else {
1555-
icx.astconv().instantiate_mono_trait_ref(ast_trait_ref, selfty)
1556-
};
1557-
ty::EarlyBinder::bind(ty::ImplTraitHeader {
1558-
trait_ref,
1559-
unsafety: impl_.unsafety,
1560-
polarity: polarity_of_impl(tcx, def_id, impl_, item.span)
1561-
})
1527+
check_impl_constness(tcx, tcx.is_const_trait_impl_raw(def_id.to_def_id()), ast_trait_ref);
1528+
1529+
let trait_ref = icx.astconv().instantiate_mono_trait_ref(ast_trait_ref, selfty);
1530+
1531+
ty::EarlyBinder::bind(ty::ImplTraitHeader {
1532+
trait_ref,
1533+
unsafety: impl_.unsafety,
1534+
polarity: polarity_of_impl(tcx, def_id, impl_, item.span),
15621535
})
1536+
})
15631537
}
15641538

15651539
fn check_impl_constness(

0 commit comments

Comments
 (0)