Skip to content

Commit c69d7f9

Browse files
committed
internal: Enforce utf8 paths
1 parent ba33959 commit c69d7f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+343
-262
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ anyhow = "1.0.75"
105105
arrayvec = "0.7.4"
106106
bitflags = "2.4.1"
107107
cargo_metadata = "0.18.1"
108+
camino = "1.1.6"
108109
chalk-solve = { version = "0.96.0", default-features = false }
109110
chalk-ir = "0.96.0"
110111
chalk-recursive = { version = "0.96.0", default-features = false }

crates/flycheck/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
#![warn(rust_2018_idioms, unused_lifetimes)]
1010

11-
use std::{fmt, io, path::PathBuf, process::Command, time::Duration};
11+
use std::{fmt, io, process::Command, time::Duration};
1212

1313
use crossbeam_channel::{never, select, unbounded, Receiver, Sender};
14-
use paths::{AbsPath, AbsPathBuf};
14+
use paths::{AbsPath, AbsPathBuf, Utf8PathBuf};
1515
use rustc_hash::FxHashMap;
1616
use serde::Deserialize;
1717

@@ -53,7 +53,7 @@ pub enum FlycheckConfig {
5353
extra_args: Vec<String>,
5454
extra_env: FxHashMap<String, String>,
5555
ansi_color_output: bool,
56-
target_dir: Option<PathBuf>,
56+
target_dir: Option<Utf8PathBuf>,
5757
},
5858
CustomCommand {
5959
command: String,
@@ -363,7 +363,7 @@ impl FlycheckActor {
363363
});
364364

365365
cmd.arg("--manifest-path");
366-
cmd.arg(self.root.join("Cargo.toml").as_os_str());
366+
cmd.arg(self.root.join("Cargo.toml"));
367367

368368
for target in target_triples {
369369
cmd.args(["--target", target.as_str()]);

crates/ide-diagnostics/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ text-edit.workspace = true
2626
cfg.workspace = true
2727
hir.workspace = true
2828
ide-db.workspace = true
29+
paths.workspace = true
2930

3031
[dev-dependencies]
3132
expect-test = "1.4.0"

crates/ide-diagnostics/src/handlers/unlinked_file.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use ide_db::{
88
source_change::SourceChange,
99
RootDatabase,
1010
};
11+
use paths::Utf8Component;
1112
use syntax::{
1213
ast::{self, edit::IndentLevel, HasModuleItem, HasName},
1314
AstNode, TextRange,
@@ -84,10 +85,10 @@ fn fixes(ctx: &DiagnosticsContext<'_>, file_id: FileId) -> Option<Vec<Assist>> {
8485

8586
// try resolving the relative difference of the paths as inline modules
8687
let mut current = root_module;
87-
for ele in rel.as_ref().components() {
88+
for ele in rel.as_utf8_path().components() {
8889
let seg = match ele {
89-
std::path::Component::Normal(seg) => seg.to_str()?,
90-
std::path::Component::RootDir => continue,
90+
Utf8Component::Normal(seg) => seg,
91+
Utf8Component::RootDir => continue,
9192
// shouldn't occur
9293
_ => continue 'crates,
9394
};

crates/load-cargo/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ tracing.workspace = true
2020

2121
hir-expand.workspace = true
2222
ide-db.workspace = true
23+
paths.workspace = true
2324
proc-macro-api.workspace = true
2425
project-model.workspace = true
2526
span.workspace = true

crates/load-cargo/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub fn load_workspace_at(
3838
load_config: &LoadCargoConfig,
3939
progress: &dyn Fn(String),
4040
) -> anyhow::Result<(RootDatabase, vfs::Vfs, Option<ProcMacroServer>)> {
41-
let root = AbsPathBuf::assert(std::env::current_dir()?.join(root));
41+
let root = AbsPathBuf::assert_utf8(std::env::current_dir()?.join(root));
4242
let root = ProjectManifest::discover_single(&root)?;
4343
let mut workspace = ProjectWorkspace::load(root, cargo_config, progress)?;
4444

crates/paths/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ rust-version.workspace = true
1212
doctest = false
1313

1414
[dependencies]
15+
camino.workspace = true
1516
# Adding this dep sadly puts a lot of rust-analyzer crates after the
1617
# serde-derive crate. Even though we don't activate the derive feature here,
1718
# someone else in the crate graph certainly does!
1819
# serde.workspace = true
1920

21+
[features]
22+
serde1 = ["camino/serde1"]
23+
2024
[lints]
21-
workspace = true
25+
workspace = true

0 commit comments

Comments
 (0)