Skip to content

Commit 83fa4f6

Browse files
committed
Address more review comments.
1 parent 25a83b4 commit 83fa4f6

File tree

7 files changed

+20
-18
lines changed

7 files changed

+20
-18
lines changed

compiler/rustc_hir_analysis/src/check/wfcheck.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,6 @@ fn check_type_defn<'tcx>(
10871087
packed && {
10881088
let ty = tcx.type_of(variant.tail().did).instantiate_identity();
10891089
let ty = tcx.erase_regions(ty);
1090-
assert!(!ty.has_infer());
10911090
ty.needs_drop(tcx, tcx.param_env(item.owner_id))
10921091
}
10931092
};

compiler/rustc_hir_typeck/src/intrinsicck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
5151
// Note: this path is currently not reached in any test, so any
5252
// example that triggers this would be worth minimizing and
5353
// converting into a test.
54-
tcx.dcx().span_delayed_bug(span, "argument to transmute has inference variables");
54+
tcx.dcx().span_bug(span, "argument to transmute has inference variables");
5555
}
5656
// Transmutes that are only changing lifetimes are always ok.
5757
if from == to {

compiler/rustc_middle/src/util/bug.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn opt_span_bug_fmt<S: Into<MultiSpan>>(
4242
/// delayed bug, so what is the point of this? It exists to help us test the interaction of delayed
4343
/// bugs with the query system and incremental.
4444
pub fn trigger_delayed_bug(tcx: TyCtxt<'_>, key: rustc_hir::def_id::DefId) {
45-
tcx.dcx().span_bug(
45+
tcx.dcx().span_delayed_bug(
4646
tcx.def_span(key),
4747
"delayed bug triggered by #[rustc_error(delayed_bug_from_inside_query)]",
4848
);

compiler/rustc_mir_build/src/build/expr/as_constant.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,12 @@ fn lit_to_mir_constant<'tcx>(
110110
let LitToConstInput { lit, ty, neg } = lit_input;
111111
let trunc = |n| {
112112
let param_ty = ty::ParamEnv::reveal_all().and(ty);
113-
let width = tcx
114-
.layout_of(param_ty)
115-
.expect(&format!("couldn't compute width of literal: {:?}", lit_input.lit))
116-
.size;
113+
let width = match tcx.layout_of(param_ty) {
114+
Ok(layout) => layout.size,
115+
Err(_) => {
116+
tcx.dcx().bug(format!("couldn't compute width of literal: {:?}", lit_input.lit))
117+
}
118+
};
117119
trace!("trunc {} with size {} and shift {}", n, width.bits(), 128 - width.bits());
118120
let result = width.truncate(n);
119121
trace!("trunc result: {}", result);

compiler/rustc_mir_build/src/thir/constant.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ pub(crate) fn lit_to_const<'tcx>(
1212

1313
let trunc = |n| {
1414
let param_ty = ParamEnv::reveal_all().and(ty);
15-
let width = tcx
16-
.layout_of(param_ty)
17-
.expect(&format!("couldn't compute width of literal: {:?}", lit_input.lit))
18-
.size;
15+
let width = match tcx.layout_of(param_ty) {
16+
Ok(layout) => layout.size,
17+
Err(_) => {
18+
tcx.dcx().bug(format!("couldn't compute width of literal: {:?}", lit_input.lit))
19+
}
20+
};
1921
trace!("trunc {} with size {} and shift {}", n, width.bits(), 128 - width.bits());
2022
let result = width.truncate(n);
2123
trace!("trunc result: {}", result);

compiler/rustc_resolve/src/late.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3681,9 +3681,9 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
36813681
None
36823682
}
36833683
Res::SelfCtor(_) => {
3684-
// njn: remove comment?
36853684
// We resolve `Self` in pattern position as an ident sometimes during recovery,
3686-
// so delay a bug instead of ICEing.
3685+
// so delay a bug instead of ICEing. (Note: is this no longer true? We now ICE. If
3686+
// this triggers, please convert to a delayed bug and add a test.)
36873687
self.r.dcx().span_bug(
36883688
ident.span,
36893689
"unexpected `SelfCtor` in pattern, expected identifier"

compiler/rustc_trait_selection/src/traits/const_evaluatable.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,10 @@ pub fn is_const_evaluatable<'tcx>(
6262

6363
match unexpanded_ct.kind() {
6464
ty::ConstKind::Expr(_) => {
65-
// njn: ?
66-
// FIXME(generic_const_exprs): we have a `ConstKind::Expr` which is fully concrete,
67-
// but currently it is not possible to evaluate `ConstKind::Expr` so we are unable
68-
// to tell if it is evaluatable or not. For now we just ICE until this is
69-
// implemented.
65+
// FIXME(generic_const_exprs): we have a fully concrete `ConstKind::Expr`, but
66+
// haven't implemented evaluating `ConstKind::Expr` yet, so we are unable to tell
67+
// if it is evaluatable or not. As this is unreachable for now, we can simple ICE
68+
// here.
7069
tcx.dcx().span_bug(span, "evaluating `ConstKind::Expr` is not currently supported");
7170
}
7271
ty::ConstKind::Unevaluated(uv) => {

0 commit comments

Comments
 (0)