1 //! Config used by the language server.
3 //! We currently get this config from `initialize` LSP request, which is not the
4 //! best way to do it, but was the simplest thing we could implement.
6 //! Of particular interest is the `feature_flags` hash map: while other fields
7 //! configure the server itself, feature flags are passed into analysis, and
8 //! tweak things like automatic insertion of `()` in completions.
10 use std::{convert::TryFrom, ffi::OsString, path::PathBuf};
12 use flycheck::FlycheckConfig;
14 use ide::{AssistConfig, CompletionConfig, DiagnosticsConfig, HoverConfig, InlayHintsConfig};
15 use ide_db::helpers::insert_use::MergeBehavior;
16 use itertools::Itertools;
17 use lsp_types::{ClientCapabilities, MarkupKind};
18 use project_model::{CargoConfig, ProjectJson, ProjectJsonData, ProjectManifest};
19 use rustc_hash::FxHashSet;
20 use serde::{de::DeserializeOwned, Deserialize};
23 use crate::{caps::completion_item_edit_resolve, diagnostics::DiagnosticsMapConfig};
27 /// The strategy to use when inserting new imports or merging imports.
28 assist_importMergeBehaviour: MergeBehaviorDef = "\"full\"",
29 /// The path structure for newly inserted paths to use.
30 assist_importPrefix: ImportPrefixDef = "\"plain\"",
32 /// Show function name and docs in parameter hints.
33 callInfo_full: bool = "true",
35 /// Automatically refresh project info via `cargo metadata` on
36 /// `Cargo.toml` changes.
37 cargo_autoreload: bool = "true",
38 /// Activate all available features.
39 cargo_allFeatures: bool = "false",
40 /// List of features to activate.
41 cargo_features: Vec<String> = "[]",
42 /// Run `cargo check` on startup to get the correct value for package
44 cargo_loadOutDirsFromCheck: bool = "false",
45 /// Do not activate the `default` feature.
46 cargo_noDefaultFeatures: bool = "false",
47 /// Compilation target (target triple).
48 cargo_target: Option<String> = "null",
49 /// Internal config for debugging, disables loading of sysroot crates.
50 cargo_noSysroot: bool = "false",
52 /// Run specified `cargo check` command for diagnostics on save.
53 checkOnSave_enable: bool = "true",
54 /// Check with all features (will be passed as `--all-features`).
55 /// Defaults to `#rust-analyzer.cargo.allFeatures#`.
56 checkOnSave_allFeatures: Option<bool> = "null",
57 /// Check all targets and tests (will be passed as `--all-targets`).
58 checkOnSave_allTargets: bool = "true",
59 /// Cargo command to use for `cargo check`.
60 checkOnSave_command: String = "\"check\"",
61 /// Do not activate the `default` feature.
62 checkOnSave_noDefaultFeatures: Option<bool> = "null",
63 /// Check for a specific target. Defaults to
64 /// `#rust-analyzer.cargo.target#`.
65 checkOnSave_target: Option<String> = "null",
66 /// Extra arguments for `cargo check`.
67 checkOnSave_extraArgs: Vec<String> = "[]",
68 /// List of features to activate. Defaults to
69 /// `#rust-analyzer.cargo.features#`.
70 checkOnSave_features: Option<Vec<String>> = "null",
71 /// Advanced option, fully override the command rust-analyzer uses for
72 /// checking. The command should include `--message-format=json` or
74 checkOnSave_overrideCommand: Option<Vec<String>> = "null",
76 /// Whether to add argument snippets when completing functions.
77 completion_addCallArgumentSnippets: bool = "true",
78 /// Whether to add parenthesis when completing functions.
79 completion_addCallParenthesis: bool = "true",
80 /// Whether to show postfix snippets like `dbg`, `if`, `not`, etc.
81 completion_postfix_enable: bool = "true",
82 /// Toggles the additional completions that automatically add imports when completed.
83 /// Note that your client must specify the `additionalTextEdits` LSP client capability to truly have this feature enabled.
84 completion_autoimport_enable: bool = "true",
86 /// Whether to show native rust-analyzer diagnostics.
87 diagnostics_enable: bool = "true",
88 /// Whether to show experimental rust-analyzer diagnostics that might
89 /// have more false positives than usual.
90 diagnostics_enableExperimental: bool = "true",
91 /// List of rust-analyzer diagnostics to disable.
92 diagnostics_disabled: FxHashSet<String> = "[]",
93 /// List of warnings that should be displayed with info severity.\n\nThe
94 /// warnings will be indicated by a blue squiggly underline in code and
95 /// a blue icon in the `Problems Panel`.
96 diagnostics_warningsAsHint: Vec<String> = "[]",
97 /// List of warnings that should be displayed with hint severity.\n\nThe
98 /// warnings will be indicated by faded text or three dots in code and
99 /// will not show up in the `Problems Panel`.
100 diagnostics_warningsAsInfo: Vec<String> = "[]",
102 /// Controls file watching implementation.
103 files_watcher: String = "\"client\"",
105 /// Whether to show `Debug` action. Only applies when
106 /// `#rust-analyzer.hoverActions.enable#` is set.
107 hoverActions_debug: bool = "true",
108 /// Whether to show HoverActions in Rust files.
109 hoverActions_enable: bool = "true",
110 /// Whether to show `Go to Type Definition` action. Only applies when
111 /// `#rust-analyzer.hoverActions.enable#` is set.
112 hoverActions_gotoTypeDef: bool = "true",
113 /// Whether to show `Implementations` action. Only applies when
114 /// `#rust-analyzer.hoverActions.enable#` is set.
115 hoverActions_implementations: bool = "true",
116 /// Whether to show `Run` action. Only applies when
117 /// `#rust-analyzer.hoverActions.enable#` is set.
118 hoverActions_run: bool = "true",
119 /// Use markdown syntax for links in hover.
120 hoverActions_linksInHover: bool = "true",
122 /// Whether to show inlay type hints for method chains.
123 inlayHints_chainingHints: bool = "true",
124 /// Maximum length for inlay hints. Default is unlimited.
125 inlayHints_maxLength: Option<usize> = "null",
126 /// Whether to show function parameter name inlay hints at the call
128 inlayHints_parameterHints: bool = "true",
129 /// Whether to show inlay type hints for variables.
130 inlayHints_typeHints: bool = "true",
132 /// Whether to show `Debug` lens. Only applies when
133 /// `#rust-analyzer.lens.enable#` is set.
134 lens_debug: bool = "true",
135 /// Whether to show CodeLens in Rust files.
136 lens_enable: bool = "true",
137 /// Whether to show `Implementations` lens. Only applies when
138 /// `#rust-analyzer.lens.enable#` is set.
139 lens_implementations: bool = "true",
140 /// Whether to show `Run` lens. Only applies when
141 /// `#rust-analyzer.lens.enable#` is set.
142 lens_run: bool = "true",
143 /// Whether to show `Method References` lens. Only applies when
144 /// `#rust-analyzer.lens.enable#` is set.
145 lens_methodReferences: bool = "false",
147 /// Disable project auto-discovery in favor of explicitly specified set
148 /// of projects.\n\nElements must be paths pointing to `Cargo.toml`,
149 /// `rust-project.json`, or JSON objects in `rust-project.json` format.
150 linkedProjects: Vec<ManifestOrProjectJson> = "[]",
152 /// Number of syntax trees rust-analyzer keeps in memory. Defaults to 128.
153 lruCapacity: Option<usize> = "null",
155 /// Whether to show `can't find Cargo.toml` error message.
156 notifications_cargoTomlNotFound: bool = "true",
158 /// Enable Proc macro support, `#rust-analyzer.cargo.loadOutDirsFromCheck#` must be
160 procMacro_enable: bool = "false",
161 /// Internal config, path to proc-macro server executable (typically,
162 /// this is rust-analyzer itself, but we override this in tests).
163 procMacro_server: Option<PathBuf> = "null",
165 /// Command to be executed instead of 'cargo' for runnables.
166 runnables_overrideCargo: Option<String> = "null",
167 /// Additional arguments to be passed to cargo for runnables such as
168 /// tests or binaries.\nFor example, it may be `--release`.
169 runnables_cargoExtraArgs: Vec<String> = "[]",
171 /// Path to the rust compiler sources, for usage in rustc_private projects.
172 rustcSource : Option<PathBuf> = "null",
174 /// Additional arguments to `rustfmt`.
175 rustfmt_extraArgs: Vec<String> = "[]",
176 /// Advanced option, fully override the command rust-analyzer uses for
178 rustfmt_overrideCommand: Option<Vec<String>> = "null",
182 impl Default for ConfigData {
183 fn default() -> Self {
184 ConfigData::from_json(serde_json::Value::Null)
188 #[derive(Debug, Clone)]
190 caps: lsp_types::ClientCapabilities,
192 pub discovered_projects: Option<Vec<ProjectManifest>>,
193 pub root_path: AbsPathBuf,
196 #[derive(Debug, Clone, Eq, PartialEq)]
197 pub enum LinkedProject {
198 ProjectManifest(ProjectManifest),
199 InlineJsonProject(ProjectJson),
202 impl From<ProjectManifest> for LinkedProject {
203 fn from(v: ProjectManifest) -> Self {
204 LinkedProject::ProjectManifest(v)
208 impl From<ProjectJson> for LinkedProject {
209 fn from(v: ProjectJson) -> Self {
210 LinkedProject::InlineJsonProject(v)
214 #[derive(Clone, Debug, PartialEq, Eq)]
215 pub struct LensConfig {
218 pub implementations: bool,
219 pub method_refs: bool,
223 pub fn any(&self) -> bool {
224 self.implementations || self.runnable() || self.references()
227 pub fn none(&self) -> bool {
231 pub fn runnable(&self) -> bool {
232 self.run || self.debug
235 pub fn references(&self) -> bool {
240 #[derive(Debug, Clone)]
241 pub struct FilesConfig {
242 pub watcher: FilesWatcher,
243 pub exclude: Vec<String>,
246 #[derive(Debug, Clone)]
247 pub enum FilesWatcher {
252 #[derive(Debug, Clone)]
253 pub struct NotificationsConfig {
254 pub cargo_toml_not_found: bool,
257 #[derive(Debug, Clone)]
258 pub enum RustfmtConfig {
259 Rustfmt { extra_args: Vec<String> },
260 CustomCommand { command: String, args: Vec<String> },
263 /// Configuration for runnable items, such as `main` function or tests.
264 #[derive(Debug, Clone)]
265 pub struct RunnablesConfig {
266 /// Custom command to be executed instead of `cargo` for runnables.
267 pub override_cargo: Option<String>,
268 /// Additional arguments for the `cargo`, e.g. `--release`.
269 pub cargo_extra_args: Vec<String>,
273 pub fn new(root_path: AbsPathBuf, caps: ClientCapabilities) -> Self {
274 Config { caps, data: ConfigData::default(), discovered_projects: None, root_path }
276 pub fn update(&mut self, json: serde_json::Value) {
277 log::info!("updating config from JSON: {:#}", json);
278 if json.is_null() || json.as_object().map_or(false, |it| it.is_empty()) {
281 self.data = ConfigData::from_json(json);
284 pub fn json_schema() -> serde_json::Value {
285 ConfigData::json_schema()
291 || -> _ { Some($expr) }()
294 macro_rules! try_or {
295 ($expr:expr, $or:expr) => {
296 try_!($expr).unwrap_or($or)
301 pub fn linked_projects(&self) -> Vec<LinkedProject> {
302 if self.data.linkedProjects.is_empty() {
303 self.discovered_projects
308 .map(LinkedProject::from)
314 .filter_map(|linked_project| {
315 let res = match linked_project {
316 ManifestOrProjectJson::Manifest(it) => {
317 let path = self.root_path.join(it);
318 ProjectManifest::from_manifest_file(path)
319 .map_err(|e| log::error!("failed to load linked project: {}", e))
323 ManifestOrProjectJson::ProjectJson(it) => {
324 ProjectJson::new(&self.root_path, it.clone()).into()
333 pub fn location_link(&self) -> bool {
334 try_or!(self.caps.text_document.as_ref()?.definition?.link_support?, false)
336 pub fn line_folding_only(&self) -> bool {
337 try_or!(self.caps.text_document.as_ref()?.folding_range.as_ref()?.line_folding_only?, false)
339 pub fn hierarchical_symbols(&self) -> bool {
346 .hierarchical_document_symbol_support?,
350 pub fn code_action_literals(&self) -> bool {
357 .code_action_literal_support
361 pub fn work_done_progress(&self) -> bool {
362 try_or!(self.caps.window.as_ref()?.work_done_progress?, false)
364 pub fn code_action_resolve(&self) -> bool {
378 .any(|it| it == "edit")
380 pub fn signature_help_label_offsets(&self) -> bool {
387 .signature_information
389 .parameter_information
391 .label_offset_support?,
396 fn experimental(&self, index: &'static str) -> bool {
397 try_or!(self.caps.experimental.as_ref()?.get(index)?.as_bool()?, false)
399 pub fn code_action_group(&self) -> bool {
400 self.experimental("codeActionGroup")
402 pub fn hover_actions(&self) -> bool {
403 self.experimental("hoverActions")
405 pub fn status_notification(&self) -> bool {
406 self.experimental("statusNotification")
409 pub fn publish_diagnostics(&self) -> bool {
410 self.data.diagnostics_enable
412 pub fn diagnostics(&self) -> DiagnosticsConfig {
414 disable_experimental: !self.data.diagnostics_enableExperimental,
415 disabled: self.data.diagnostics_disabled.clone(),
418 pub fn diagnostics_map(&self) -> DiagnosticsMapConfig {
419 DiagnosticsMapConfig {
420 warnings_as_info: self.data.diagnostics_warningsAsInfo.clone(),
421 warnings_as_hint: self.data.diagnostics_warningsAsHint.clone(),
424 pub fn lru_capacity(&self) -> Option<usize> {
425 self.data.lruCapacity
427 pub fn proc_macro_srv(&self) -> Option<(PathBuf, Vec<OsString>)> {
428 if !self.data.procMacro_enable {
432 let path = self.data.procMacro_server.clone().or_else(|| std::env::current_exe().ok())?;
433 Some((path, vec!["proc-macro".into()]))
435 pub fn files(&self) -> FilesConfig {
437 watcher: match self.data.files_watcher.as_str() {
438 "notify" => FilesWatcher::Notify,
439 "client" | _ => FilesWatcher::Client,
444 pub fn notifications(&self) -> NotificationsConfig {
445 NotificationsConfig { cargo_toml_not_found: self.data.notifications_cargoTomlNotFound }
447 pub fn cargo_autoreload(&self) -> bool {
448 self.data.cargo_autoreload
450 pub fn cargo(&self) -> CargoConfig {
451 let rustc_source = self.data.rustcSource.clone().and_then(|it| {
452 AbsPathBuf::try_from(it)
453 .map_err(|_| log::error!("rustc source directory must be an absolute path"))
458 no_default_features: self.data.cargo_noDefaultFeatures,
459 all_features: self.data.cargo_allFeatures,
460 features: self.data.cargo_features.clone(),
461 load_out_dirs_from_check: self.data.cargo_loadOutDirsFromCheck,
462 target: self.data.cargo_target.clone(),
464 no_sysroot: self.data.cargo_noSysroot,
467 pub fn rustfmt(&self) -> RustfmtConfig {
468 match &self.data.rustfmt_overrideCommand {
469 Some(args) if !args.is_empty() => {
470 let mut args = args.clone();
471 let command = args.remove(0);
472 RustfmtConfig::CustomCommand { command, args }
475 RustfmtConfig::Rustfmt { extra_args: self.data.rustfmt_extraArgs.clone() }
479 pub fn flycheck(&self) -> Option<FlycheckConfig> {
480 if !self.data.checkOnSave_enable {
483 let flycheck_config = match &self.data.checkOnSave_overrideCommand {
484 Some(args) if !args.is_empty() => {
485 let mut args = args.clone();
486 let command = args.remove(0);
487 FlycheckConfig::CustomCommand { command, args }
489 Some(_) | None => FlycheckConfig::CargoCommand {
490 command: self.data.checkOnSave_command.clone(),
495 .or(self.data.cargo_target.clone()),
496 all_targets: self.data.checkOnSave_allTargets,
497 no_default_features: self
499 .checkOnSave_noDefaultFeatures
500 .unwrap_or(self.data.cargo_noDefaultFeatures),
503 .checkOnSave_allFeatures
504 .unwrap_or(self.data.cargo_allFeatures),
507 .checkOnSave_features
509 .unwrap_or(self.data.cargo_features.clone()),
510 extra_args: self.data.checkOnSave_extraArgs.clone(),
513 Some(flycheck_config)
515 pub fn runnables(&self) -> RunnablesConfig {
517 override_cargo: self.data.runnables_overrideCargo.clone(),
518 cargo_extra_args: self.data.runnables_cargoExtraArgs.clone(),
521 pub fn inlay_hints(&self) -> InlayHintsConfig {
523 type_hints: self.data.inlayHints_typeHints,
524 parameter_hints: self.data.inlayHints_parameterHints,
525 chaining_hints: self.data.inlayHints_chainingHints,
526 max_length: self.data.inlayHints_maxLength,
529 fn merge_behavior(&self) -> Option<MergeBehavior> {
530 match self.data.assist_importMergeBehaviour {
531 MergeBehaviorDef::None => None,
532 MergeBehaviorDef::Full => Some(MergeBehavior::Full),
533 MergeBehaviorDef::Last => Some(MergeBehavior::Last),
536 pub fn completion(&self) -> CompletionConfig {
537 let mut res = CompletionConfig::default();
538 res.enable_postfix_completions = self.data.completion_postfix_enable;
539 res.enable_autoimport_completions =
540 self.data.completion_autoimport_enable && completion_item_edit_resolve(&self.caps);
541 res.add_call_parenthesis = self.data.completion_addCallParenthesis;
542 res.add_call_argument_snippets = self.data.completion_addCallArgumentSnippets;
543 res.merge = self.merge_behavior();
545 res.allow_snippets(try_or!(
558 pub fn assist(&self) -> AssistConfig {
559 let mut res = AssistConfig::default();
560 res.insert_use.merge = self.merge_behavior();
561 res.insert_use.prefix_kind = match self.data.assist_importPrefix {
562 ImportPrefixDef::Plain => PrefixKind::Plain,
563 ImportPrefixDef::ByCrate => PrefixKind::ByCrate,
564 ImportPrefixDef::BySelf => PrefixKind::BySelf,
566 res.allow_snippets(self.experimental("snippetTextEdit"));
569 pub fn call_info_full(&self) -> bool {
570 self.data.callInfo_full
572 pub fn lens(&self) -> LensConfig {
574 run: self.data.lens_enable && self.data.lens_run,
575 debug: self.data.lens_enable && self.data.lens_debug,
576 implementations: self.data.lens_enable && self.data.lens_implementations,
577 method_refs: self.data.lens_enable && self.data.lens_methodReferences,
580 pub fn hover(&self) -> HoverConfig {
582 implementations: self.data.hoverActions_enable
583 && self.data.hoverActions_implementations,
584 run: self.data.hoverActions_enable && self.data.hoverActions_run,
585 debug: self.data.hoverActions_enable && self.data.hoverActions_debug,
586 goto_type_def: self.data.hoverActions_enable && self.data.hoverActions_gotoTypeDef,
587 links_in_hover: self.data.hoverActions_linksInHover,
599 .contains(&MarkupKind::Markdown),
602 pub fn semantic_tokens_refresh(&self) -> bool {
603 try_or!(self.caps.workspace.as_ref()?.semantic_tokens.as_ref()?.refresh_support?, false)
605 pub fn code_lens_refresh(&self) -> bool {
606 try_or!(self.caps.workspace.as_ref()?.code_lens.as_ref()?.refresh_support?, false)
610 #[derive(Deserialize, Debug, Clone)]
612 enum ManifestOrProjectJson {
614 ProjectJson(ProjectJsonData),
617 #[derive(Deserialize, Debug, Clone)]
618 #[serde(rename_all = "snake_case")]
619 enum MergeBehaviorDef {
625 #[derive(Deserialize, Debug, Clone)]
626 #[serde(rename_all = "snake_case")]
627 enum ImportPrefixDef {
633 macro_rules! _config_data {
634 (struct $name:ident {
636 $(#[doc=$doc:literal])*
637 $field:ident: $ty:ty = $default:expr,
640 #[allow(non_snake_case)]
641 #[derive(Debug, Clone)]
642 struct $name { $($field: $ty,)* }
644 fn from_json(mut json: serde_json::Value) -> $name {
646 $field: get_field(&mut json, stringify!($field), $default),
650 fn json_schema() -> serde_json::Value {
653 let field = stringify!($field);
654 let ty = stringify!($ty);
655 (field, ty, &[$($doc),*], $default)
661 fn manual() -> String {
664 let field = stringify!($field);
665 let ty = stringify!($ty);
666 (field, ty, &[$($doc),*], $default)
673 use _config_data as config_data;
675 fn get_field<T: DeserializeOwned>(
676 json: &mut serde_json::Value,
680 let default = serde_json::from_str(default).unwrap();
682 let mut pointer = field.replace('_', "/");
683 pointer.insert(0, '/');
684 json.pointer_mut(&pointer)
685 .and_then(|it| serde_json::from_value(it.take()).ok())
689 fn schema(fields: &[(&'static str, &'static str, &[&str], &str)]) -> serde_json::Value {
690 for ((f1, ..), (f2, ..)) in fields.iter().zip(&fields[1..]) {
691 fn key(f: &str) -> &str {
692 f.splitn(2, "_").next().unwrap()
694 assert!(key(f1) <= key(f2), "wrong field order: {:?} {:?}", f1, f2);
699 .map(|(field, ty, doc, default)| {
700 let name = field.replace("_", ".");
701 let name = format!("rust-analyzer.{}", name);
702 let props = field_props(field, ty, doc, default);
705 .collect::<serde_json::Map<_, _>>();
709 fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json::Value {
710 let doc = doc.iter().map(|it| it.trim()).join(" ");
712 doc.ends_with('.') && doc.starts_with(char::is_uppercase),
713 "bad docs for {}: {:?}",
717 let default = default.parse::<serde_json::Value>().unwrap();
719 let mut map = serde_json::Map::default();
721 ($($key:literal: $value:tt),*$(,)?) => {{$(
722 map.insert($key.into(), serde_json::json!($value));
725 set!("markdownDescription": doc);
726 set!("default": default);
729 "bool" => set!("type": "boolean"),
730 "String" => set!("type": "string"),
731 "Vec<String>" => set! {
733 "items": { "type": "string" },
735 "FxHashSet<String>" => set! {
737 "items": { "type": "string" },
740 "Option<usize>" => set! {
741 "type": ["null", "integer"],
744 "Option<String>" => set! {
745 "type": ["null", "string"],
747 "Option<PathBuf>" => set! {
748 "type": ["null", "string"],
750 "Option<bool>" => set! {
751 "type": ["null", "boolean"],
753 "Option<Vec<String>>" => set! {
754 "type": ["null", "array"],
755 "items": { "type": "string" },
757 "MergeBehaviorDef" => set! {
759 "enum": ["none", "full", "last"],
760 "enumDescriptions": [
762 "Merge all layers of the import trees",
763 "Only merge the last layer of the import trees"
766 "ImportPrefixDef" => set! {
773 "enumDescriptions": [
774 "Insert import paths relative to the current module, using up to one `super` prefix if the parent module contains the requested item.",
775 "Prefix all import paths with `self` if they don't begin with `self`, `super`, `crate` or a crate name.",
776 "Force import paths to be absolute by always starting them with `crate` or the crate name they refer to."
779 "Vec<ManifestOrProjectJson>" => set! {
781 "items": { "type": ["string", "object"] },
783 _ => panic!("{}: {}", ty, default),
790 fn manual(fields: &[(&'static str, &'static str, &[&str], &str)]) -> String {
793 .map(|(field, _ty, doc, default)| {
794 let name = format!("rust-analyzer.{}", field.replace("_", "."));
795 format!("[[{}]]{} (default: `{}`)::\n{}\n", name, name, default, doc.join(" "))
804 use test_utils::project_dir;
809 fn schema_in_sync_with_package_json() {
810 let s = Config::json_schema();
811 let schema = format!("{:#}", s);
812 let schema = schema.trim_start_matches('{').trim_end_matches('}');
814 let package_json = project_dir().join("editors/code/package.json");
815 let package_json = fs::read_to_string(&package_json).unwrap();
817 let p = remove_ws(&package_json);
818 let s = remove_ws(&schema);
820 assert!(p.contains(&s), "update config in package.json. New config:\n{:#}", schema);
824 fn schema_in_sync_with_docs() {
825 let docs_path = project_dir().join("docs/user/generated_config.adoc");
826 let current = fs::read_to_string(&docs_path).unwrap();
827 let expected = ConfigData::manual();
829 if remove_ws(¤t) != remove_ws(&expected) {
830 fs::write(&docs_path, expected).unwrap();
831 panic!("updated config manual");
835 fn remove_ws(text: &str) -> String {
836 text.replace(char::is_whitespace, "")