Skip to content

Commit 41f8315

Browse files
committed
Fix tools
1 parent 7716845 commit 41f8315

File tree

7 files changed

+26
-9
lines changed

7 files changed

+26
-9
lines changed

compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
130130
return;
131131
}
132132

133-
let idx = generic_args[2].expect_const().to_value().valtree.unwrap_branch();
133+
let idx = generic_args[2].expect_const().to_branch();
134134

135135
assert_eq!(x.layout(), y.layout());
136136
let layout = x.layout();

src/librustdoc/clean/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,9 @@ pub(crate) fn clean_const<'tcx>(constant: &hir::ConstArg<'tcx>) -> ConstantKind
319319
hir::ConstArgKind::Path(qpath) => {
320320
ConstantKind::Path { path: qpath_to_string(qpath).into() }
321321
}
322+
hir::ConstArgKind::Struct(..) => {
323+
ConstantKind::Path { path: "/* STRUCT EXPR */".to_string().into() }
324+
}
322325
hir::ConstArgKind::Anon(anon) => ConstantKind::Anonymous { body: anon.body },
323326
hir::ConstArgKind::Infer(..) | hir::ConstArgKind::Error(..) => ConstantKind::Infer,
324327
}
@@ -1800,7 +1803,7 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
18001803
let ct = cx.tcx.normalize_erasing_regions(typing_env, ct);
18011804
print_const(cx, ct)
18021805
}
1803-
hir::ConstArgKind::Path(..) => {
1806+
hir::ConstArgKind::Struct(..) | hir::ConstArgKind::Path(..) => {
18041807
let ct = lower_const_arg_for_rustdoc(cx.tcx, const_arg, FeedConstTy::No);
18051808
print_const(cx, ct)
18061809
}

src/librustdoc/clean/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ pub(crate) fn print_const(cx: &DocContext<'_>, n: ty::Const<'_>) -> String {
357357
}
358358
// array lengths are obviously usize
359359
ty::ConstKind::Value(cv) if *cv.ty.kind() == ty::Uint(ty::UintTy::Usize) => {
360-
cv.valtree.unwrap_leaf().to_string()
360+
cv.to_leaf().to_string()
361361
}
362362
_ => n.to_string(),
363363
}

src/tools/clippy/clippy_lints/src/utils/author.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
319319
chain!(self, "let ConstArgKind::Anon({anon_const}) = {const_arg}.kind");
320320
self.body(field!(anon_const.body));
321321
},
322+
ConstArgKind::Struct(..) => chain!(self, "let ConstArgKind::Struct(..) = {const_arg}.kind"),
322323
ConstArgKind::Infer(..) => chain!(self, "let ConstArgKind::Infer(..) = {const_arg}.kind"),
323324
ConstArgKind::Error(..) => chain!(self, "let ConstArgKind::Error(..) = {const_arg}.kind"),
324325
}

src/tools/clippy/clippy_utils/src/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ pub fn const_item_rhs_to_expr<'tcx>(tcx: TyCtxt<'tcx>, ct_rhs: ConstItemRhs<'tcx
11391139
ConstItemRhs::Body(body_id) => Some(tcx.hir_body(body_id).value),
11401140
ConstItemRhs::TypeConst(const_arg) => match const_arg.kind {
11411141
ConstArgKind::Anon(anon) => Some(tcx.hir_body(anon.body).value),
1142-
ConstArgKind::Path(_) | ConstArgKind::Error(..) | ConstArgKind::Infer(..) => None,
1142+
ConstArgKind::Struct(..) | ConstArgKind::Path(_) | ConstArgKind::Error(..) | ConstArgKind::Infer(..) => None,
11431143
},
11441144
}
11451145
}

src/tools/clippy/clippy_utils/src/hir_utils.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,11 +477,18 @@ impl HirEqInterExpr<'_, '_, '_> {
477477
(ConstArgKind::Path(l_p), ConstArgKind::Path(r_p)) => self.eq_qpath(l_p, r_p),
478478
(ConstArgKind::Anon(l_an), ConstArgKind::Anon(r_an)) => self.eq_body(l_an.body, r_an.body),
479479
(ConstArgKind::Infer(..), ConstArgKind::Infer(..)) => true,
480+
(ConstArgKind::Struct(path_a, inits_a), ConstArgKind::Struct(path_b, inits_b)) => {
481+
self.eq_qpath(path_a, path_b)
482+
&& inits_a.iter().zip(*inits_b).all(|(init_a, init_b)| {
483+
self.eq_const_arg(init_a.expr, init_b.expr)
484+
})
485+
}
480486
// Use explicit match for now since ConstArg is undergoing flux.
481-
(ConstArgKind::Path(..), ConstArgKind::Anon(..))
482-
| (ConstArgKind::Anon(..), ConstArgKind::Path(..))
483-
| (ConstArgKind::Infer(..) | ConstArgKind::Error(..), _)
484-
| (_, ConstArgKind::Infer(..) | ConstArgKind::Error(..)) => false,
487+
(ConstArgKind::Path(..), _)
488+
| (ConstArgKind::Anon(..), _)
489+
| (ConstArgKind::Infer(..), _)
490+
| (ConstArgKind::Struct(..), _)
491+
| (ConstArgKind::Error(..), _) => false,
485492
}
486493
}
487494

@@ -1332,6 +1339,12 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
13321339
match &const_arg.kind {
13331340
ConstArgKind::Path(path) => self.hash_qpath(path),
13341341
ConstArgKind::Anon(anon) => self.hash_body(anon.body),
1342+
ConstArgKind::Struct(path, inits) => {
1343+
self.hash_qpath(path);
1344+
for init in *inits {
1345+
self.hash_const_arg(init.expr);
1346+
}
1347+
}
13351348
ConstArgKind::Infer(..) | ConstArgKind::Error(..) => {},
13361349
}
13371350
}

src/tools/miri/src/intrinsics/atomic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
3131

3232
let get_ord_at = |i: usize| {
3333
let ordering = generic_args.const_at(i).to_value();
34-
ordering.valtree.unwrap_branch()[0].unwrap_leaf().to_atomic_ordering()
34+
ordering.to_branch()[0].to_value().to_leaf().to_atomic_ordering()
3535
};
3636

3737
fn read_ord(ord: AtomicOrdering) -> AtomicReadOrd {

0 commit comments

Comments
 (0)