Skip to content

Commit bdd1233

Browse files
authored
Merge pull request #687 from Nadrieril/update-rustc
Bump rustc version
2 parents 19d23b2 + 7bdba90 commit bdd1233

File tree

11 files changed

+142
-165
lines changed

11 files changed

+142
-165
lines changed

cli/driver/src/callbacks_wrapper.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ impl<'a> Callbacks for CallbacksWrapper<'a> {
3838
}
3939
fn after_analysis<'tcx>(
4040
&mut self,
41+
early_handler: &rustc_session::EarlyErrorHandler,
4142
compiler: &interface::Compiler,
4243
queries: &'tcx Queries<'tcx>,
4344
) -> Compilation {
44-
self.sub.after_analysis(compiler, queries)
45+
self.sub.after_analysis(early_handler, compiler, queries)
4546
}
4647
}

engine/hax-engine.opam

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ build: [
6060
dev-repo: "git+https://github.com/hacspec/hax.git"
6161
depexts: [
6262
["nodejs"] {}
63-
]
63+
]

engine/lib/import_thir.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ end) : EXPR = struct
480480
(U.call Rust_primitives__hax__never_to_any [ c_expr source ] span typ)
481481
.e
482482
(* TODO: this is incorrect (NeverToAny) *)
483-
| Pointer { cast; source } -> c_pointer e typ span cast source
483+
| PointerCoercion { cast; source } -> c_pointer e typ span cast source
484484
| Loop { body } ->
485485
let body = c_expr body in
486486
Loop
@@ -907,7 +907,7 @@ end) : EXPR = struct
907907
(* ^ [%show: expr] source)) *)
908908
| _ ->
909909
unimplemented [ e.span ]
910-
("Pointer, with [cast] being " ^ [%show: Thir.pointer_cast] cast)
910+
("Pointer, with [cast] being " ^ [%show: Thir.pointer_coercion] cast)
911911

912912
and c_ty (span : Thir.span) (ty : Thir.ty) : ty =
913913
match ty with

frontend/exporter/src/constant_utils.rs

+16-35
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,14 @@ pub(crate) fn is_anon_const<'tcx>(
305305
fn trait_const_to_constant_expr_kind<'tcx, S: BaseState<'tcx> + HasOwnerId>(
306306
s: &S,
307307
_const_def_id: rustc_hir::def_id::DefId,
308-
substs: rustc_middle::ty::SubstsRef<'tcx>,
308+
generics: rustc_middle::ty::GenericArgsRef<'tcx>,
309309
assoc: &rustc_middle::ty::AssocItem,
310310
) -> ConstantExprKind {
311311
assert!(assoc.trait_item_def_id.is_some());
312312
let name = assoc.name.to_string();
313313

314314
// Retrieve the trait information
315-
let impl_expr = get_trait_info(s, substs, assoc);
315+
let impl_expr = get_trait_info(s, generics, assoc);
316316

317317
ConstantExprKind::TraitConst { impl_expr, name }
318318
}
@@ -356,19 +356,18 @@ pub trait ConstantExt<'tcx>: Sized + std::fmt::Debug {
356356
let cv = if let Some(assoc) = s.base().tcx.opt_associated_item(ucv.def) {
357357
if assoc.trait_item_def_id.is_some() {
358358
// This must be a trait declaration constant
359-
trait_const_to_constant_expr_kind(s, ucv.def, ucv.substs, &assoc)
359+
trait_const_to_constant_expr_kind(s, ucv.def, ucv.args, &assoc)
360360
} else {
361361
// Constant appearing in an inherent impl block.
362362

363363
// Solve the trait obligations
364364
let parent_def_id = tcx.parent(ucv.def);
365365
let param_env = s.param_env();
366-
let trait_refs =
367-
solve_item_traits(s, param_env, parent_def_id, ucv.substs, None);
366+
let trait_refs = solve_item_traits(s, param_env, parent_def_id, ucv.args, None);
368367

369368
// Convert
370369
let id = ucv.def.sinto(s);
371-
let generics = ucv.substs.sinto(s);
370+
let generics = ucv.args.sinto(s);
372371
ConstantExprKind::GlobalName {
373372
id,
374373
generics,
@@ -377,7 +376,7 @@ pub trait ConstantExt<'tcx>: Sized + std::fmt::Debug {
377376
}
378377
} else {
379378
// Top-level constant.
380-
assert!(ucv.substs.is_empty(), "top-level constant has generics?");
379+
assert!(ucv.args.is_empty(), "top-level constant has generics?");
381380
let id = ucv.def.sinto(s);
382381
ConstantExprKind::GlobalName {
383382
id,
@@ -449,7 +448,7 @@ pub(crate) fn valtree_to_constant_expr<'tcx, S: UnderOwnerState<'tcx>>(
449448
(ty::ValTree::Branch(_), ty::Array(..) | ty::Tuple(..) | ty::Adt(..)) => {
450449
let contents: rustc_middle::ty::DestructuredConst = s
451450
.base().tcx
452-
.destructure_const(s.base().tcx.mk_const(valtree, ty));
451+
.destructure_const(ty::Const::new_value(s.base().tcx, valtree, ty));
453452
let fields = contents.fields.iter().copied();
454453
match ty.kind() {
455454
ty::Array(_, _) => ConstantExprKind::Array {
@@ -499,23 +498,10 @@ pub(crate) fn const_value_reference_to_constant_expr<'tcx, S: UnderOwnerState<'t
499498
val: rustc_middle::mir::interpret::ConstValue<'tcx>,
500499
span: rustc_span::Span,
501500
) -> ConstantExpr {
502-
use rustc_middle::mir::interpret;
503-
use rustc_middle::ty;
504-
505501
let tcx = s.base().tcx;
506502

507-
// We use [try_destructure_mir_constant] to destructure the constant
508-
let param_env = s.param_env();
509-
// We have to clone some values: it is a bit annoying, but I don't
510-
// manage to get the lifetimes working otherwise...
511-
let cvalue = rustc_middle::mir::ConstantKind::Val(val, ty);
512-
let param_env_and_const = rustc_middle::ty::ParamEnvAnd {
513-
param_env,
514-
value: cvalue,
515-
};
516-
517503
let dc = tcx
518-
.try_destructure_mir_constant(param_env_and_const)
504+
.try_destructure_mir_constant_for_diagnostics((val, ty))
519505
.s_unwrap(s);
520506

521507
// Iterate over the fields, which should be values
@@ -530,19 +516,14 @@ pub(crate) fn const_value_reference_to_constant_expr<'tcx, S: UnderOwnerState<'t
530516
}
531517
};
532518

533-
// The fields should be of the variant: [ConstantKind::Value]
534-
let fields: Vec<(ty::Ty, interpret::ConstValue)> = dc
535-
.fields
536-
.iter()
537-
.map(|f| (f.ty(), f.try_to_value(tcx).s_unwrap(s)))
538-
.collect();
539-
540519
// Below: we are mutually recursive with [const_value_to_constant_expr],
541-
// which takes a [ConstantKind] as input (see `cvalue` above), but it should be
520+
// which takes a [ConstantKind] as input, but it should be
542521
// ok because we call it on a strictly smaller value.
543-
let fields: Vec<ConstantExpr> = fields
544-
.into_iter()
545-
.map(|(ty, f)| const_value_to_constant_expr(s, ty, f, span))
522+
let fields: Vec<ConstantExpr> = dc
523+
.fields
524+
.iter()
525+
.copied()
526+
.map(|(val, ty)| const_value_to_constant_expr(s, ty, val, span))
546527
.collect();
547528
(ConstantExprKind::Tuple { fields }).decorate(hax_ty, span.sinto(s))
548529
}
@@ -577,9 +558,9 @@ pub fn const_value_to_constant_expr<'tcx, S: UnderOwnerState<'tcx>>(
577558
let cv = match &hty {
578559
Ty::Tuple(tys) if tys.is_empty() => ConstantExprKind::Tuple { fields: Vec::new() },
579560
Ty::Arrow(_) => match ty.kind() {
580-
rustc_middle::ty::TyKind::FnDef(def_id, substs) => {
561+
rustc_middle::ty::TyKind::FnDef(def_id, args) => {
581562
let (def_id, generics, generics_impls, method_impl) =
582-
get_function_from_def_id_and_substs(s, *def_id, substs);
563+
get_function_from_def_id_and_generics(s, *def_id, args);
583564

584565
ConstantExprKind::FnPtr {
585566
def_id,

frontend/exporter/src/rustc_utils.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ impl<'tcx, T: ty::TypeFoldable<ty::TyCtxt<'tcx>>> ty::Binder<'tcx, T> {
66
fn subst(
77
self,
88
tcx: ty::TyCtxt<'tcx>,
9-
substs: &[ty::subst::GenericArg<'tcx>],
9+
generics: &[ty::GenericArg<'tcx>],
1010
) -> ty::Binder<'tcx, T> {
11-
self.rebind(ty::EarlyBinder::bind(self.clone().skip_binder()).subst(tcx, substs))
11+
self.rebind(ty::EarlyBinder::bind(self.clone().skip_binder()).instantiate(tcx, generics))
1212
}
1313
}
1414

@@ -95,11 +95,11 @@ impl<'tcx> ty::TyCtxt<'tcx> {
9595
pub fn poly_trait_ref<'tcx, S: UnderOwnerState<'tcx>>(
9696
s: &S,
9797
assoc: &ty::AssocItem,
98-
substs: ty::SubstsRef<'tcx>,
98+
generics: ty::GenericArgsRef<'tcx>,
9999
) -> Option<ty::PolyTraitRef<'tcx>> {
100100
let tcx = s.base().tcx;
101101
let r#trait = tcx.trait_of_item(assoc.def_id)?;
102-
Some(ty::Binder::dummy(ty::TraitRef::new(tcx, r#trait, substs)))
102+
Some(ty::Binder::dummy(ty::TraitRef::new(tcx, r#trait, generics)))
103103
}
104104

105105
#[tracing::instrument(skip(s))]

frontend/exporter/src/state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ impl ImplInfos {
248248

249249
Self {
250250
generics: tcx.generics_of(did).sinto(s),
251-
typ: tcx.type_of(did).subst_identity().sinto(s),
251+
typ: tcx.type_of(did).instantiate_identity().sinto(s),
252252
trait_ref: tcx.impl_trait_ref(did).sinto(s),
253253
clauses: tcx.predicates_defined_on(did).predicates.sinto(s),
254254
}

frontend/exporter/src/traits.rs

+11-15
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ pub(crate) mod search_clause {
8080
fn predicates_to_poly_trait_predicates<'tcx>(
8181
tcx: TyCtxt<'tcx>,
8282
predicates: impl Iterator<Item = Predicate<'tcx>>,
83-
substs: subst::SubstsRef<'tcx>,
83+
generics: GenericArgsRef<'tcx>,
8484
) -> impl Iterator<Item = PolyTraitPredicate<'tcx>> {
8585
predicates
86-
.map(move |pred| pred.kind().subst(tcx, substs))
86+
.map(move |pred| pred.kind().subst(tcx, generics))
8787
.filter_map(|pred| pred.as_poly_trait_predicate())
8888
}
8989

@@ -160,20 +160,16 @@ pub(crate) mod search_clause {
160160
.predicates_defined_on_or_above(self.def_id())
161161
.into_iter()
162162
.map(|apred| apred.predicate);
163-
predicates_to_poly_trait_predicates(
164-
tcx,
165-
predicates,
166-
self.skip_binder().trait_ref.substs,
167-
)
168-
.enumerate()
169-
.collect()
163+
predicates_to_poly_trait_predicates(tcx, predicates, self.skip_binder().trait_ref.args)
164+
.enumerate()
165+
.collect()
170166
}
171167
fn associated_items_trait_predicates(
172168
self,
173169
s: &S,
174170
) -> Vec<(
175171
AssocItem,
176-
subst::EarlyBinder<Vec<(usize, PolyTraitPredicate<'tcx>)>>,
172+
EarlyBinder<Vec<(usize, PolyTraitPredicate<'tcx>)>>,
177173
)> {
178174
let tcx = s.base().tcx;
179175
tcx.associated_items(self.def_id())
@@ -185,7 +181,7 @@ pub(crate) mod search_clause {
185181
predicates_to_poly_trait_predicates(
186182
tcx,
187183
clauses.into_iter().map(|clause| clause.as_predicate()),
188-
self.skip_binder().trait_ref.substs,
184+
self.skip_binder().trait_ref.args,
189185
)
190186
.enumerate()
191187
.collect()
@@ -321,11 +317,11 @@ impl<'tcx> IntoImplExpr<'tcx> for rustc_middle::ty::PolyTraitRef<'tcx> {
321317
match select_trait_candidate(s, param_env, *self) {
322318
ImplSource::UserDefined(ImplSourceUserDefinedData {
323319
impl_def_id,
324-
substs,
320+
args: generics,
325321
nested,
326322
}) => ImplExprAtom::Concrete {
327323
id: impl_def_id.sinto(s),
328-
generics: substs.sinto(s),
324+
generics: generics.sinto(s),
329325
}
330326
.with_args(impl_exprs(s, &nested), trait_ref),
331327
ImplSource::Param(nested, _constness) => {
@@ -398,7 +394,7 @@ pub fn super_clause_to_clause_and_impl_expr<'tcx, S: UnderOwnerState<'tcx>>(
398394
let tcx = s.base().tcx;
399395
let impl_trait_ref = tcx
400396
.impl_trait_ref(impl_did)
401-
.map(|binder| rustc_middle::ty::Binder::dummy(binder.subst_identity()))?;
397+
.map(|binder| rustc_middle::ty::Binder::dummy(binder.instantiate_identity()))?;
402398
let original_predicate_id = {
403399
// We don't want the id of the substituted clause id, but the
404400
// original clause id (with, i.e., `Self`)
@@ -470,7 +466,7 @@ pub mod copy_paste_from_rustc {
470466
let obligation_cause = ObligationCause::dummy();
471467
let obligation = Obligation::new(tcx, obligation_cause, param_env, trait_ref);
472468

473-
let selection = match selcx.select(&obligation) {
469+
let selection = match selcx.poly_select(&obligation) {
474470
Ok(Some(selection)) => selection,
475471
Ok(None) => return Err(CodegenObligationError::Ambiguity),
476472
Err(Unimplemented) => return Err(CodegenObligationError::Unimplemented),

0 commit comments

Comments
 (0)