From fe6e8dac3592b3e73120ff5ce9569c0f2323dd74 Mon Sep 17 00:00:00 2001 From: mcarton Date: Wed, 13 Apr 2016 16:02:44 +0200 Subject: [PATCH 1/2] More tests in `DOC_MARKDOWN` --- src/doc.rs | 5 +++- src/utils/conf.rs | 2 +- tests/compile-fail/doc.rs | 52 +++++++++++++++++++++++++++++++++++++-- 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/src/doc.rs b/src/doc.rs index da87b104341..f27b4d862f1 100644 --- a/src/doc.rs +++ b/src/doc.rs @@ -165,7 +165,10 @@ pub fn check_doc(cx: &EarlyContext, valid_idents: &[String], doc: &str, span: Sp ':' => { // reference link current_word_begin = jump_to!(chars, '\n', len); } - _ => continue, + _ => { // automatic reference link + current_word_begin = jump_to!(@next_char, chars, len); + check_doc(cx, valid_idents, link_text, span); + } } } None => return, diff --git a/src/utils/conf.rs b/src/utils/conf.rs index e11a6c0d9c7..74a68d2d730 100644 --- a/src/utils/conf.rs +++ b/src/utils/conf.rs @@ -150,7 +150,7 @@ define_Conf! { /// Lint: CYCLOMATIC_COMPLEXITY. The maximum cyclomatic complexity a function can have ("cyclomatic-complexity-threshold", cyclomatic_complexity_threshold, 25 => u64), /// Lint: DOC_MARKDOWN. The list of words this lint should not consider as identifiers needing ticks - ("doc-valid-idents", doc_valid_idents, ["MiB", "GiB", "TiB", "PiB", "EiB"] => Vec), + ("doc-valid-idents", doc_valid_idents, ["MiB", "GiB", "TiB", "PiB", "EiB", "GitHub"] => Vec), /// Lint: TOO_MANY_ARGUMENTS. The maximum number of argument a function or method can have ("too-many-arguments-threshold", too_many_arguments_threshold, 7 => u64), /// Lint: TYPE_COMPLEXITY. The maximum complexity a type can have diff --git a/tests/compile-fail/doc.rs b/tests/compile-fail/doc.rs index 81250b5485a..16e460e5055 100755 --- a/tests/compile-fail/doc.rs +++ b/tests/compile-fail/doc.rs @@ -9,10 +9,12 @@ /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) /// Markdown is _weird_. I mean _really weird_. This \_ is ok. So is `_`. But not Foo::some_fun /// which should be reported only once despite being __doubly bad__. +/// be_sure_we_got_to_the_end_of_it fn foo_bar() { //~^ ERROR: you should put `foo_bar` between ticks //~| ERROR: you should put `foo::bar` between ticks //~| ERROR: you should put `Foo::some_fun` between ticks +//~| ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks } /// That one tests multiline ticks. @@ -20,13 +22,17 @@ fn foo_bar() { /// foo_bar FOO_BAR /// _foo bar_ /// ``` +/// be_sure_we_got_to_the_end_of_it fn multiline_ticks() { +//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks } /// This _is a test for /// multiline /// emphasis_. +/// be_sure_we_got_to_the_end_of_it fn test_emphasis() { +//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks } /// This tests units. See also #835. @@ -38,22 +44,64 @@ fn test_emphasis() { /// 32kib 32Mib 32Gib 32Tib 32Pib 32Eib /// 32kB 32MB 32GB 32TB 32PB 32EB /// 32kb 32Mb 32Gb 32Tb 32Pb 32Eb +/// be_sure_we_got_to_the_end_of_it fn test_units() { +//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks +} + +/// This one checks we don’t try to split unicode codepoints +/// `ß` +/// `ℝ` +/// `💣` +/// `❤️` +/// ß_foo +/// ℝ_foo +/// 💣_foo +/// ❤️_foo +/// foo_ß +/// foo_ℝ +/// foo_💣 +/// foo_❤️ +/// [ßdummy textß][foo_ß] +/// [ℝdummy textℝ][foo_ℝ] +/// [💣dummy tex💣t][foo_💣] +/// [❤️dummy text❤️][foo_❤️] +/// [ßdummy textß](foo_ß) +/// [ℝdummy textℝ](foo_ℝ) +/// [💣dummy tex💣t](foo_💣) +/// [❤️dummy text❤️](foo_❤️) +/// [foo_ß]: dummy text +/// [foo_ℝ]: dummy text +/// [foo_💣]: dummy text +/// [foo_❤️]: dummy text +/// be_sure_we_got_to_the_end_of_it +fn test_unicode() { +//~^ ERROR: you should put `ß_foo` between ticks +//~| ERROR: you should put `ℝ_foo` between ticks +//~| ERROR: you should put `foo_ß` between ticks +//~| ERROR: you should put `foo_ℝ` between ticks +//~| ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks } /// This test has [a link_with_underscores][chunked-example] inside it. See #823. -/// See also [the issue tracker](https://github.com/Manishearth/rust-clippy/search?q=doc_markdown&type=Issues). And here is another [inline link][inline_link]. +/// See also [the issue tracker](https://github.com/Manishearth/rust-clippy/search?q=doc_markdown&type=Issues) +/// on GitHub (which is a camel-cased word, but is OK). And here is another [inline link][inline_link]. +/// It can also be [inline_link2]. /// /// [chunked-example]: https://en.wikipedia.org/wiki/Chunked_transfer_encoding#Example /// [inline_link]: https://foobar +/// [inline_link2]: https://foobar /// The `main` function is the entry point of the program. Here it only calls the `foo_bar` and /// `multiline_ticks` functions. /// /// expression of the type `_ m c` (where `` /// is one of {`&`, '|'} and `` is one of {`!=`, `>=`, `>` , +/// be_sure_we_got_to_the_end_of_it fn main() { -//~^ ERROR: you should put `link_with_underscores` between ticks +//~^ ERROR: you should put `inline_link2` between ticks +//~| ERROR: you should put `link_with_underscores` between ticks +//~| ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks foo_bar(); multiline_ticks(); test_emphasis(); From 7ae8516bb3b44239131211425862502f4bfb5ecb Mon Sep 17 00:00:00 2001 From: mcarton Date: Wed, 13 Apr 2016 16:07:45 +0200 Subject: [PATCH 2/2] Remove `#[feature(deprecated)]` Fixes `warning: this feature is stable. attribute no longer needed`. --- tests/compile-fail/attrs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/compile-fail/attrs.rs b/tests/compile-fail/attrs.rs index c7a4af60982..314602b2b0b 100644 --- a/tests/compile-fail/attrs.rs +++ b/tests/compile-fail/attrs.rs @@ -1,4 +1,4 @@ -#![feature(plugin, deprecated)] +#![feature(plugin)] #![plugin(clippy)] #![deny(inline_always, deprecated_semver)]