Skip to content

Commit

Permalink
Rollup merge of rust-lang#101720 - GuillaumeGomez:warn-INVALID_HTML_T…
Browse files Browse the repository at this point in the history
…AGS, r=notriddle

Change default level of INVALID_HTML_TAGS to warning and stabilize it

Fixes of rust-lang#67799.

cc ``@Nemo157``
r? ``@notriddle``
  • Loading branch information
matthiaskrgr authored Oct 8, 2022
2 parents ec8b515 + 4ee7db2 commit 8aeadd0
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 20 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ struct HandlerInner {
/// would be unnecessary repetition.
taught_diagnostics: FxHashSet<DiagnosticId>,

/// Used to suggest rustc --explain <error code>
/// Used to suggest rustc --explain `<error code>`
emitted_diagnostic_codes: FxIndexSet<DiagnosticId>,

/// This set contains a hash of every diagnostic that has been emitted by
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ declare_rustdoc_lint! {
///
/// [rustdoc book]: ../../../rustdoc/lints.html#invalid_html_tags
INVALID_HTML_TAGS,
Allow,
Warn,
"detects invalid HTML tags in doc comments"
}

Expand Down
6 changes: 2 additions & 4 deletions src/librustdoc/passes/html_tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ struct InvalidHtmlTagsLinter<'a, 'tcx> {
}

pub(crate) fn check_invalid_html_tags(krate: Crate, cx: &mut DocContext<'_>) -> Crate {
if cx.tcx.sess.is_nightly_build() {
let mut coll = InvalidHtmlTagsLinter { cx };
coll.visit_crate(&krate);
}
let mut coll = InvalidHtmlTagsLinter { cx };
coll.visit_crate(&krate);
krate
}

Expand Down
9 changes: 9 additions & 0 deletions src/test/rustdoc-ui/intra-doc/malformed-generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,26 @@
//! [Vec<] //~ ERROR
//! [Vec<Box<T] //~ ERROR
//! [Vec<Box<T>] //~ ERROR
//~^ WARN
//! [Vec<Box<T>>>] //~ ERROR
//~^ WARN
//! [Vec<T>>>] //~ ERROR
//~^ WARN
//! [<Vec] //~ ERROR
//! [Vec::<] //~ ERROR
//! [<T>] //~ ERROR
//~^ WARN
//! [<invalid syntax>] //~ ERROR
//~^ WARN
//! [Vec:<T>:new()] //~ ERROR
//~^ WARN
//! [Vec<<T>>] //~ ERROR
//~^ WARN
//! [Vec<>] //~ ERROR
//! [Vec<<>>] //~ ERROR

// FIXME(#74563) support UFCS
//! [<Vec as IntoIterator>::into_iter] //~ ERROR
//~^ WARN
//! [<Vec<T> as IntoIterator>::iter] //~ ERROR
//~^ WARN
82 changes: 69 additions & 13 deletions src/test/rustdoc-ui/intra-doc/malformed-generics.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -23,80 +23,136 @@ LL | //! [Vec<Box<T>]
| ^^^^^^^^^^ unbalanced angle brackets

error: unresolved link to `Vec<Box<T>>>`
--> $DIR/malformed-generics.rs:6:6
--> $DIR/malformed-generics.rs:7:6
|
LL | //! [Vec<Box<T>>>]
| ^^^^^^^^^^^^ unbalanced angle brackets

error: unresolved link to `Vec<T>>>`
--> $DIR/malformed-generics.rs:7:6
--> $DIR/malformed-generics.rs:9:6
|
LL | //! [Vec<T>>>]
| ^^^^^^^^ unbalanced angle brackets

error: unresolved link to `<Vec`
--> $DIR/malformed-generics.rs:8:6
--> $DIR/malformed-generics.rs:11:6
|
LL | //! [<Vec]
| ^^^^ unbalanced angle brackets

error: unresolved link to `Vec::<`
--> $DIR/malformed-generics.rs:9:6
--> $DIR/malformed-generics.rs:12:6
|
LL | //! [Vec::<]
| ^^^^^^ unbalanced angle brackets

error: unresolved link to `<T>`
--> $DIR/malformed-generics.rs:10:6
--> $DIR/malformed-generics.rs:13:6
|
LL | //! [<T>]
| ^^^ missing type for generic parameters

error: unresolved link to `<invalid syntax>`
--> $DIR/malformed-generics.rs:11:6
--> $DIR/malformed-generics.rs:15:6
|
LL | //! [<invalid syntax>]
| ^^^^^^^^^^^^^^^^ missing type for generic parameters

error: unresolved link to `Vec:<T>:new`
--> $DIR/malformed-generics.rs:12:6
--> $DIR/malformed-generics.rs:17:6
|
LL | //! [Vec:<T>:new()]
| ^^^^^^^^^^^^^ has invalid path separator

error: unresolved link to `Vec<<T>>`
--> $DIR/malformed-generics.rs:13:6
--> $DIR/malformed-generics.rs:19:6
|
LL | //! [Vec<<T>>]
| ^^^^^^^^ too many angle brackets

error: unresolved link to `Vec<>`
--> $DIR/malformed-generics.rs:14:6
--> $DIR/malformed-generics.rs:21:6
|
LL | //! [Vec<>]
| ^^^^^ empty angle brackets

error: unresolved link to `Vec<<>>`
--> $DIR/malformed-generics.rs:15:6
--> $DIR/malformed-generics.rs:22:6
|
LL | //! [Vec<<>>]
| ^^^^^^^ too many angle brackets

error: unresolved link to `<Vec as IntoIterator>::into_iter`
--> $DIR/malformed-generics.rs:18:6
--> $DIR/malformed-generics.rs:25:6
|
LL | //! [<Vec as IntoIterator>::into_iter]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fully-qualified syntax is unsupported
|
= note: see https://github.com/rust-lang/rust/issues/74563 for more information

error: unresolved link to `<Vec<T> as IntoIterator>::iter`
--> $DIR/malformed-generics.rs:19:6
--> $DIR/malformed-generics.rs:27:6
|
LL | //! [<Vec<T> as IntoIterator>::iter]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fully-qualified syntax is unsupported
|
= note: see https://github.com/rust-lang/rust/issues/74563 for more information

error: aborting due to 15 previous errors
warning: unclosed HTML tag `T`
--> $DIR/malformed-generics.rs:5:13
|
LL | //! [Vec<Box<T>]
| ^^^
|
= note: `#[warn(rustdoc::invalid_html_tags)]` on by default

warning: unclosed HTML tag `T`
--> $DIR/malformed-generics.rs:7:13
|
LL | //! [Vec<Box<T>>>]
| ^^^

warning: unclosed HTML tag `T`
--> $DIR/malformed-generics.rs:9:9
|
LL | //! [Vec<T>>>]
| ^^^

warning: unclosed HTML tag `T`
--> $DIR/malformed-generics.rs:13:6
|
LL | //! [<T>]
| ^^^

warning: unclosed HTML tag `invalid`
--> $DIR/malformed-generics.rs:15:6
|
LL | //! [<invalid syntax>]
| ^^^^^^^^

warning: unclosed HTML tag `T`
--> $DIR/malformed-generics.rs:17:10
|
LL | //! [Vec:<T>:new()]
| ^^^

warning: unclosed HTML tag `T`
--> $DIR/malformed-generics.rs:19:10
|
LL | //! [Vec<<T>>]
| ^^^

warning: unclosed HTML tag `Vec`
--> $DIR/malformed-generics.rs:25:6
|
LL | //! [<Vec as IntoIterator>::into_iter]
| ^^^^

warning: unclosed HTML tag `T`
--> $DIR/malformed-generics.rs:27:10
|
LL | //! [<Vec<T> as IntoIterator>::iter]
| ^^^

error: aborting due to 15 previous errors; 9 warnings emitted

Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
//! [`empty`]

// @has - '//a[@href="../empty2/index.html"]' 'empty2'
//! [empty2<x>]
//! [`empty2<x>`]

0 comments on commit 8aeadd0

Please sign in to comment.