Skip to content

Commit c711b19

Browse files
authored
Merge pull request #735 from Nadrieril/update-rustc-madness
Update rustc all at once
2 parents a4ea5b7 + a9adabf commit c711b19

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+524
-539
lines changed

cli/driver/src/callbacks_wrapper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub struct CallbacksWrapper<'a> {
1414
impl<'a> Callbacks for CallbacksWrapper<'a> {
1515
fn config(&mut self, config: &mut interface::Config) {
1616
let options = self.options.clone();
17-
config.parse_sess_created = Some(Box::new(move |parse_sess| {
17+
config.psess_created = Some(Box::new(move |parse_sess| {
1818
parse_sess.env_depinfo.get_mut().insert((
1919
Symbol::intern(hax_cli_options::ENV_VAR_OPTIONS_FRONTEND),
2020
Some(Symbol::intern(&serde_json::to_string(&options).unwrap())),

cli/driver/src/driver.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ fn setup_logging() {
6565
};
6666
let subscriber = tracing_subscriber::Registry::default()
6767
.with(tracing_subscriber::EnvFilter::from_default_env())
68+
.with(
69+
tracing_subscriber::fmt::layer()
70+
.with_file(true)
71+
.with_line_number(true),
72+
)
6873
.with(
6974
tracing_tree::HierarchicalLayer::new(2)
7075
.with_ansi(enable_colors)

cli/driver/src/exporter.rs

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,26 @@ use rustc_middle::{
1111
thir,
1212
thir::{Block, BlockId, Expr, ExprId, ExprKind, Pat, PatKind, Stmt, StmtId, StmtKind, Thir},
1313
};
14-
use rustc_session::parse::ParseSess;
1514
use rustc_span::symbol::Symbol;
1615
use serde::Serialize;
1716
use std::cell::RefCell;
1817
use std::collections::{HashMap, HashSet};
1918
use std::rc::Rc;
2019

2120
fn report_diagnostics(
21+
tcx: TyCtxt<'_>,
2222
output: &hax_cli_options_engine::Output,
23-
session: &rustc_session::Session,
2423
mapping: &Vec<(hax_frontend_exporter::Span, rustc_span::Span)>,
2524
) {
2625
for d in &output.diagnostics {
2726
use hax_diagnostics::*;
28-
session.span_hax_err(d.convert(mapping).into());
27+
tcx.dcx().span_hax_err(d.convert(mapping).into());
2928
}
3029
}
3130

3231
fn write_files(
32+
tcx: TyCtxt<'_>,
3333
output: &hax_cli_options_engine::Output,
34-
session: &rustc_session::Session,
3534
backend: hax_cli_options::Backend,
3635
) {
3736
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
@@ -43,9 +42,9 @@ fn write_files(
4342
for file in output.files.clone() {
4443
let path = out_dir.join(&file.path);
4544
std::fs::create_dir_all(&path.parent().unwrap()).unwrap();
46-
session.note_without_error(format!("Writing file {:#?}", path));
45+
tcx.dcx().note(format!("Writing file {:#?}", path));
4746
std::fs::write(&path, file.contents).unwrap_or_else(|e| {
48-
session.fatal(format!(
47+
tcx.dcx().fatal(format!(
4948
"Unable to write to file {:#?}. Error: {:#?}",
5049
path, e
5150
))
@@ -55,17 +54,21 @@ fn write_files(
5554

5655
type ThirBundle<'tcx> = (Rc<rustc_middle::thir::Thir<'tcx>>, ExprId);
5756
/// Generates a dummy THIR body with an error literal as first expression
58-
fn dummy_thir_body<'tcx>(tcx: TyCtxt<'tcx>, span: rustc_span::Span) -> ThirBundle<'tcx> {
57+
fn dummy_thir_body<'tcx>(
58+
tcx: TyCtxt<'tcx>,
59+
span: rustc_span::Span,
60+
guar: rustc_errors::ErrorGuaranteed,
61+
) -> ThirBundle<'tcx> {
5962
use rustc_middle::thir::*;
6063
let ty = tcx.mk_ty_from_kind(rustc_type_ir::TyKind::Never);
6164
let mut thir = Thir::new(BodyTy::Const(ty));
62-
const ERR_LITERAL: &'static rustc_hir::Lit = &rustc_span::source_map::Spanned {
63-
node: rustc_ast::ast::LitKind::Err,
65+
let lit_err = tcx.hir_arena.alloc(rustc_span::source_map::Spanned {
66+
node: rustc_ast::ast::LitKind::Err(guar),
6467
span: rustc_span::DUMMY_SP,
65-
};
68+
});
6669
let expr = thir.exprs.push(Expr {
6770
kind: ExprKind::Literal {
68-
lit: ERR_LITERAL,
71+
lit: lit_err,
6972
neg: false,
7073
},
7174
ty,
@@ -127,24 +130,24 @@ fn precompute_local_thir_bodies<'tcx>(
127130
.filter(|ldid| hir.maybe_body_owned_by(*ldid).is_some())
128131
.map(|ldid| {
129132
tracing::debug!("⏳ Type-checking THIR body for {:#?}", ldid);
130-
let span = hir.span(hir.local_def_id_to_hir_id(ldid));
133+
let span = hir.span(tcx.local_def_id_to_hir_id(ldid));
131134
let (thir, expr) = match tcx.thir_body(ldid) {
132135
Ok(x) => x,
133136
Err(e) => {
134-
tcx.sess.span_err(
137+
let guar = tcx.dcx().span_err(
135138
span,
136139
"While trying to reach a body's THIR defintion, got a typechecking error.",
137140
);
138-
return (ldid, dummy_thir_body(tcx, span));
141+
return (ldid, dummy_thir_body(tcx, span, guar));
139142
}
140143
};
141144
let thir = match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
142145
thir.borrow().clone()
143146
})) {
144147
Ok(x) => x,
145148
Err(e) => {
146-
tcx.sess.span_err(span, format!("The THIR body of item {:?} was stolen.\nThis is not supposed to happen.\nThis is a bug in Hax's frontend.\nThis is discussed in issue https://github.com/hacspec/hax/issues/27.\nPlease comment this issue if you see this error message!", ldid));
147-
return (ldid, dummy_thir_body(tcx, span));
149+
let guar = tcx.dcx().span_err(span, format!("The THIR body of item {:?} was stolen.\nThis is not supposed to happen.\nThis is a bug in Hax's frontend.\nThis is discussed in issue https://github.com/hacspec/hax/issues/27.\nPlease comment this issue if you see this error message!", ldid));
150+
return (ldid, dummy_thir_body(tcx, span, guar));
148151
}
149152
};
150153
tracing::debug!("✅ Type-checked THIR body for {:#?}", ldid);
@@ -298,7 +301,7 @@ impl Callbacks for ExtractionCallbacks {
298301
.into_iter()
299302
.map(|(k, v)| {
300303
use hax_frontend_exporter::*;
301-
let sess = compiler.session();
304+
let sess = &compiler.sess;
302305
(
303306
translate_span(k, sess),
304307
translate_span(argument_span_of_mac_call(&v), sess),
@@ -362,29 +365,19 @@ impl Callbacks for ExtractionCallbacks {
362365
include_extra,
363366
};
364367
mod from {
365-
pub use hax_cli_options::ExportBodyKind::{
366-
MirBuilt as MB, MirConst as MC, Thir as T,
367-
};
368+
pub use hax_cli_options::ExportBodyKind::{MirBuilt as MB, Thir as T};
368369
}
369370
mod to {
370371
pub type T = hax_frontend_exporter::ThirBody;
371372
pub type MB =
372373
hax_frontend_exporter::MirBody<hax_frontend_exporter::mir_kinds::Built>;
373-
pub type MC =
374-
hax_frontend_exporter::MirBody<hax_frontend_exporter::mir_kinds::Const>;
375374
}
376375
kind.sort();
377376
kind.dedup();
378377
match kind.as_slice() {
379378
[from::MB] => driver.to_json::<to::MB>(),
380-
[from::MC] => driver.to_json::<to::MC>(),
381379
[from::T] => driver.to_json::<to::T>(),
382-
[from::MB, from::MC] => driver.to_json::<(to::MB, to::MC)>(),
383380
[from::T, from::MB] => driver.to_json::<(to::MB, to::T)>(),
384-
[from::T, from::MC] => driver.to_json::<(to::MC, to::T)>(),
385-
[from::T, from::MB, from::MC] => {
386-
driver.to_json::<(to::MB, (to::MC, to::T))>()
387-
}
388381
[] => driver.to_json::<()>(),
389382
_ => panic!("Unsupported kind {:#?}", kind),
390383
}
@@ -432,9 +425,8 @@ impl Callbacks for ExtractionCallbacks {
432425
.unwrap();
433426

434427
let out = engine_subprocess.wait_with_output().unwrap();
435-
let session = compiler.session();
436428
if !out.status.success() {
437-
session.fatal(format!(
429+
tcx.dcx().fatal(format!(
438430
"{} exited with non-zero code {}\nstdout: {}\n stderr: {}",
439431
ENGINE_BINARY_NAME,
440432
out.status.code().unwrap_or(-1),
@@ -456,8 +448,8 @@ impl Callbacks for ExtractionCallbacks {
456448
let state =
457449
hax_frontend_exporter::state::State::new(tcx, options_frontend.clone());
458450
report_diagnostics(
451+
tcx,
459452
&output,
460-
&session,
461453
&spans
462454
.into_iter()
463455
.map(|span| (span.sinto(&state), span.clone()))
@@ -467,7 +459,7 @@ impl Callbacks for ExtractionCallbacks {
467459
serde_json::to_writer(std::io::BufWriter::new(std::io::stdout()), &output)
468460
.unwrap()
469461
} else {
470-
write_files(&output, &session, backend.backend);
462+
write_files(tcx, &output, backend.backend);
471463
}
472464
if let Some(debug_json) = &output.debug_json {
473465
use hax_cli_options::DebugEngineMode;

cli/driver/src/linter.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ impl Callbacks for LinterCallbacks {
2828
compiler: &Compiler,
2929
queries: &'tcx Queries<'tcx>,
3030
) -> Compilation {
31-
let session = compiler.session();
3231
queries
3332
.global_ctxt()
3433
.unwrap()
35-
.enter(|tcx| hax_lint::Linter::register(tcx, session, self.ltype));
34+
.enter(|tcx| hax_lint::Linter::register(tcx, self.ltype));
3635

3736
Compilation::Continue
3837
}

cli/options/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ pub enum ExporterCommand {
370370
pub enum ExportBodyKind {
371371
Thir,
372372
MirBuilt,
373-
MirConst,
374373
}
375374

376375
#[derive(JsonSchema, Subcommand, Debug, Clone, Serialize, Deserialize)]

engine/lib/ast.ml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,14 @@ let show_int_kind { size; signedness } =
7878
|> Option.map ~f:Int.to_string
7979
|> Option.value ~default:"size")
8080

81-
type float_kind = F32 | F64 [@@deriving show, yojson, hash, compare, eq]
81+
type float_kind = F16 | F32 | F64 | F128
82+
[@@deriving show, yojson, hash, compare, eq]
8283

83-
let show_float_kind = function F32 -> "f32" | F64 -> "f64"
84+
let show_float_kind = function
85+
| F16 -> "f16"
86+
| F32 -> "f32"
87+
| F64 -> "f64"
88+
| F128 -> "f128"
8489

8590
type literal =
8691
| String of string

engine/lib/concrete_ident/concrete_ident.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ module Imported = struct
1515
| ForeignMod
1616
| Use
1717
| GlobalAsm
18-
| ClosureExpr
18+
| Closure
1919
| Ctor
2020
| AnonConst
21-
| ImplTrait
22-
| ImplTraitAssocTy
21+
| AnonAdt
22+
| OpaqueTy
2323
| TypeNs of string
2424
| ValueNs of string
2525
| MacroNs of string
@@ -32,15 +32,15 @@ module Imported = struct
3232
| ForeignMod -> ForeignMod
3333
| Use -> Use
3434
| GlobalAsm -> GlobalAsm
35-
| ClosureExpr -> ClosureExpr
35+
| Closure -> Closure
3636
| Ctor -> Ctor
3737
| AnonConst -> AnonConst
38-
| ImplTrait -> ImplTrait
39-
| ImplTraitAssocTy -> ImplTraitAssocTy
38+
| OpaqueTy -> OpaqueTy
4039
| TypeNs s -> TypeNs s
4140
| ValueNs s -> ValueNs s
4241
| MacroNs s -> MacroNs s
4342
| LifetimeNs s -> LifetimeNs s
43+
| AnonAdt -> AnonAdt
4444

4545
let of_disambiguated_def_path_item :
4646
Types.disambiguated_def_path_item -> disambiguated_def_path_item =

engine/lib/generic_printer/generic_printer.ml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ module Make (F : Features.T) (View : Concrete_ident.VIEW_API) = struct
6666
| Float { value; kind; negative } ->
6767
string value
6868
|> precede (if negative then minus else empty)
69-
|> terminate
70-
(string (match kind with F32 -> "f32" | F64 -> "f64"))
69+
|> terminate (string (show_float_kind kind))
7170
| Bool b -> OCaml.bool b
7271

7372
method generic_value : generic_value fn =
@@ -101,8 +100,7 @@ module Make (F : Features.T) (View : Concrete_ident.VIEW_API) = struct
101100
in
102101
string signedness ^^ size
103102

104-
method ty_float : float_kind fn =
105-
(function F32 -> "f32" | F64 -> "f64") >> string
103+
method ty_float : float_kind fn = show_float_kind >> string
106104

107105
method generic_values : generic_value list fn =
108106
function

0 commit comments

Comments
 (0)