Repository: tweag/nickel (rust)

Issue:
Parse error when importing toml files
**Describe the bug**
toml files that use dot paths fail to parse.

```
error: toml parse error: TOML parse error at line 1, column 1
  |
1 | foo.bar = "qux"
  | ^^^^^^^^^^^^^^^
invalid type: string "bar", expected a borrowed string
```

on the other hand, when not using paths with simple top level keys (like in the example folder) e.g.
```toml
foo = "bar"
```
works correctly

even square bracket syntax seems to fail
```toml
[foo.bar]
qux = "42"
```
showing same error.

**To Reproduce**
try any of the simple previous examples in a minimal ncl file like
```ncl
let _data = import "test.toml" in

{ data = _data }
```

**Expected behavior**
A clear and concise description of what you expected to happen.

**Environment**
 - OS name + version: Linux 6.8.0-40-generic #40~22.04.3-Ubuntu
 - Version of the code: 1.8.0

**Additional context**
Add any other context about the problem here.


Pull request:
Disable the spanned-deser feature by default
Works around #2059 by disabling spans.

Fixes #2059.

Possible more permanent fixes include:
- waiting for (or helping with) a fix for the underlying issue in `toml`
- using toml-edit instead, as in #2074 

Patch:
diff --git a/cli/Cargo.toml b/cli/Cargo.toml
index be944961..a3043d4b 100644
--- a/cli/Cargo.toml
+++ b/cli/Cargo.toml
@@ -16,7 +16,7 @@ path = "src/main.rs"
 bench = false
 
 [features]
-default = ["repl", "doc", "format", "spanned-deser"]
+default = ["repl", "doc", "format"]
 repl = ["nickel-lang-core/repl"]
 doc = ["nickel-lang-core/doc", "comrak"]
 format = ["nickel-lang-core/format", "dep:tempfile"]
diff --git a/core/Cargo.toml b/core/Cargo.toml
index eb3a7915..8d636e29 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -19,7 +19,7 @@ links = "nix"
 bench = false
 
 [features]
-default = ["markdown", "repl", "doc", "format", "spanned-deser"]
+default = ["markdown", "repl", "doc", "format"]
 markdown = ["dep:termimad"]
 repl = ["dep:rustyline", "dep:rustyline-derive", "dep:ansi_term"]
 repl-wasm = ["dep:wasm-bindgen", "dep:js-sys", "dep:serde_repr"]
diff --git a/core/src/serialize.rs b/core/src/serialize.rs
index 7b513a2c..0bbc92f6 100644
--- a/core/src/serialize.rs
+++ b/core/src/serialize.rs
@@ -462,7 +462,6 @@ pub fn to_string(format: ExportFormat, rt: &RichTerm) -> Result<String, ExportEr
 /// enabled, [::toml::from_str] will either simply call [toml::from_str] or a custom
 /// deserializer that preserves span information.
 pub mod toml_deser {
-    use super::PrimitiveFloat;
     use crate::term::RichTerm;
     use codespan::FileId;
 
@@ -532,6 +531,8 @@ pub mod toml_deser {
             where
                 D: Deserializer<'de>,
             {
+                use malachite::num::basic::floats::PrimitiveFloat;
+
                 fn deser_int<I: Into<Number>, E>(n: I) -> Result<SpannedValueData, E> {
                     Ok(SpannedValueData::Number(n.into()))
                 }
diff --git a/lsp/nls/Cargo.toml b/lsp/nls/Cargo.toml
index 4813216e..b10db8ec 100644
--- a/lsp/nls/Cargo.toml
+++ b/lsp/nls/Cargo.toml
@@ -41,7 +41,10 @@ lsp-types.workspace = true
 # contract they should follow, e.g. with an environment variable or just the
 # filesystem layout, in which case we will be able to show Nickel diagnostics
 # directly inside a TOML or a YAML file. It's not used as of yet, though.
-nickel-lang-core = {workspace = true, default-features = false, features = ["spanned-deser", "format"]}
+#
+# Actually, never mind. We temporarily disable spanned-deser because of
+# https://github.com/tweag/nickel/issues/2059
+nickel-lang-core = {workspace = true, default-features = false, features = ["format"]}
 regex.workspace = true
 scopeguard.workspace = true
 serde = { workspace = true, features = ["derive"] }


Test patch:
diff --git a/cli/tests/snapshot/snapshots/snapshot__eval_stderr_spanned_toml.ncl.snap b/cli/tests/snapshot/snapshots/snapshot__eval_stderr_spanned_toml.ncl.snap
index df0e816d..d0628873 100644
--- a/cli/tests/snapshot/snapshots/snapshot__eval_stderr_spanned_toml.ncl.snap
+++ b/cli/tests/snapshot/snapshots/snapshot__eval_stderr_spanned_toml.ncl.snap
@@ -8,7 +8,7 @@ error: contract broken by the value of `name`
 5 │   package.name | String,
   │                  ------ expected type
   │
-  ┌─ [IMPORTS_PATH]/package.toml:2:8
+  ┌─ <unknown> (generated by evaluation):1:1
   │
-2 │ name = 5
-  │        ^ applied to this expression
+1 │ 5
+  │ - evaluated to this value