Skip to content

Commit 2082d9f

Browse files
committed
---
yaml --- r: 1278 b: refs/heads/master c: 7672813 h: refs/heads/master v: v3
1 parent f5c58cb commit 2082d9f

File tree

6 files changed

+251
-306
lines changed

6 files changed

+251
-306
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 51542b279fcae0f740a76b631ce0fbcdf4c7cf5e
2+
refs/heads/master: 76728137089ddb174d18accd7024a6187148104d

trunk/src/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,6 @@ TEST_XFAILS_RUSTC := $(filter-out \
456456
large-records.rs \
457457
lazy-init.rs \
458458
lazy-and-or.rs \
459-
linear-for-loop.rs \
460459
multiline-comment.rs \
461460
obj-drop.rs \
462461
obj-recursion.rs \

trunk/src/boot/me/effect.ml

Lines changed: 34 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ let effect_checking_visitor
179179
then Ast.EFF_pure
180180
else Stack.top auth_stack
181181
in
182-
Stack.push e auth_stack;
182+
let next = lower_effect_of e curr in
183+
Stack.push next auth_stack;
183184
iflog cx
184185
begin
185186
fun _ ->
@@ -188,62 +189,40 @@ let effect_checking_visitor
188189
"entering '%a', adjusting auth effect: '%a' -> '%a'"
189190
Ast.sprintf_name name
190191
Ast.sprintf_effect curr
191-
Ast.sprintf_effect e
192+
Ast.sprintf_effect next
192193
end
193194
end;
194-
let report_mismatch declared_effect calculated_effect =
195-
let name = Hashtbl.find cx.ctxt_all_item_names i.id in
196-
err (Some i.id)
197-
"%a claims effect '%a' but calculated effect is '%a'%s"
198-
Ast.sprintf_name name
199-
Ast.sprintf_effect declared_effect
200-
Ast.sprintf_effect calculated_effect
201-
begin
202-
if Stack.is_empty auth_stack
203-
then ""
204-
else
205-
Printf.sprintf " (auth effects are '%s')"
206-
(stk_fold
207-
auth_stack
208-
(fun e s ->
209-
if s = ""
210-
then
211-
Printf.sprintf "%a"
212-
Ast.sprintf_effect e
213-
else
214-
Printf.sprintf "%s, %a" s
215-
Ast.sprintf_effect e) "")
216-
end
217-
in
218195
begin
219196
match i.node.Ast.decl_item with
220197
Ast.MOD_ITEM_fn f
221198
when htab_search cx.ctxt_required_items i.id = None ->
222-
let calculated_effect =
199+
let e =
223200
match htab_search item_effect i.id with
224201
None -> Ast.EFF_pure
225202
| Some e -> e
226203
in
227-
let declared_effect = f.Ast.fn_aux.Ast.fn_effect in
228-
if calculated_effect <> declared_effect
204+
let fe = f.Ast.fn_aux.Ast.fn_effect in
205+
let ae =
206+
if Stack.is_empty auth_stack
207+
then None
208+
else Some (Stack.top auth_stack)
209+
in
210+
if e <> fe && (ae <> (Some e))
229211
then
230-
(* Something's fishy in this case. If the calculated effect
231-
* is equal to one auth'ed by an enclosing scope -- not just
232-
* a lower one -- we accept this mismatch; otherwise we
233-
* complain.
234-
*
235-
* FIXME: this choice of "what constitutes an error" in
236-
* auth/effect mismatches is subjective and could do
237-
* with some discussion. *)
238212
begin
239-
match
240-
stk_search auth_stack
241-
(fun e ->
242-
if e = calculated_effect then Some e else None)
243-
with
244-
Some _ -> ()
245-
| None ->
246-
report_mismatch declared_effect calculated_effect
213+
let name = Hashtbl.find cx.ctxt_all_item_names i.id in
214+
err (Some i.id)
215+
"%a claims effect '%a' but calculated effect is '%a'%s"
216+
Ast.sprintf_name name
217+
Ast.sprintf_effect fe
218+
Ast.sprintf_effect e
219+
begin
220+
match ae with
221+
Some ae when ae <> fe ->
222+
Printf.sprintf " (auth effect is '%a')"
223+
Ast.sprintf_effect ae
224+
| _ -> ""
225+
end
247226
end
248227
| _ -> ()
249228
end;
@@ -260,16 +239,16 @@ let effect_checking_visitor
260239
then Ast.EFF_pure
261240
else Stack.top auth_stack
262241
in
263-
iflog cx
264-
begin
265-
fun _ ->
266-
let name = Hashtbl.find cx.ctxt_all_item_names i.id in
267-
log cx
268-
"leaving '%a', restoring auth effect: '%a' -> '%a'"
269-
Ast.sprintf_name name
270-
Ast.sprintf_effect curr
271-
Ast.sprintf_effect next
272-
end
242+
iflog cx
243+
begin
244+
fun _ ->
245+
let name = Hashtbl.find cx.ctxt_all_item_names i.id in
246+
log cx
247+
"leaving '%a', restoring auth effect: '%a' -> '%a'"
248+
Ast.sprintf_name name
249+
Ast.sprintf_effect curr
250+
Ast.sprintf_effect next
251+
end
273252
in
274253
{ inner with
275254
Walk.visit_mod_item_pre = visit_mod_item_pre;

0 commit comments

Comments
 (0)