Skip to content

Commit 2d4727e

Browse files
authored
Merge pull request #1534 from Nadrieril/update-rustc
Update rustc to latest nightly
2 parents 8ff1bfa + 5184964 commit 2d4727e

Some content is hidden

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

54 files changed

+700
-400
lines changed

.github/workflows/charon.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

cli/driver/src/driver.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![feature(rustc_private)]
22
#![feature(box_patterns)]
3-
#![feature(concat_idents)]
43
#![feature(trait_alias)]
54
#![allow(unused_imports)]
65
#![allow(unused_variables)]

engine/backends/coq/coq/coq_backend.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,7 @@ open Phase_utils
10861086
module TransformToInputLanguage =
10871087
[%functor_application
10881088
Phases.Reject.Unsafe(Features.Rust)
1089+
|> Phases.Drop_metasized
10891090
|> Phases.Reject.RawOrMutPointer
10901091
|> Phases.And_mut_defsite
10911092
|> Phases.Reconstruct_asserts

engine/backends/coq/ssprove/ssprove_backend.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ open Phase_utils
555555
module TransformToInputLanguage =
556556
[%functor_application
557557
Phases.Reject.Unsafe(Features.Rust)
558+
|> Phases.Drop_metasized
558559
|> Phases.Reject.RawOrMutPointer
559560
|> Phases.And_mut_defsite
560561
|> Phases.Reconstruct_asserts

engine/backends/fstar/fstar_backend.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,6 +1911,7 @@ module DepGraphR = Dependencies.Make (Features.Rust)
19111911
module TransformToInputLanguage =
19121912
[%functor_application
19131913
Phases.Reject.RawOrMutPointer(Features.Rust)
1914+
|> Phases.Drop_metasized
19141915
|> Phases.Transform_hax_lib_inline
19151916
|> Phases.Specialize
19161917
|> Phases.Drop_sized_trait

engine/backends/proverif/proverif_backend.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,7 @@ module DepGraphR = Dependencies.Make (Features.Rust)
887887
module TransformToInputLanguage =
888888
[%functor_application
889889
Phases.Reject.Unsafe(Features.Rust)
890+
|> Phases.Drop_metasized
890891
|> Phases.Reject.RawOrMutPointer
891892
|> Phases.Transform_hax_lib_inline
892893
|> Phases.Simplify_question_marks

engine/lib/import_thir.ml

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ let c_attr (attr : Thir.attribute) : attr option =
118118
in
119119
let kind = DocComment { kind; body = comment } in
120120
Some { kind; span = Span.of_thir span }
121+
| Parsed (AutomaticallyDerived span) ->
122+
(* Restore behavior before PR #1534 *)
123+
let kind = Tool { path = "automatically_derived"; tokens = "" } in
124+
Some { kind; span = Span.of_thir span }
121125
| Unparsed { args = Eq { expr = { symbol; _ }; _ }; path = "doc"; span; _ } ->
122126
(* Looks for `#[doc = "something"]` *)
123127
let kind = DocComment { kind = DCKLine; body = symbol } in
@@ -1105,8 +1109,6 @@ end) : EXPR = struct
11051109
match non_traits with
11061110
| [] -> TDyn { witness = W.dyn; goals }
11071111
| _ -> assertion_failure [ span ] "type Dyn with non trait predicate")
1108-
| Dynamic (_, _, DynStar) ->
1109-
unimplemented ~issue_id:931 [ span ] "type DynStar"
11101112
| Coroutine _ ->
11111113
unimplemented ~issue_id:924 [ span ]
11121114
"Got type `Coroutine`: coroutines are not supported by hax"
@@ -1377,7 +1379,7 @@ let is_automatically_derived (attrs : Thir.attribute list) =
13771379
~f:(function
13781380
(* This will break once these attributes get properly parsed. It will
13791381
then be very easy to parse them correctly *)
1380-
| Unparsed { path; _ } -> String.equal path "automatically_derived"
1382+
| Parsed (AutomaticallyDerived _) -> true
13811383
| _ -> false)
13821384
attrs
13831385

@@ -1516,7 +1518,7 @@ and c_item_unwrapped ~ident ~type_only (item : Thir.item) : item list =
15161518
in
15171519
(* TODO: things might be unnamed (e.g. constants) *)
15181520
match (item.kind : Thir.item_kind) with
1519-
| Const (_, _, generics, body) ->
1521+
| Const (_, generics, _, body) ->
15201522
mk
15211523
@@ Fn
15221524
{
@@ -1526,14 +1528,14 @@ and c_item_unwrapped ~ident ~type_only (item : Thir.item) : item list =
15261528
params = [];
15271529
safety = Safe;
15281530
}
1529-
| Static (_, _, true, _) ->
1531+
| Static (true, _, _, _) ->
15301532
unimplemented ~issue_id:1343 [ item.span ]
15311533
"Mutable static items are not supported."
1532-
| Static (_, _ty, false, body) ->
1534+
| Static (false, _, _ty, body) ->
15331535
let name = Concrete_ident.of_def_id ~value:true (assert_item_def_id ()) in
15341536
let generics = { params = []; constraints = [] } in
15351537
mk (Fn { name; generics; body = c_body body; params = []; safety = Safe })
1536-
| TyAlias (_, ty, generics) ->
1538+
| TyAlias (_, generics, ty) ->
15371539
mk
15381540
@@ TyAlias
15391541
{
@@ -1552,13 +1554,13 @@ and c_item_unwrapped ~ident ~type_only (item : Thir.item) : item list =
15521554
params = c_fn_params item.span params;
15531555
safety = c_header_safety safety;
15541556
}
1555-
| (Enum (_, _, generics, _) | Struct (_, _, generics)) when erased ->
1557+
| (Enum (_, generics, _, _) | Struct (_, generics, _)) when erased ->
15561558
let generics = c_generics generics in
15571559
let is_struct = match item.kind with Struct _ -> true | _ -> false in
15581560
let def_id = assert_item_def_id () in
15591561
let name = Concrete_ident.of_def_id ~value:false def_id in
15601562
mk @@ Type { name; generics; variants = []; is_struct }
1561-
| Enum (_, variants, generics, repr) ->
1563+
| Enum (_, generics, variants, repr) ->
15621564
let def_id = assert_item_def_id () in
15631565
let generics = c_generics generics in
15641566
let is_struct = false in
@@ -1616,7 +1618,7 @@ and c_item_unwrapped ~ident ~type_only (item : Thir.item) : item list =
16161618
mk_one (Type { name; generics; variants; is_struct }) :: discs
16171619
in
16181620
if is_primitive then cast_fun :: result else result
1619-
| Struct (_, v, generics) ->
1621+
| Struct (_, generics, v) ->
16201622
let generics = c_generics generics in
16211623
let def_id = assert_item_def_id () in
16221624
let is_struct = true in
@@ -1643,7 +1645,7 @@ and c_item_unwrapped ~ident ~type_only (item : Thir.item) : item list =
16431645
let variants = [ v ] in
16441646
let name = Concrete_ident.of_def_id ~value:false def_id in
16451647
mk @@ Type { name; generics; variants; is_struct }
1646-
| Trait (No, safety, _, generics, _bounds, items) ->
1648+
| Trait (NotConst, No, safety, _, generics, _bounds, items) ->
16471649
let items =
16481650
List.filter
16491651
~f:(fun { attributes; _ } -> not (should_skip attributes))
@@ -1666,8 +1668,10 @@ and c_item_unwrapped ~ident ~type_only (item : Thir.item) : item list =
16661668
let items = List.map ~f:c_trait_item items in
16671669
let safety = csafety safety in
16681670
mk @@ Trait { name; generics; items; safety }
1669-
| Trait (Yes, _, _, _, _, _) ->
1671+
| Trait (_, Yes, _, _, _, _, _) ->
16701672
unimplemented ~issue_id:930 [ item.span ] "Auto trait"
1673+
| Trait (Const, _, _, _, _, _, _) ->
1674+
unimplemented ~issue_id:930 [ item.span ] "Const trait"
16711675
| Impl { of_trait = None; generics; items; _ } ->
16721676
let items =
16731677
List.filter
@@ -1814,7 +1818,9 @@ and c_item_unwrapped ~ident ~type_only (item : Thir.item) : item list =
18141818
{
18151819
path = List.map ~f:(fun x -> fst x.ident) segments;
18161820
is_external =
1817-
List.exists ~f:(function Err -> true | _ -> false) res;
1821+
List.exists
1822+
~f:(function None | Some Err -> true | _ -> false)
1823+
res;
18181824
(* TODO: this should represent local/external? *)
18191825
rename;
18201826
}
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
(** This phase gets rid of the MetaSized bound. See
2+
https://github.com/cryspen/hax/pull/1534. *)
3+
4+
open! Prelude
5+
6+
module%inlined_contents Make (F : Features.T) = struct
7+
open Ast
8+
module FA = F
9+
module FB = FA
10+
11+
include
12+
Phase_utils.MakeBase (F) (FB)
13+
(struct
14+
let phase_id = [%auto_phase_name auto]
15+
end)
16+
17+
module UA = Ast_utils.Make (F)
18+
19+
module Implem : ImplemT.T = struct
20+
let metadata = metadata
21+
22+
module S = struct
23+
include Features.SUBTYPE.Id
24+
end
25+
26+
[%%inline_defs dmutability + dsafety_kind]
27+
28+
let rec dimpl_expr (span : span) (i : A.impl_expr) : B.impl_expr option =
29+
let* kind = dimpl_expr_kind span i.kind in
30+
let* goal = dtrait_goal span i.goal in
31+
Some B.{ kind; goal }
32+
33+
and dtrait_goal (span : span) (r : A.trait_goal) : B.trait_goal option =
34+
let*? _ = not (Concrete_ident.eq_name Core__marker__MetaSized r.trait) in
35+
Some
36+
B.{ trait = r.trait; args = List.map ~f:(dgeneric_value span) r.args }
37+
38+
and dimpl_expr_exn message span i =
39+
match dimpl_expr span i with
40+
| None -> Error.assertion_failure span message
41+
| Some impl -> impl
42+
43+
and dimpl_ident (span : span) (r : A.impl_ident) : B.impl_ident option =
44+
let* goal = dtrait_goal span r.goal in
45+
Some B.{ goal; name = r.name }
46+
47+
and dty (span : span) (ty : A.ty) : B.ty =
48+
match ty with
49+
| TAssociatedType { impl; item } ->
50+
let impl =
51+
dimpl_expr_exn "MetaSized has no associated type" span impl
52+
in
53+
TAssociatedType { impl; item }
54+
| [%inline_arms "dty.*" - TAssociatedType] -> auto
55+
56+
and dprojection_predicate (span : span) (r : A.projection_predicate) :
57+
B.projection_predicate =
58+
{
59+
impl = dimpl_expr_exn "MetaSized cannot be projected" span r.impl;
60+
assoc_item = r.assoc_item;
61+
typ = dty span r.typ;
62+
}
63+
64+
and dimpl_expr_kind (span : span) (i : A.impl_expr_kind) :
65+
B.impl_expr_kind option =
66+
match i with
67+
| Parent { impl; ident } ->
68+
let* impl = dimpl_expr span impl in
69+
let* ident = dimpl_ident span ident in
70+
Some (B.Parent { impl; ident })
71+
| Projection { impl; item; ident } ->
72+
let impl = dimpl_expr_exn "MetaSized have no projection" span impl in
73+
let* ident = dimpl_ident span ident in
74+
Some (B.Projection { impl; item; ident })
75+
| ImplApp { impl; args } ->
76+
let* impl = dimpl_expr span impl in
77+
let args = List.filter_map ~f:(dimpl_expr span) args in
78+
Some (B.ImplApp { impl; args })
79+
| Builtin tr ->
80+
let* tr = dtrait_goal span tr in
81+
Some (B.Builtin tr)
82+
| Concrete tr ->
83+
let* tr = dtrait_goal span tr in
84+
Some (B.Concrete tr)
85+
| [%inline_arms
86+
"dimpl_expr_kind.*" - Parent - Projection - ImplApp - Builtin
87+
- Concrete] ->
88+
map (fun x ->
89+
Some
90+
(let result : B.impl_expr_kind = x in
91+
result))
92+
93+
and dexpr' (span : span) (expr : A.expr') : B.expr' =
94+
match expr with
95+
| App { f; args; generic_args; bounds_impls; trait } ->
96+
let dgeneric_values = List.map ~f:(dgeneric_value span) in
97+
App
98+
{
99+
f = dexpr f;
100+
args = List.map ~f:dexpr args;
101+
generic_args = dgeneric_values generic_args;
102+
bounds_impls = List.filter_map ~f:(dimpl_expr span) bounds_impls;
103+
trait =
104+
Option.map
105+
~f:
106+
(dimpl_expr_exn "MetaSized have no method" span
107+
*** dgeneric_values)
108+
trait;
109+
}
110+
| [%inline_arms "dexpr'.*" - App] -> auto
111+
[@@inline_ands
112+
bindings_of dty - dimpl_expr - dexpr' - dprojection_predicate
113+
- dimpl_expr_kind - dty - dimpl_ident]
114+
115+
let rec dimpl_item' (span : span) (ii : A.impl_item') : B.impl_item' =
116+
match ii with
117+
| IIType { typ; parent_bounds } ->
118+
IIType
119+
{
120+
typ = dty span typ;
121+
parent_bounds =
122+
List.filter_map
123+
~f:(fun (impl, ident) ->
124+
let* impl = dimpl_expr span impl in
125+
let* ident = dimpl_ident span ident in
126+
Some (impl, ident))
127+
parent_bounds;
128+
}
129+
(* | _ -> Obj.magic () *)
130+
| [%inline_arms "dimpl_item'.*" - IIType] -> auto
131+
132+
and dtrait_item' (span : span) (ti : A.trait_item') : B.trait_item' =
133+
match ti with
134+
| TIType idents -> TIType (List.filter_map ~f:(dimpl_ident span) idents)
135+
| [%inline_arms "dtrait_item'.*" - TIType] -> auto
136+
137+
and dgeneric_constraint (span : span)
138+
(generic_constraint : A.generic_constraint) :
139+
B.generic_constraint option =
140+
match generic_constraint with
141+
| GCLifetime (lf, witness) ->
142+
Some (B.GCLifetime (lf, S.lifetime span witness))
143+
| GCType impl_ident ->
144+
let* impl = dimpl_ident span impl_ident in
145+
Some (B.GCType impl)
146+
| GCProjection projection ->
147+
Some (B.GCProjection (dprojection_predicate span projection))
148+
149+
and dgenerics (span : span) (g : A.generics) : B.generics =
150+
{
151+
params = List.map ~f:(dgeneric_param span) g.params;
152+
constraints =
153+
List.filter_map ~f:(dgeneric_constraint span) g.constraints;
154+
}
155+
156+
and ditem' (span : span) (item : A.item') : B.item' =
157+
match item with
158+
| Impl
159+
{
160+
generics;
161+
self_ty;
162+
of_trait = trait_id, trait_generics;
163+
items;
164+
parent_bounds;
165+
safety;
166+
} ->
167+
B.Impl
168+
{
169+
generics = dgenerics span generics;
170+
self_ty = dty span self_ty;
171+
of_trait =
172+
(trait_id, List.map ~f:(dgeneric_value span) trait_generics);
173+
items = List.map ~f:dimpl_item items;
174+
parent_bounds =
175+
List.filter_map
176+
~f:(fun (impl, ident) ->
177+
let* impl = dimpl_expr span impl in
178+
let* ident = dimpl_ident span ident in
179+
Some (impl, ident))
180+
parent_bounds;
181+
safety = dsafety_kind span safety;
182+
}
183+
| [%inline_arms "ditem'.*" - Impl] -> auto
184+
[@@inline_ands
185+
"Item.*" - ditem' - dimpl_item' - dtrait_item' - dgeneric_constraint
186+
- dgenerics]
187+
188+
[%%inline_defs ditems]
189+
end
190+
191+
include Implem
192+
end
193+
[@@add "subtype.ml"]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
(** This phase gets rid of the MetaSized bound. See
2+
https://github.com/cryspen/hax/pull/1534. *)
3+
4+
open! Prelude
5+
6+
module Make (F : Features.T) : sig
7+
include module type of struct
8+
module FA = F
9+
module FB = FA
10+
module A = Ast.Make (F)
11+
module B = Ast.Make (FB)
12+
module ImplemT = Phase_utils.MakePhaseImplemT (A) (B)
13+
end
14+
15+
include ImplemT.T
16+
end

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)