mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Correctly fix formatting doc tests with generics
Before the doc_test would be outputted like this: "Foo<T, U>::t" However, this would cause shells with shell redirection. I've changed it so when generics are involved we simply wrap the expression under escape chanters as so: "\"Foo<T, U>::t\"" Note: At the cost of adding this, I had to allocate a new string via format!{}. However, I argue this is alright as this for just for outputting the name of the doc test. The following tests have been changed: runnables::tests::doc_test_type_params runnables::tests::test_doc_runnables_impl_mod runnables::tests::test_runnables_doc_test_in_impl
This commit is contained in:
parent
89faff7477
commit
5f3327a6b8
1 changed files with 5 additions and 5 deletions
|
@ -426,8 +426,8 @@ fn module_def_doctest(db: &RootDatabase, def: Definition) -> Option<Runnable> {
|
||||||
ty_args.format_with(", ", |ty, cb| cb(&ty.display(db)))
|
ty_args.format_with(", ", |ty, cb| cb(&ty.display(db)))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
format_to!(path, "::{}", def_name);
|
format_to!(path, "::{}\"", def_name);
|
||||||
return Some(path);
|
return Some(format!("\"{}", path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -966,7 +966,7 @@ impl Data {
|
||||||
},
|
},
|
||||||
kind: DocTest {
|
kind: DocTest {
|
||||||
test_id: Path(
|
test_id: Path(
|
||||||
"Data::foo",
|
"\"Data::foo\"",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
cfg: None,
|
cfg: None,
|
||||||
|
@ -1360,7 +1360,7 @@ impl Foo {
|
||||||
},
|
},
|
||||||
kind: DocTest {
|
kind: DocTest {
|
||||||
test_id: Path(
|
test_id: Path(
|
||||||
"foo::Foo::foo",
|
"\"foo::Foo::foo\"",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
cfg: None,
|
cfg: None,
|
||||||
|
@ -2066,7 +2066,7 @@ impl<T, U> Foo<T, U> {
|
||||||
},
|
},
|
||||||
kind: DocTest {
|
kind: DocTest {
|
||||||
test_id: Path(
|
test_id: Path(
|
||||||
"Foo<T, U>::t",
|
"\"Foo<T, U>::t\"",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
cfg: None,
|
cfg: None,
|
||||||
|
|
Loading…
Reference in a new issue