Skip to content

Commit 002cfdb

Browse files
committed
Fix new ? inference errors in librustc
1 parent 4c44226 commit 002cfdb

File tree

9 files changed

+24
-20
lines changed

9 files changed

+24
-20
lines changed

src/librustc/dep_graph/dep_node.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ impl fmt::Debug for DepNode {
370370

371371
write!(f, "(")?;
372372

373-
crate::ty::tls::with_opt(|opt_tcx| {
373+
crate::ty::tls::with_opt(|opt_tcx| -> fmt::Result {
374374
if let Some(tcx) = opt_tcx {
375375
if let Some(def_id) = self.extract_def_id(tcx) {
376376
write!(f, "{}", tcx.def_path_debug_str(def_id))?;

src/librustc/hir/def_id.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl fmt::Debug for DefId {
171171
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
172172
write!(f, "DefId({}:{}", self.krate, self.index.as_array_index())?;
173173

174-
ty::tls::with_opt(|opt_tcx| {
174+
ty::tls::with_opt(|opt_tcx| -> fmt::Result {
175175
if let Some(tcx) = opt_tcx {
176176
write!(f, " ~ {}", tcx.def_path_debug_str(*self))?;
177177
}

src/librustc/infer/unify_key.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ impl<'tcx> UnifyValue for ConstVarValue<'tcx> {
139139

140140
// If one side is known, prefer that one.
141141
(ConstVariableValue::Known { .. }, ConstVariableValue::Unknown { .. }) => {
142-
Ok(value1.val)
142+
value1.val
143143
}
144144
(ConstVariableValue::Unknown { .. }, ConstVariableValue::Known { .. }) => {
145-
Ok(value2.val)
145+
value2.val
146146
}
147147

148148
// If both sides are *unknown*, it hardly matters, does it?
@@ -154,9 +154,9 @@ impl<'tcx> UnifyValue for ConstVarValue<'tcx> {
154154
// universe is the minimum of the two universes, because that is
155155
// the one which contains the fewest names in scope.
156156
let universe = cmp::min(universe1, universe2);
157-
Ok(ConstVariableValue::Unknown { universe })
157+
ConstVariableValue::Unknown { universe }
158158
}
159-
}?;
159+
};
160160

161161
Ok(ConstVarValue {
162162
origin: ConstVariableOrigin::ConstInference(DUMMY_SP),

src/librustc/mir/interpret/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl<'s> AllocDecodingSession<'s> {
159159

160160
// Decode the AllocDiscriminant now so that we know if we have to reserve an
161161
// AllocId.
162-
let (alloc_kind, pos) = decoder.with_position(pos, |decoder| {
162+
let (alloc_kind, pos) = decoder.with_position(pos, |decoder| -> Result<_, D::Error> {
163163
let alloc_kind = AllocDiscriminant::decode(decoder)?;
164164
Ok((alloc_kind, decoder.position()))
165165
})?;
@@ -217,7 +217,7 @@ impl<'s> AllocDecodingSession<'s> {
217217
};
218218

219219
// Now decode the actual data
220-
let alloc_id = decoder.with_position(pos, |decoder| {
220+
let alloc_id = decoder.with_position(pos, |decoder| -> Result<_, D::Error> {
221221
match alloc_kind {
222222
AllocDiscriminant::Alloc => {
223223
let allocation = <&'tcx Allocation as Decodable>::decode(decoder)?;

src/librustc/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2543,7 +2543,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
25432543
let variant_def = &adt_def.variants[variant];
25442544

25452545
let f = &mut *fmt;
2546-
ty::tls::with(|tcx| {
2546+
ty::tls::with(|tcx| -> fmt::Result {
25472547
let substs = tcx.lift(&substs).expect("could not lift for printing");
25482548
FmtPrinter::new(tcx, f, Namespace::ValueNS)
25492549
.print_def_path(variant_def.def_id, substs)?;

src/librustc/ty/codec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ pub fn decode_predicates<'a, 'tcx, D>(decoder: &mut D)
201201
}?;
202202
Ok((predicate, Decodable::decode(decoder)?))
203203
})
204-
.collect::<Result<Vec<_>, _>>()?,
204+
.collect::<Result<Vec<_>, D::Error>>()?,
205205
})
206206
}
207207

src/librustc/ty/instance.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ impl<'tcx> InstanceDef<'tcx> {
174174

175175
impl<'tcx> fmt::Display for Instance<'tcx> {
176176
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
177-
ty::tls::with(|tcx| {
177+
ty::tls::with(|tcx| -> fmt::Result {
178178
let substs = tcx.lift(&self.substs).expect("could not lift for printing");
179179
FmtPrinter::new(tcx, &mut *f, Namespace::ValueNS)
180180
.print_def_path(self.def_id(), substs)?;

src/librustc/ty/layout.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,10 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
249249
Prefixed(Size, Align),
250250
}
251251

252-
let univariant_uninterned = |fields: &[TyLayout<'_>], repr: &ReprOptions, kind| {
252+
let univariant_uninterned = |fields: &[TyLayout<'_>],
253+
repr: &ReprOptions,
254+
kind|
255+
-> Result<_, LayoutError<'tcx>> {
253256
let packed = repr.packed();
254257
if packed && repr.align > 0 {
255258
bug!("struct cannot be packed and aligned");
@@ -458,9 +461,10 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
458461
size
459462
})
460463
};
461-
let univariant = |fields: &[TyLayout<'_>], repr: &ReprOptions, kind| {
462-
Ok(tcx.intern_layout(univariant_uninterned(fields, repr, kind)?))
463-
};
464+
let univariant =
465+
|fields: &[TyLayout<'_>], repr: &ReprOptions, kind| -> Result<_, LayoutError<'tcx>> {
466+
Ok(tcx.intern_layout(univariant_uninterned(fields, repr, kind)?))
467+
};
464468
debug_assert!(!ty.has_infer_types());
465469

466470
Ok(match ty.sty {
@@ -635,7 +639,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
635639
align = align.max(variant.align);
636640

637641
Ok(variant)
638-
}).collect::<Result<IndexVec<VariantIdx, _>, _>>()?;
642+
}).collect::<Result<IndexVec<VariantIdx, _>, LayoutError<'tcx>>>()?;
639643

640644
let abi = if prefix.abi.is_uninhabited() ||
641645
variants.iter().all(|v| v.abi.is_uninhabited()) {
@@ -933,7 +937,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
933937
align = align.max(st.align);
934938

935939
Ok(st)
936-
}).collect::<Result<IndexVec<VariantIdx, _>, _>>()?;
940+
}).collect::<Result<IndexVec<VariantIdx, _>, LayoutError<'tcx>>>()?;
937941

938942
let offset = st[i].fields.offset(field_index) + niche.offset;
939943
let size = st[i].size;
@@ -1048,7 +1052,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
10481052
size = cmp::max(size, st.size);
10491053
align = align.max(st.align);
10501054
Ok(st)
1051-
}).collect::<Result<IndexVec<VariantIdx, _>, _>>()?;
1055+
}).collect::<Result<IndexVec<VariantIdx, _>, LayoutError<'tcx>>>()?;
10521056

10531057
// Align the maximum variant size to the largest alignment.
10541058
size = size.align_to(align.abi);

src/librustc/ty/query/on_disk_cache.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl<'sess> OnDiskCache<'sess> {
202202
// Encode query results
203203
let mut query_result_index = EncodedQueryResultIndex::new();
204204

205-
time(tcx.sess, "encode query results", || {
205+
time(tcx.sess, "encode query results", || -> Result<_, E::Error> {
206206
use crate::ty::query::queries::*;
207207
let enc = &mut encoder;
208208
let qri = &mut query_result_index;
@@ -260,7 +260,7 @@ impl<'sess> OnDiskCache<'sess> {
260260

261261
Ok((dep_node_index, pos))
262262
})
263-
.collect::<Result<_, _>>()?;
263+
.collect::<Result<_, E::Error>>()?;
264264

265265
let interpret_alloc_index = {
266266
let mut interpret_alloc_index = Vec::new();

0 commit comments

Comments
 (0)