internal: Enforce utf8 paths

This commit is contained in:
Lukas Wirth 2024-03-19 13:05:50 +01:00
parent ba339596bf
commit 399dbc074b
46 changed files with 383 additions and 319 deletions

View file

@ -1,4 +1,4 @@
use std::{ffi::OsStr, iter};
use std::iter;
use expect_test::{expect, Expect};
use hir::Semantics;
@ -18,10 +18,10 @@ use crate::{
fn check_external_docs(
ra_fixture: &str,
target_dir: Option<&OsStr>,
target_dir: Option<&str>,
expect_web_url: Option<Expect>,
expect_local_url: Option<Expect>,
sysroot: Option<&OsStr>,
sysroot: Option<&str>,
) {
let (analysis, position) = fixture::position(ra_fixture);
let links = analysis.external_docs(position, target_dir, sysroot).unwrap();
@ -127,10 +127,10 @@ fn external_docs_doc_builtin_type() {
//- /main.rs crate:foo
let x: u3$02 = 0;
"#,
Some(OsStr::new("/home/user/project")),
Some("/home/user/project"),
Some(expect![[r#"https://doc.rust-lang.org/nightly/core/primitive.u32.html"#]]),
Some(expect![[r#"file:///sysroot/share/doc/rust/html/core/primitive.u32.html"#]]),
Some(OsStr::new("/sysroot")),
Some("/sysroot"),
);
}
@ -143,10 +143,10 @@ use foo$0::Foo;
//- /lib.rs crate:foo
pub struct Foo;
"#,
Some(OsStr::new("/home/user/project")),
Some("/home/user/project"),
Some(expect![[r#"https://docs.rs/foo/*/foo/index.html"#]]),
Some(expect![[r#"file:///home/user/project/doc/foo/index.html"#]]),
Some(OsStr::new("/sysroot")),
Some("/sysroot"),
);
}
@ -157,10 +157,10 @@ fn external_docs_doc_url_std_crate() {
//- /main.rs crate:std
use self$0;
"#,
Some(OsStr::new("/home/user/project")),
Some("/home/user/project"),
Some(expect!["https://doc.rust-lang.org/stable/std/index.html"]),
Some(expect!["file:///sysroot/share/doc/rust/html/std/index.html"]),
Some(OsStr::new("/sysroot")),
Some("/sysroot"),
);
}
@ -171,10 +171,10 @@ fn external_docs_doc_url_struct() {
//- /main.rs crate:foo
pub struct Fo$0o;
"#,
Some(OsStr::new("/home/user/project")),
Some("/home/user/project"),
Some(expect![[r#"https://docs.rs/foo/*/foo/struct.Foo.html"#]]),
Some(expect![[r#"file:///home/user/project/doc/foo/struct.Foo.html"#]]),
Some(OsStr::new("/sysroot")),
Some("/sysroot"),
);
}
@ -185,10 +185,10 @@ fn external_docs_doc_url_windows_backslash_path() {
//- /main.rs crate:foo
pub struct Fo$0o;
"#,
Some(OsStr::new(r"C:\Users\user\project")),
Some(r"C:\Users\user\project"),
Some(expect![[r#"https://docs.rs/foo/*/foo/struct.Foo.html"#]]),
Some(expect![[r#"file:///C:/Users/user/project/doc/foo/struct.Foo.html"#]]),
Some(OsStr::new("/sysroot")),
Some("/sysroot"),
);
}
@ -199,10 +199,10 @@ fn external_docs_doc_url_windows_slash_path() {
//- /main.rs crate:foo
pub struct Fo$0o;
"#,
Some(OsStr::new(r"C:/Users/user/project")),
Some("C:/Users/user/project"),
Some(expect![[r#"https://docs.rs/foo/*/foo/struct.Foo.html"#]]),
Some(expect![[r#"file:///C:/Users/user/project/doc/foo/struct.Foo.html"#]]),
Some(OsStr::new("/sysroot")),
Some("/sysroot"),
);
}