diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_ast/src/attr/mod.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_error_codes/src/lib.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_feature/src/accepted.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/context.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/lib.rs | 38 | ||||
| -rw-r--r-- | compiler/rustc_lint_defs/src/builtin.rs | 95 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/late/diagnostics.rs | 29 | ||||
| -rw-r--r-- | compiler/rustc_span/src/symbol.rs | 1 |
8 files changed, 54 insertions, 122 deletions
diff --git a/compiler/rustc_ast/src/attr/mod.rs b/compiler/rustc_ast/src/attr/mod.rs index 52ac7540f69..1e224dbf833 100644 --- a/compiler/rustc_ast/src/attr/mod.rs +++ b/compiler/rustc_ast/src/attr/mod.rs @@ -34,7 +34,7 @@ impl MarkedAttrs { } pub fn is_known_lint_tool(m_item: Ident) -> bool { - [sym::clippy, sym::rustc].contains(&m_item.name) + [sym::clippy, sym::rustc, sym::rustdoc].contains(&m_item.name) } impl NestedMetaItem { diff --git a/compiler/rustc_error_codes/src/lib.rs b/compiler/rustc_error_codes/src/lib.rs index e4a70253144..14ddb3e2079 100644 --- a/compiler/rustc_error_codes/src/lib.rs +++ b/compiler/rustc_error_codes/src/lib.rs @@ -1,4 +1,5 @@ -#![deny(invalid_codeblock_attributes)] +#![cfg_attr(bootstrap, deny(invalid_codeblock_attributes))] +#![cfg_attr(not(bootstrap), deny(rustdoc::invalid_codeblock_attributes))] //! This library is used to gather all error codes into one place, //! the goal being to make their maintenance easier. diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index aa54ffb132d..5012d500cee 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -272,7 +272,7 @@ declare_features! ( (accepted, doc_alias, "1.48.0", Some(50146), None), /// Allows patterns with concurrent by-move and by-ref bindings. /// For example, you can write `Foo(a, ref b)` where `a` is by-move and `b` is by-ref. - (accepted, move_ref_pattern, "1.48.0", Some(68354), None), + (accepted, move_ref_pattern, "1.49.0", Some(68354), None), /// The smallest useful subset of `const_generics`. (accepted, min_const_generics, "1.51.0", Some(74878), None), diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index b8db51f590d..7d5577cdca6 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -89,6 +89,7 @@ impl SessionLintStore for LintStore { } /// The target of the `by_name` map, which accounts for renaming/deprecation. +#[derive(Debug)] enum TargetLint { /// A direct lint target Id(LintId), @@ -470,7 +471,10 @@ impl LintStore { Some(&Id(ref id)) => { CheckLintNameResult::Tool(Err((Some(slice::from_ref(id)), complete_name))) } - _ => CheckLintNameResult::NoLint(None), + Some(other) => { + tracing::debug!("got renamed lint {:?}", other); + CheckLintNameResult::NoLint(None) + } } } } diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 638b73c27a8..547779dd685 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -69,9 +69,7 @@ use rustc_hir::def_id::LocalDefId; use rustc_middle::ty::query::Providers; use rustc_middle::ty::TyCtxt; use rustc_session::lint::builtin::{ - BARE_TRAIT_OBJECTS, BROKEN_INTRA_DOC_LINKS, ELIDED_LIFETIMES_IN_PATHS, - EXPLICIT_OUTLIVES_REQUIREMENTS, INVALID_CODEBLOCK_ATTRIBUTES, INVALID_HTML_TAGS, - MISSING_DOC_CODE_EXAMPLES, NON_AUTOLINKS, PRIVATE_DOC_TESTS, + BARE_TRAIT_OBJECTS, ELIDED_LIFETIMES_IN_PATHS, EXPLICIT_OUTLIVES_REQUIREMENTS, }; use rustc_span::symbol::{Ident, Symbol}; use rustc_span::Span; @@ -314,17 +312,6 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) { // MACRO_USE_EXTERN_CRATE ); - add_lint_group!( - "rustdoc", - NON_AUTOLINKS, - BROKEN_INTRA_DOC_LINKS, - PRIVATE_INTRA_DOC_LINKS, - INVALID_CODEBLOCK_ATTRIBUTES, - MISSING_DOC_CODE_EXAMPLES, - PRIVATE_DOC_TESTS, - INVALID_HTML_TAGS - ); - // Register renamed and removed lints. store.register_renamed("single_use_lifetime", "single_use_lifetimes"); store.register_renamed("elided_lifetime_in_path", "elided_lifetimes_in_paths"); @@ -334,8 +321,29 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) { store.register_renamed("async_idents", "keyword_idents"); store.register_renamed("exceeding_bitshifts", "arithmetic_overflow"); store.register_renamed("redundant_semicolon", "redundant_semicolons"); - store.register_renamed("intra_doc_link_resolution_failure", "broken_intra_doc_links"); store.register_renamed("overlapping_patterns", "overlapping_range_endpoints"); + + // These were moved to tool lints, but rustc still sees them when compiling normally, before + // tool lints are registered, so `check_tool_name_for_backwards_compat` doesn't work. Use + // `register_removed` explicitly. + const RUSTDOC_LINTS: &[&str] = &[ + "broken_intra_doc_links", + "private_intra_doc_links", + "missing_crate_level_docs", + "missing_doc_code_examples", + "private_doc_tests", + "invalid_codeblock_attributes", + "invalid_html_tags", + "non_autolinks", + ]; + for rustdoc_lint in RUSTDOC_LINTS { + store.register_removed(rustdoc_lint, &format!("use `rustdoc::{}` instead", rustdoc_lint)); + } + store.register_removed( + "intra_doc_link_resolution_failure", + "use `rustdoc::broken_intra_doc_links` instead", + ); + store.register_removed("unknown_features", "replaced by an error"); store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate"); store.register_removed("negate_unsigned", "cast a signed value instead"); diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 46138df07bf..12d849e3b94 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -1876,93 +1876,6 @@ declare_lint! { } declare_lint! { - /// The `broken_intra_doc_links` lint detects failures in resolving - /// intra-doc link targets. This is a `rustdoc` only lint, see the - /// documentation in the [rustdoc book]. - /// - /// [rustdoc book]: ../../../rustdoc/lints.html#broken_intra_doc_links - pub BROKEN_INTRA_DOC_LINKS, - Warn, - "failures in resolving intra-doc link targets" -} - -declare_lint! { - /// This is a subset of `broken_intra_doc_links` that warns when linking from - /// a public item to a private one. This is a `rustdoc` only lint, see the - /// documentation in the [rustdoc book]. - /// - /// [rustdoc book]: ../../../rustdoc/lints.html#private_intra_doc_links - pub PRIVATE_INTRA_DOC_LINKS, - Warn, - "linking from a public item to a private one" -} - -declare_lint! { - /// The `invalid_codeblock_attributes` lint detects code block attributes - /// in documentation examples that have potentially mis-typed values. This - /// is a `rustdoc` only lint, see the documentation in the [rustdoc book]. - /// - /// [rustdoc book]: ../../../rustdoc/lints.html#invalid_codeblock_attributes - pub INVALID_CODEBLOCK_ATTRIBUTES, - Warn, - "codeblock attribute looks a lot like a known one" -} - -declare_lint! { - /// The `missing_crate_level_docs` lint detects if documentation is - /// missing at the crate root. This is a `rustdoc` only lint, see the - /// documentation in the [rustdoc book]. - /// - /// [rustdoc book]: ../../../rustdoc/lints.html#missing_crate_level_docs - pub MISSING_CRATE_LEVEL_DOCS, - Allow, - "detects crates with no crate-level documentation" -} - -declare_lint! { - /// The `missing_doc_code_examples` lint detects publicly-exported items - /// without code samples in their documentation. This is a `rustdoc` only - /// lint, see the documentation in the [rustdoc book]. - /// - /// [rustdoc book]: ../../../rustdoc/lints.html#missing_doc_code_examples - pub MISSING_DOC_CODE_EXAMPLES, - Allow, - "detects publicly-exported items without code samples in their documentation" -} - -declare_lint! { - /// The `private_doc_tests` lint detects code samples in docs of private - /// items not documented by `rustdoc`. This is a `rustdoc` only lint, see - /// the documentation in the [rustdoc book]. - /// - /// [rustdoc book]: ../../../rustdoc/lints.html#private_doc_tests - pub PRIVATE_DOC_TESTS, - Allow, - "detects code samples in docs of private items not documented by rustdoc" -} - -declare_lint! { - /// The `invalid_html_tags` lint detects invalid HTML tags. This is a - /// `rustdoc` only lint, see the documentation in the [rustdoc book]. - /// - /// [rustdoc book]: ../../../rustdoc/lints.html#invalid_html_tags - pub INVALID_HTML_TAGS, - Allow, - "detects invalid HTML tags in doc comments" -} - -declare_lint! { - /// The `non_autolinks` lint detects when a URL could be written using - /// only angle brackets. This is a `rustdoc` only lint, see the - /// documentation in the [rustdoc book]. - /// - /// [rustdoc book]: ../../../rustdoc/lints.html#non_autolinks - pub NON_AUTOLINKS, - Warn, - "detects URLs that could be written using only angle brackets" -} - -declare_lint! { /// The `where_clauses_object_safety` lint detects for [object safety] of /// [where clauses]. /// @@ -3020,14 +2933,6 @@ declare_lint_pass! { ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE, UNSTABLE_NAME_COLLISIONS, IRREFUTABLE_LET_PATTERNS, - BROKEN_INTRA_DOC_LINKS, - PRIVATE_INTRA_DOC_LINKS, - INVALID_CODEBLOCK_ATTRIBUTES, - MISSING_CRATE_LEVEL_DOCS, - MISSING_DOC_CODE_EXAMPLES, - INVALID_HTML_TAGS, - PRIVATE_DOC_TESTS, - NON_AUTOLINKS, WHERE_CLAUSES_OBJECT_SAFETY, PROC_MACRO_DERIVE_RESOLUTION_FALLBACK, MACRO_USE_EXTERN_CRATE, diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index d60f929cb8f..87bf79d722b 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -1645,6 +1645,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { ); err.span_label(lifetime_ref.span, "undeclared lifetime"); let mut suggests_in_band = false; + let mut suggest_note = true; for missing in &self.missing_named_lifetime_spots { match missing { MissingLifetimeSpot::Generics(generics) => { @@ -1664,12 +1665,24 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { suggests_in_band = true; (generics.span, format!("<{}>", lifetime_ref)) }; - err.span_suggestion( - span, - &format!("consider introducing lifetime `{}` here", lifetime_ref), - sugg, - Applicability::MaybeIncorrect, - ); + if !span.from_expansion() { + err.span_suggestion( + span, + &format!("consider introducing lifetime `{}` here", lifetime_ref), + sugg, + Applicability::MaybeIncorrect, + ); + } else if suggest_note { + suggest_note = false; // Avoid displaying the same help multiple times. + err.span_label( + span, + &format!( + "lifetime `{}` is missing in item created through this procedural \ + macro", + lifetime_ref, + ), + ); + } } MissingLifetimeSpot::HigherRanked { span, span_type } => { err.span_suggestion( @@ -1684,7 +1697,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { ); err.note( "for more information on higher-ranked polymorphism, visit \ - https://doc.rust-lang.org/nomicon/hrtb.html", + https://doc.rust-lang.org/nomicon/hrtb.html", ); } _ => {} @@ -1696,7 +1709,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { { err.help( "if you want to experiment with in-band lifetime bindings, \ - add `#![feature(in_band_lifetimes)]` to the crate attributes", + add `#![feature(in_band_lifetimes)]` to the crate attributes", ); } err.emit(); diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 27bb45bcc85..f9af0886a95 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1021,6 +1021,7 @@ symbols! { rustc_then_this_would_need, rustc_unsafe_specialization_marker, rustc_variance, + rustdoc, rustfmt, rvalue_static_promotion, sanitize, |
