cue/load: minor tweaks
This CL makes some mostly cosmetic changes that shouldn't influence
observable behaviour in practice.
- ensure that Config.ModuleRoot is always an absolute path - various
other places in the code already assume that it is (by checking that
it's a prefix of other absolute paths, for example, or by returning it
where an absolute path is expected).
- Close the `cue.mod` file after opening it.
- Factor out the sizable code block that sets Config.Module into its own
function so it's clearer what it's doing (and avoiding the need for the
slightly sleazy switch, used only so we can `break` out of it.
- Remove places that needlessly check that Config.Dir is absolute.
- Make the contract for Config.newRelInstance clear, and change the only
place (a test) that calls it with an empty path, because it's clear by
inspection of all the call sites that it can never be called with an
empty path in practice.
Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: Id48c981b8fa2ebae56d88032c4b36de15888264f
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/548987
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Unity-Result: CUEcueckoo <cueckoo@cuelang.org>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>