anchor.diff:                 cache_file msg fn)
           end
         in
  -      load_checked_file_with_tc_result (TcEnv.dep_graph env.env_tcenv) fn cache_file;
  -      match BU.smap_try_find mcache cache_file with
  -      | Some (Invalid msg, _) -> fail msg cache_file; None
  -      | Some (Valid (_, tc_result), _) ->
  +      match load_checked_file_with_tc_result
  +              (TcEnv.dep_graph env.env_tcenv)
  +              fn
  +              cache_file |> fst with
  +      | Invalid msg -> fail msg cache_file; None
  +      | Valid (_, tc_result) ->
           if Options.debug_any () then
           BU.print1 "Successfully loaded module from checked file %s\n" cache_file;
           Some tc_result
  
positive.code:                     expected: %s, found: %s\n"
                      checked_fn fn current_dig dig;
                    let msg = BU.format2 "checked file %s is stale (digest mismatch for %s)" checked_fn fn in
                    BU.smap_add mcache checked_fn (Invalid msg, Inl msg)
                  end
                  else BU.smap_add mcache checked_fn (Unknown (deps_dig, tc_result), Inr parsing_data)
  
  (*
   * Second step for loading checked files, validates the tc data
   *)
  let load_checked_file_with_tc_result (deps:Dep.deps) (fn:string) (checked_fn:string) :unit =
    load_checked_file fn checked_fn;  //first step, in case some client calls it directly
    match BU.smap_try_find mcache checked_fn with
    | None -> failwith "Impossible, load_checked_file must add an entry to mcache"
    | Some (Invalid _, _)
    | Some (Valid _, _) -> ()  //already marked Valid or Invalid
    | Some (Unknown (deps_dig, tc_result), parsing_data) ->
      match hash_dependences deps fn with
      | Inl msg ->
        BU.smap_add mcache checked_fn (Invalid msg, parsing_data)
      | Inr deps_dig' ->
        if deps_dig = deps_dig'
        then begin
          //mark the tc data of the file as valid
          BU.smap_add mcache
            checked_fn
            (Valid (BU.digest_of_file checked_fn, tc_result), parsing_data);
          //if there exists an interface for it, mark that too as valid
          //validity of implementaton tc data implies validity of iface tc data
          let validate_iface_cache () =
            let iface = fn |> Dep.lowercase_module_name |> Dep.interface_of deps in
            match iface with
  
negative.code:  *
   * See above for the two steps of loading the checked files
   *)
  let load_checked_file (fn:string) (checked_fn:string) :cache_t =
    let elt = checked_fn |> BU.smap_try_find mcache in
    if elt |> is_some then elt |> must  //already loaded
    else
      let add_and_return elt = BU.smap_add mcache checked_fn elt; elt in
      if not (BU.file_exists checked_fn)
      then let msg = BU.format1 "checked file %s does not exist" checked_fn in
           add_and_return (Invalid msg, Inl msg)
      else match BU.load_value_from_file checked_fn with
           | None ->
             let msg = BU.format1 "checked file %s is corrupt" checked_fn in
             add_and_return (Invalid msg, Inl msg)
           | Some (vnum, deps_dig, dig, parsing_data, tc_result) ->
             if vnum <> cache_version_number
             then let msg = BU.format1 "checked file %s has incorrect version" checked_fn in
                  add_and_return (Invalid msg, Inl msg)
             else let current_dig = BU.digest_of_file fn in
                  if dig <> current_dig
                  then begin
  