From c269627e0f160771f5e8a7375d38e08a2a6ea990 Mon Sep 17 00:00:00 2001 From: rchaser53 Date: Mon, 10 Feb 2020 00:09:48 +0900 Subject: [PATCH] fix not to break relative path link --- rustfmt-core/rustfmt-lib/src/string.rs | 1 + rustfmt-core/rustfmt-lib/tests/target/issue-4023.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 rustfmt-core/rustfmt-lib/tests/target/issue-4023.rs diff --git a/rustfmt-core/rustfmt-lib/src/string.rs b/rustfmt-core/rustfmt-lib/src/string.rs index 080c4f17788..aade2f74d5f 100644 --- a/rustfmt-core/rustfmt-lib/src/string.rs +++ b/rustfmt-core/rustfmt-lib/src/string.rs @@ -169,6 +169,7 @@ fn detect_url(s: &[&str], index: usize) -> Option { || split.contains("http://") || split.contains("ftp://") || split.contains("file://") + || split.contains("./") { match s[index..].iter().position(|g| is_whitespace(g)) { Some(pos) => Some(index + pos - 1), diff --git a/rustfmt-core/rustfmt-lib/tests/target/issue-4023.rs b/rustfmt-core/rustfmt-lib/tests/target/issue-4023.rs new file mode 100644 index 00000000000..5b73c0145e7 --- /dev/null +++ b/rustfmt-core/rustfmt-lib/tests/target/issue-4023.rs @@ -0,0 +1,12 @@ +// rustfmt-max_width: 100 +// rustfmt-wrap_comments: true +// rustfmt-comment_width: 80 +// rustfmt-normalize_comments: true +// rustfmt-unstable_features: true + +struct Test { + /// [`MANAGE_MESSAGES`]: ../permissions/struct.Permissions.html#associatedconstant.MANAGE_MESSAGES + /// [`MANAGE_CHANNEL`]: ./permissions/struct.Permissions.html#associatedconstant.MANAGE_CHANNEL + #[serde(default, rename = "rate_limit_per_user")] + pub rate_limit: u16, +}