@@ -392,21 +392,27 @@ where
392392 return {
393393 ictx
394394 stx := newStx
395- diagnostics := old.diagnostics
395+ diagnostics := .empty
396+ metaSnap := .finished newStx {
397+ diagnostics := old.diagnostics
398+ }
396399 result? := some {
397400 parserState := newParserState
398- processedSnap := (← oldSuccess.processedSnap.bindIO (stx? := newStx)
401+ processedSnap := (← oldSuccess.processedSnap.bindIO
399402 (cancelTk? := none) (reportingRange? := progressRange?) (sync := true ) fun oldProcessed => do
400403 if let some oldProcSuccess := oldProcessed.result? then
401404 -- also wait on old command parse snapshot as parsing is cheap and may allow for
402405 -- elaboration reuse
403- oldProcSuccess.firstCmdSnap.bindIO (sync := true ) (stx? := newStx)
406+ oldProcSuccess.firstCmdSnap.bindIO (sync := true )
404407 (cancelTk? := none) (reportingRange? := progressRange?) fun oldCmd => do
405408 let prom ← IO.Promise.new
406409 let cancelTk ← IO.CancelToken.new
407410 parseCmd oldCmd newParserState oldProcSuccess.cmdState prom (sync := true ) cancelTk ctx
408- return .finished newStx {
409- diagnostics := oldProcessed.diagnostics
411+ return .finished none {
412+ diagnostics := .empty
413+ metaSnap := .finished newStx {
414+ diagnostics := oldProcessed.diagnostics
415+ }
410416 result? := some {
411417 cmdState := oldProcSuccess.cmdState
412418 firstCmdSnap := { stx? := none, task := prom.result!, cancelTk? := cancelTk } } }
@@ -425,13 +431,16 @@ where
425431 -- ...go immediately to next snapshot
426432 return (← unchanged old old.stx oldSuccess.parserState)
427433
428- withHeaderExceptions ({ · with ictx, stx := .missing, result? := none }) do
434+ withHeaderExceptions ({ · with ictx, stx := .missing, result? := none, metaSnap := default }) do
429435 -- parsing the header should be cheap enough to do synchronously
430436 let (stx, parserState, msgLog) ← Parser.parseHeader ictx
431437 if msgLog.hasErrors then
432438 return {
433439 ictx, stx
434- diagnostics := (← Snapshot.Diagnostics.ofMessageLog msgLog)
440+ diagnostics := .empty
441+ metaSnap := .finished stx {
442+ diagnostics := (← Snapshot.Diagnostics.ofMessageLog msgLog)
443+ }
435444 result? := none
436445 }
437446
@@ -452,7 +461,10 @@ where
452461 old.result?.forM (·.processedSnap.cancelRec)
453462 return {
454463 ictx, stx
455- diagnostics := (← Snapshot.Diagnostics.ofMessageLog msgLog)
464+ diagnostics := .empty
465+ metaSnap := .finished stx {
466+ diagnostics := (← Snapshot.Diagnostics.ofMessageLog msgLog)
467+ }
456468 result? := some {
457469 parserState
458470 processedSnap := (← processHeader ⟨trimmedStx⟩ parserState)
@@ -462,9 +474,9 @@ where
462474 processHeader (stx : HeaderSyntax) (parserState : Parser.ModuleParserState) :
463475 LeanProcessingM (SnapshotTask HeaderProcessedSnapshot) := do
464476 let ctx ← read
465- SnapshotTask.ofIO stx none (some ⟨0 , ctx.input.endPos⟩) <|
477+ SnapshotTask.ofIO none none (some ⟨0 , ctx.input.endPos⟩) <|
466478 ReaderT.run (r := ctx) <| -- re-enter reader in new task
467- withHeaderExceptions (α := HeaderProcessedSnapshot) ({ · with result? := none }) do
479+ withHeaderExceptions (α := HeaderProcessedSnapshot) ({ · with result? := none, metaSnap := default }) do
468480 let setup ← match (← setupImports stx) with
469481 | .ok setup => pure setup
470482 | .error snap => return snap
@@ -483,7 +495,7 @@ where
483495 let stopTime := (← IO.monoNanosNow).toFloat / 1000000000
484496 let diagnostics := (← Snapshot.Diagnostics.ofMessageLog msgLog)
485497 if msgLog.hasErrors then
486- return { diagnostics, result? := none }
498+ return { diagnostics, result? := none, metaSnap := default }
487499
488500 let mut traceState := default
489501 if trace.profiler.output.get? setup.opts |>.isSome then
@@ -521,8 +533,11 @@ where
521533 let cancelTk ← IO.CancelToken.new
522534 parseCmd none parserState cmdState prom (sync := true ) cancelTk ctx
523535 return {
524- diagnostics
525- infoTree? := cmdState.infoState.trees[0 ]!
536+ diagnostics := .empty
537+ metaSnap := .finished stx {
538+ diagnostics
539+ infoTree? := cmdState.infoState.trees[0 ]!
540+ }
526541 result? := some {
527542 cmdState
528543 firstCmdSnap := { stx? := none, task := prom.result!, cancelTk? := cancelTk }
@@ -543,7 +558,7 @@ where
543558 let newProm ← IO.Promise.new
544559 let cancelTk ← IO.CancelToken.new
545560 -- can reuse range, syntax unchanged
546- BaseIO.chainTask (sync := true ) old.resultSnap.task fun oldResult =>
561+ BaseIO.chainTask (sync := true ) old.elabSnap. resultSnap.task fun oldResult =>
547562 -- also wait on old command parse snapshot as parsing is cheap and may allow for
548563 -- elaboration reuse
549564 BaseIO.chainTask (sync := true ) oldNext.task fun oldNext => do
@@ -601,10 +616,13 @@ where
601616 -- is not `Inhabited`
602617 prom.resolve <| {
603618 diagnostics := .empty, stx := .missing, parserState
604- elabSnap := default
605- resultSnap := .finished none { diagnostics := .empty, cmdState }
606- infoTreeSnap := .finished none { diagnostics := .empty }
607- reportSnap := default
619+ elabSnap := {
620+ diagnostics := .empty
621+ elabSnap := default
622+ resultSnap := .finished none { diagnostics := .empty, cmdState }
623+ infoTreeSnap := .finished none { diagnostics := .empty }
624+ reportSnap := default
625+ }
608626 nextCmdSnap? := none
609627 }
610628 return
@@ -641,13 +659,16 @@ where
641659 prom.resolve {
642660 diagnostics, nextCmdSnap?
643661 stx := stx', parserState := parserState'
644- elabSnap := { stx? := stx', task := elabPromise.result!, cancelTk? := some elabCmdCancelTk }
645- resultSnap := { stx? := stx', reportingRange? := initRange?, task := resultPromise.result!, cancelTk? := none }
646- infoTreeSnap := { stx? := stx', reportingRange? := initRange?, task := finishedPromise.result!, cancelTk? := none }
647- reportSnap := { stx? := none, reportingRange? := initRange?, task := reportPromise.result!, cancelTk? := none }
662+ elabSnap := {
663+ diagnostics := .empty
664+ elabSnap := { stx? := stx', task := elabPromise.result!, cancelTk? := some elabCmdCancelTk }
665+ resultSnap := { stx? := stx', reportingRange? := initRange?, task := resultPromise.result!, cancelTk? := none }
666+ infoTreeSnap := { stx? := stx', reportingRange? := initRange?, task := finishedPromise.result!, cancelTk? := none }
667+ reportSnap := { stx? := none, reportingRange? := initRange?, task := reportPromise.result!, cancelTk? := none }
668+ }
648669 }
649670 let cmdState ← doElab stx cmdState beginPos
650- { old? := old?.map fun old => ⟨old.stx, old.elabSnap⟩, new := elabPromise }
671+ { old? := old?.map fun old => ⟨old.stx, old.elabSnap.elabSnap ⟩, new := elabPromise }
651672 elabCmdCancelTk ctx
652673
653674 let mut reportedCmdState := cmdState
@@ -777,6 +798,6 @@ where goCmd snap :=
777798 if let some next := snap.nextCmdSnap? then
778799 goCmd next.get
779800 else
780- snap.resultSnap.get.cmdState
801+ snap.elabSnap. resultSnap.get.cmdState
781802
782803end Lean
0 commit comments