Skip to content

Commit 36c8e29

Browse files
committed
Auto merge of rust-lang#101720 - GuillaumeGomez:warn-INVALID_HTML_TAGS, r=notriddle
Change default level of INVALID_HTML_TAGS to warning and stabilize it Fixes of rust-lang#67799. cc `@Nemo157` r? `@notriddle`
2 parents a6b7274 + d565200 commit 36c8e29

File tree

18 files changed

+119
-40
lines changed

18 files changed

+119
-40
lines changed

compiler/rustc_errors/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ struct HandlerInner {
411411
/// would be unnecessary repetition.
412412
taught_diagnostics: FxHashSet<DiagnosticId>,
413413

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

417417
/// This set contains a hash of every diagnostic that has been emitted by

compiler/rustc_hir_analysis/src/check/check.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -707,10 +707,12 @@ pub(super) fn check_opaque_for_cycles<'tcx>(
707707
/// check those cases in the `param_env` of that function, which may have
708708
/// bounds not on this opaque type:
709709
///
710-
/// type X<T> = impl Clone
710+
/// ```ignore (illustrative)
711+
/// type X<T> = impl Clone;
711712
/// fn f<T: Clone>(t: T) -> X<T> {
712713
/// t
713714
/// }
715+
/// ```
714716
///
715717
/// Without this check the above code is incorrectly accepted: we would ICE if
716718
/// some tried, for example, to clone an `Option<X<&mut ()>>`.

compiler/rustc_hir_analysis/src/constrained_generic_params.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ pub fn identify_constrained_generic_params<'tcx>(
114114
/// ```
115115
/// The impl's predicates are collected from left to right. Ignoring
116116
/// the implicit `Sized` bounds, these are
117-
/// * T: Debug
118-
/// * U: Iterator
119-
/// * <U as Iterator>::Item = T -- a desugared ProjectionPredicate
117+
/// * `T: Debug`
118+
/// * `U: Iterator`
119+
/// * `<U as Iterator>::Item = T` -- a desugared ProjectionPredicate
120120
///
121121
/// When we, for example, try to go over the trait-reference
122122
/// `IntoIter<u32> as Trait`, we substitute the impl parameters with fresh
@@ -132,12 +132,16 @@ pub fn identify_constrained_generic_params<'tcx>(
132132
///
133133
/// We *do* have to be somewhat careful when projection targets contain
134134
/// projections themselves, for example in
135+
///
136+
/// ```ignore (illustrative)
135137
/// impl<S,U,V,W> Trait for U where
136138
/// /* 0 */ S: Iterator<Item = U>,
137139
/// /* - */ U: Iterator,
138140
/// /* 1 */ <U as Iterator>::Item: ToOwned<Owned=(W,<V as Iterator>::Item)>
139141
/// /* 2 */ W: Iterator<Item = V>
140142
/// /* 3 */ V: Debug
143+
/// ```
144+
///
141145
/// we have to evaluate the projections in the order I wrote them:
142146
/// `V: Debug` requires `V` to be evaluated. The only projection that
143147
/// *determines* `V` is 2 (1 contains it, but *does not determine it*,

compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs

+8
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,10 @@ fn check_always_applicable(tcx: TyCtxt<'_>, impl1_def_id: LocalDefId, impl2_node
130130
///
131131
/// Example
132132
///
133+
/// ```ignore (illustrative)
133134
/// impl<A, B> Foo<A> for B { /* impl2 */ }
134135
/// impl<C> Foo<Vec<C>> for C { /* impl1 */ }
136+
/// ```
135137
///
136138
/// Would return `S1 = [C]` and `S2 = [Vec<C>, C]`.
137139
fn get_impl_substs<'tcx>(
@@ -225,13 +227,17 @@ fn unconstrained_parent_impl_substs<'tcx>(
225227
///
226228
/// For example forbid the following:
227229
///
230+
/// ```ignore (illustrative)
228231
/// impl<A> Tr for A { }
229232
/// impl<B> Tr for (B, B) { }
233+
/// ```
230234
///
231235
/// Note that only consider the unconstrained parameters of the base impl:
232236
///
237+
/// ```ignore (illustrative)
233238
/// impl<S, I: IntoIterator<Item = S>> Tr<S> for I { }
234239
/// impl<T> Tr<T> for Vec<T> { }
240+
/// ```
235241
///
236242
/// The substs for the parent impl here are `[T, Vec<T>]`, which repeats `T`,
237243
/// but `S` is constrained in the parent impl, so `parent_substs` is only
@@ -256,8 +262,10 @@ fn check_duplicate_params<'tcx>(
256262
///
257263
/// For example forbid the following:
258264
///
265+
/// ```ignore (illustrative)
259266
/// impl<A> Tr for A { }
260267
/// impl Tr for &'static i32 { }
268+
/// ```
261269
fn check_static_lifetimes<'tcx>(
262270
tcx: TyCtxt<'tcx>,
263271
parent_substs: &Vec<GenericArg<'tcx>>,

compiler/rustc_hir_analysis/src/mem_categorization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
184184
/// modes #42640) may look like `Some(x)` but in fact have
185185
/// implicit deref patterns attached (e.g., it is really
186186
/// `&Some(x)`). In that case, we return the "outermost" type
187-
/// (e.g., `&Option<T>).
187+
/// (e.g., `&Option<T>`).
188188
pub(crate) fn pat_ty_adjusted(&self, pat: &hir::Pat<'_>) -> McResult<Ty<'tcx>> {
189189
// Check for implicit `&` types wrapping the pattern; note
190190
// that these are never attached to binding patterns, so

compiler/rustc_middle/src/thir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ pub enum StmtKind<'tcx> {
203203
/// `let pat: ty = <INIT>`
204204
initializer: Option<ExprId>,
205205

206-
/// `let pat: ty = <INIT> else { <ELSE> }
206+
/// `let pat: ty = <INIT> else { <ELSE> }`
207207
else_block: Option<BlockId>,
208208

209209
/// The lint level for this `let` statement.

compiler/rustc_middle/src/ty/adt.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,13 @@ impl<'tcx> AdtDef<'tcx> {
332332
self.flags().contains(AdtFlags::IS_PHANTOM_DATA)
333333
}
334334

335-
/// Returns `true` if this is Box<T>.
335+
/// Returns `true` if this is `Box<T>`.
336336
#[inline]
337337
pub fn is_box(self) -> bool {
338338
self.flags().contains(AdtFlags::IS_BOX)
339339
}
340340

341-
/// Returns `true` if this is UnsafeCell<T>.
341+
/// Returns `true` if this is `UnsafeCell<T>`.
342342
#[inline]
343343
pub fn is_unsafe_cell(self) -> bool {
344344
self.flags().contains(AdtFlags::IS_UNSAFE_CELL)

compiler/rustc_parse/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ mod errors;
3939
// uses a HOF to parse anything, and <source> includes file and
4040
// `source_str`.
4141

42-
/// A variant of 'panictry!' that works on a Vec<Diagnostic> instead of a single DiagnosticBuilder.
42+
/// A variant of 'panictry!' that works on a `Vec<Diagnostic>` instead of a single
43+
/// `DiagnosticBuilder`.
4344
macro_rules! panictry_buffer {
4445
($handler:expr, $e:expr) => {{
4546
use rustc_errors::FatalError;

compiler/rustc_trait_selection/src/traits/auto_trait.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ impl<'tcx> AutoTraitFinder<'tcx> {
6666
/// struct Foo<T> { data: Box<T> }
6767
/// ```
6868
///
69-
/// then this might return that Foo<T>: Send if T: Send (encoded in the AutoTraitResult type).
70-
/// The analysis attempts to account for custom impls as well as other complex cases. This
71-
/// result is intended for use by rustdoc and other such consumers.
69+
/// then this might return that `Foo<T>: Send` if `T: Send` (encoded in the AutoTraitResult
70+
/// type). The analysis attempts to account for custom impls as well as other complex cases.
71+
/// This result is intended for use by rustdoc and other such consumers.
7272
///
7373
/// (Note that due to the coinductive nature of Send, the full and correct result is actually
7474
/// quite simple to generate. That is, when a type has no custom impl, it is Send iff its field
75-
/// types are all Send. So, in our example, we might have that Foo<T>: Send if Box<T>: Send.
75+
/// types are all Send. So, in our example, we might have that `Foo<T>: Send` if `Box<T>: Send`.
7676
/// But this is often not the best way to present to the user.)
7777
///
7878
/// Warning: The API should be considered highly unstable, and it may be refactored or removed

compiler/rustc_trait_selection/src/traits/project.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ enum ProjectionCandidate<'tcx> {
6262
/// From a where-clause in the env or object type
6363
ParamEnv(ty::PolyProjectionPredicate<'tcx>),
6464

65-
/// From the definition of `Trait` when you have something like <<A as Trait>::B as Trait2>::C
65+
/// From the definition of `Trait` when you have something like
66+
/// `<<A as Trait>::B as Trait2>::C`.
6667
TraitDef(ty::PolyProjectionPredicate<'tcx>),
6768

6869
/// Bounds specified on an object type
@@ -1367,7 +1368,7 @@ fn assemble_candidates_from_param_env<'cx, 'tcx>(
13671368
);
13681369
}
13691370

1370-
/// In the case of a nested projection like <<A as Foo>::FooT as Bar>::BarT, we may find
1371+
/// In the case of a nested projection like `<<A as Foo>::FooT as Bar>::BarT`, we may find
13711372
/// that the definition of `Foo` has some clues:
13721373
///
13731374
/// ```ignore (illustrative)

compiler/rustc_trait_selection/src/traits/select/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
826826
/// must be met of course). One obvious case this comes up is
827827
/// marker traits like `Send`. Think of a linked list:
828828
///
829-
/// struct List<T> { data: T, next: Option<Box<List<T>>> }
829+
/// struct List<T> { data: T, next: Option<Box<List<T>>> }
830830
///
831831
/// `Box<List<T>>` will be `Send` if `T` is `Send` and
832832
/// `Option<Box<List<T>>>` is `Send`, and in turn

src/librustdoc/lint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ declare_rustdoc_lint! {
148148
///
149149
/// [rustdoc book]: ../../../rustdoc/lints.html#invalid_html_tags
150150
INVALID_HTML_TAGS,
151-
Allow,
151+
Warn,
152152
"detects invalid HTML tags in doc comments"
153153
}
154154

src/librustdoc/passes/html_tags.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ struct InvalidHtmlTagsLinter<'a, 'tcx> {
2222
}
2323

2424
pub(crate) fn check_invalid_html_tags(krate: Crate, cx: &mut DocContext<'_>) -> Crate {
25-
if cx.tcx.sess.is_nightly_build() {
26-
let mut coll = InvalidHtmlTagsLinter { cx };
27-
coll.visit_crate(&krate);
28-
}
25+
let mut coll = InvalidHtmlTagsLinter { cx };
26+
coll.visit_crate(&krate);
2927
krate
3028
}
3129

src/test/rustdoc-ui/intra-doc/malformed-generics.rs

+9
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,26 @@
33
//! [Vec<] //~ ERROR
44
//! [Vec<Box<T] //~ ERROR
55
//! [Vec<Box<T>] //~ ERROR
6+
//~^ WARN
67
//! [Vec<Box<T>>>] //~ ERROR
8+
//~^ WARN
79
//! [Vec<T>>>] //~ ERROR
10+
//~^ WARN
811
//! [<Vec] //~ ERROR
912
//! [Vec::<] //~ ERROR
1013
//! [<T>] //~ ERROR
14+
//~^ WARN
1115
//! [<invalid syntax>] //~ ERROR
16+
//~^ WARN
1217
//! [Vec:<T>:new()] //~ ERROR
18+
//~^ WARN
1319
//! [Vec<<T>>] //~ ERROR
20+
//~^ WARN
1421
//! [Vec<>] //~ ERROR
1522
//! [Vec<<>>] //~ ERROR
1623
1724
// FIXME(#74563) support UFCS
1825
//! [<Vec as IntoIterator>::into_iter] //~ ERROR
26+
//~^ WARN
1927
//! [<Vec<T> as IntoIterator>::iter] //~ ERROR
28+
//~^ WARN

src/test/rustdoc-ui/intra-doc/malformed-generics.stderr

+69-13
Original file line numberDiff line numberDiff line change
@@ -23,80 +23,136 @@ LL | //! [Vec<Box<T>]
2323
| ^^^^^^^^^^ unbalanced angle brackets
2424

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

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

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

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

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

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

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

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

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

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

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

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

101-
error: aborting due to 15 previous errors
101+
warning: unclosed HTML tag `T`
102+
--> $DIR/malformed-generics.rs:5:13
103+
|
104+
LL | //! [Vec<Box<T>]
105+
| ^^^
106+
|
107+
= note: `#[warn(rustdoc::invalid_html_tags)]` on by default
108+
109+
warning: unclosed HTML tag `T`
110+
--> $DIR/malformed-generics.rs:7:13
111+
|
112+
LL | //! [Vec<Box<T>>>]
113+
| ^^^
114+
115+
warning: unclosed HTML tag `T`
116+
--> $DIR/malformed-generics.rs:9:9
117+
|
118+
LL | //! [Vec<T>>>]
119+
| ^^^
120+
121+
warning: unclosed HTML tag `T`
122+
--> $DIR/malformed-generics.rs:13:6
123+
|
124+
LL | //! [<T>]
125+
| ^^^
126+
127+
warning: unclosed HTML tag `invalid`
128+
--> $DIR/malformed-generics.rs:15:6
129+
|
130+
LL | //! [<invalid syntax>]
131+
| ^^^^^^^^
132+
133+
warning: unclosed HTML tag `T`
134+
--> $DIR/malformed-generics.rs:17:10
135+
|
136+
LL | //! [Vec:<T>:new()]
137+
| ^^^
138+
139+
warning: unclosed HTML tag `T`
140+
--> $DIR/malformed-generics.rs:19:10
141+
|
142+
LL | //! [Vec<<T>>]
143+
| ^^^
144+
145+
warning: unclosed HTML tag `Vec`
146+
--> $DIR/malformed-generics.rs:25:6
147+
|
148+
LL | //! [<Vec as IntoIterator>::into_iter]
149+
| ^^^^
150+
151+
warning: unclosed HTML tag `T`
152+
--> $DIR/malformed-generics.rs:27:10
153+
|
154+
LL | //! [<Vec<T> as IntoIterator>::iter]
155+
| ^^^
156+
157+
error: aborting due to 15 previous errors; 9 warnings emitted
102158

src/test/rustdoc/intra-doc/extern-crate-only-used-in-link.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
//! [`empty`]
1717
1818
// @has - '//a[@href="../empty2/index.html"]' 'empty2'
19-
//! [empty2<x>]
19+
//! [`empty2<x>`]

0 commit comments

Comments
 (0)