Skip to content

Commit d4039c5

Browse files
committed
wip emit errors during AbstractConst building
1 parent 59fb88d commit d4039c5

File tree

5 files changed

+125
-80
lines changed

5 files changed

+125
-80
lines changed

compiler/rustc_metadata/src/rmeta/decoder.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use rustc_data_structures::fingerprint::{Fingerprint, FingerprintDecoder};
1111
use rustc_data_structures::fx::FxHashMap;
1212
use rustc_data_structures::svh::Svh;
1313
use rustc_data_structures::sync::{AtomicCell, Lock, LockGuard, Lrc, OnceCell};
14+
use rustc_errors::ErrorReported;
1415
use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind};
1516
use rustc_expand::proc_macro::{AttrProcMacro, BangProcMacro, ProcMacroDerive};
1617
use rustc_hir as hir;
@@ -1201,13 +1202,13 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
12011202
&self,
12021203
tcx: TyCtxt<'tcx>,
12031204
id: DefIndex,
1204-
) -> Option<&'tcx [mir::abstract_const::Node<'tcx>]> {
1205+
) -> Result<Option<&'tcx [mir::abstract_const::Node<'tcx>]>, ErrorReported> {
12051206
self.root
12061207
.tables
12071208
.mir_abstract_consts
12081209
.get(self, id)
12091210
.filter(|_| !self.is_proc_macro(id))
1210-
.map_or(None, |v| Some(v.decode((self, tcx))))
1211+
.map_or(Ok(None), |v| Ok(Some(v.decode((self, tcx)))))
12111212
}
12121213

12131214
fn get_unused_generic_params(&self, id: DefIndex) -> FiniteBitSet<u32> {

compiler/rustc_metadata/src/rmeta/encoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ impl EncodeContext<'a, 'tcx> {
11171117
}
11181118

11191119
let abstract_const = self.tcx.mir_abstract_const(def_id);
1120-
if let Some(abstract_const) = abstract_const {
1120+
if let Ok(Some(abstract_const)) = abstract_const {
11211121
record!(self.tables.mir_abstract_consts[def_id.to_def_id()] <- abstract_const);
11221122
}
11231123
}

compiler/rustc_middle/src/query/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,15 @@ rustc_queries! {
247247
/// Try to build an abstract representation of the given constant.
248248
query mir_abstract_const(
249249
key: DefId
250-
) -> Option<&'tcx [mir::abstract_const::Node<'tcx>]> {
250+
) -> Result<Option<&'tcx [mir::abstract_const::Node<'tcx>]>, ErrorReported> {
251251
desc {
252252
|tcx| "building an abstract representation for {}", tcx.def_path_str(key),
253253
}
254254
}
255255
/// Try to build an abstract representation of the given constant.
256256
query mir_abstract_const_of_const_arg(
257257
key: (LocalDefId, DefId)
258-
) -> Option<&'tcx [mir::abstract_const::Node<'tcx>]> {
258+
) -> Result<Option<&'tcx [mir::abstract_const::Node<'tcx>]>, ErrorReported> {
259259
desc {
260260
|tcx|
261261
"building an abstract representation for the const argument {}",

compiler/rustc_trait_selection/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#![feature(box_patterns)]
1616
#![feature(drain_filter)]
1717
#![feature(in_band_lifetimes)]
18+
#![feature(never_type)]
1819
#![feature(crate_visibility_modifier)]
1920
#![feature(or_patterns)]
2021
#![recursion_limit = "512"] // For rustdoc

0 commit comments

Comments
 (0)