Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
f45bdcc
Implement size_hint for BufReader
Xavientois Jan 15, 2021
c3e47d9
Fix implementation to specialize
Xavientois Jan 15, 2021
fa76db3
Use helper trait to follow min_specialization rules
Xavientois Jan 15, 2021
11c49f6
Add missing generic
Xavientois Jan 15, 2021
260a270
Move default to trait definition
Xavientois Jan 15, 2021
5f60a30
Fix incorrect token
Xavientois Jan 15, 2021
eea99f4
Add default keyword for specialization
Xavientois Jan 15, 2021
7e56637
Add back lower_bound as memeber
Xavientois Jan 16, 2021
442de9a
Fix semicolon
Xavientois Jan 16, 2021
1190321
Remove exposing private trait
Xavientois Jan 16, 2021
421b40c
Add dyn for SizeHint cast
Xavientois Jan 16, 2021
265db94
Fix formatting
Xavientois Jan 16, 2021
93870c8
Remove stable annotation
Xavientois Jan 16, 2021
7869371
Remove unnecessary default keyword
Xavientois Jan 16, 2021
c8e0f8a
Use fully qualified syntax to avoid dyn
Xavientois Jan 16, 2021
96255f8
Implement SizeHint trait for BufReader, Emtpy, and Chain
Xavientois Jan 16, 2021
389e638
Add tests for SizeHint implementations
Xavientois Jan 16, 2021
b837f3a
Remove trailing newline
Xavientois Jan 16, 2021
81aba38
Add space for proper indentation
Xavientois Jan 16, 2021
fc9cd4a
Fix formatting on mod
Xavientois Jan 16, 2021
7674ae1
Fix line length format
Xavientois Jan 31, 2021
4cb089b
Inherit `#[stable(..)]` annotations in enum variants and fields from …
estebank Apr 23, 2020
19806e4
Tweak stability attribute diagnostic output
estebank Feb 11, 2021
7b021aa
resolve: Reduce scope of `pub_use_of_private_extern_crate` deprecatio…
petrochenkov Jan 28, 2021
49310ce
Add test for "const stability on macro"
estebank Feb 11, 2021
fbd575a
process::unix: Handle other wait statuses in ExitStatus as Display
ijackson Feb 22, 2021
d8cfd56
process::unix: Test wait status formatting
ijackson Feb 22, 2021
4bb8425
ExitStatus: Improve documentation re wait status vs exit status
ijackson Feb 22, 2021
2f04a79
Revert `Vec::spare_capacity_mut` impl to prevent pointers invalidation
WaffleLapkin Feb 26, 2021
cc62018
Rename rustdoc lints to be a tool lint instead of built-in.
jyn514 Dec 30, 2020
37e4cfe
Move lint machinery into a separate file
jyn514 Dec 30, 2020
7195355
Add `declare_rustdoc_lint!` macro
jyn514 Dec 30, 2020
e8ddfda
Improve error messages
jyn514 Jan 17, 2021
0517ea7
Address review comments
jyn514 Jan 18, 2021
c7535d1
Update comments
jyn514 Jan 19, 2021
75efb6e
Test that using the previous lint names still applies the lint
jyn514 Feb 28, 2021
768d5e9
Load rustdoc's JS search index on-demand.
jsha Feb 20, 2021
9c4e3af
Add test that Vec::spare_capacity_mut doesn't invalidate pointers
WaffleLapkin Mar 2, 2021
a1835bc
Make Vec::split_at_spare_mut impl safer & simplier
WaffleLapkin Mar 2, 2021
d3e7ffa
Improve page load performance in rustdoc.
jsha Feb 20, 2021
f9cfe15
Use Arial as fallback font instead of sans-serif.
jsha Mar 3, 2021
040735c
First version of noop-lint
rylev Jan 5, 2021
f49ed7a
Add tests and support two more noop methods
rylev Jan 5, 2021
a6d926d
Fix tests
rylev Jan 5, 2021
618c395
Bless test where order of error message changed
rylev Jan 6, 2021
3a86184
Fix ui-full-deps suite
rylev Jan 6, 2021
ee65416
Fix core tests
rylev Jan 6, 2021
d3b49c2
Only allow new lint when not bootstrapping - since beta doesn't know …
rylev Jan 7, 2021
c5ff54c
Fix std tests
rylev Jan 7, 2021
217c886
Improve warning
rylev Jan 8, 2021
16c4afb
Fix tidy errors
rylev Jan 8, 2021
95e330b
Update error message
rylev Jan 11, 2021
316e9db
Fix tidy error
rylev Jan 11, 2021
49f32e0
Improve error messages
rylev Jan 12, 2021
e48670c
Increase accuracy of lint trigger
estebank Jan 13, 2021
055db16
Clean up code rightward drift
estebank Jan 13, 2021
4be7052
Allow noop_method_call in clippy ui test
rylev Jan 18, 2021
6bf6652
Move unrelated ui test back to what it was before
rylev Feb 10, 2021
da3995f
Remove lint pass on borrow and deref
rylev Feb 16, 2021
1999a31
Fix borrow and deref
rylev Feb 16, 2021
25637b2
Warn in doc test
rylev Feb 17, 2021
6111445
Add `-Z unpretty` flags for the AST
LeSeulArtichaut Feb 19, 2021
950f121
Update library/alloc/src/vec/mod.rs
WaffleLapkin Mar 3, 2021
5461ee0
rustc_target: add "unwind" payloads to `Abi`
Aug 27, 2020
9a007cf
implement unwinding abi's (RFC 2945)
Sep 10, 2020
0fd2fd9
add integration tests, unwind across FFI boundary
Dec 12, 2020
d8bfdc8
address pr review comments
Oct 23, 2020
229ffc3
Rollup merge of #71481 - estebank:inherit-stability, r=nikomatsakis
Dylan-DPC Mar 4, 2021
045261f
Rollup merge of #76570 - cratelyn:implement-rfc-2945-c-unwind-abi, r=…
Dylan-DPC Mar 4, 2021
ea7c3e7
Rollup merge of #80527 - jyn514:rustdoc-lints, r=GuillaumeGomez
Dylan-DPC Mar 4, 2021
72e5b5a
Rollup merge of #80723 - rylev:noop-lint-pass, r=estebank
Dylan-DPC Mar 4, 2021
cb909a6
Rollup merge of #80763 - petrochenkov:pubusecrate, r=estebank
Dylan-DPC Mar 4, 2021
1dfd766
Rollup merge of #81136 - Xavientois:io_reader_size_hint, r=cramertj
Dylan-DPC Mar 4, 2021
e0ef270
Rollup merge of #82304 - LeSeulArtichaut:unpretty-ast, r=spastorino
Dylan-DPC Mar 4, 2021
4cb61a3
Rollup merge of #82310 - jsha:rustdoc-search-onfocus, r=GuillaumeGomez
Dylan-DPC Mar 4, 2021
ba4ee48
Rollup merge of #82315 - jsha:font-display-swap, r=GuillaumeGomez
Dylan-DPC Mar 4, 2021
ae2482e
Rollup merge of #82411 - ijackson:fix-exitstatus, r=dtolnay
Dylan-DPC Mar 4, 2021
b0b63ec
Rollup merge of #82564 - WaffleLapkin:revert_spare_mut, r=RalfJung
Dylan-DPC Mar 4, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move lint machinery into a separate file
  • Loading branch information
jyn514 committed Mar 2, 2021
commit 37e4cfe5125e1d8d29fd1a66c7f80109c25618fb
175 changes: 7 additions & 168 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ use rustc_hir::{
Path,
};
use rustc_interface::{interface, Queries};
use rustc_lint::LintStore;
use rustc_lint_defs::{declare_tool_lint, Lint, LintId};
use rustc_middle::hir::map::Map;
use rustc_middle::middle::privacy::AccessLevels;
use rustc_middle::ty::{ParamEnv, Ty, TyCtxt};
Expand All @@ -28,7 +26,6 @@ use rustc_span::DUMMY_SP;

use std::cell::RefCell;
use std::collections::hash_map::Entry;
use std::lazy::SyncLazy as Lazy;
use std::mem;
use std::rc::Rc;

Expand Down Expand Up @@ -232,164 +229,6 @@ crate fn new_handler(
)
}

/// This function is used to setup the lint initialization. By default, in rustdoc, everything
/// is "allowed". Depending if we run in test mode or not, we want some of them to be at their
/// default level. For example, the "INVALID_CODEBLOCK_ATTRIBUTES" lint is activated in both
/// modes.
///
/// A little detail easy to forget is that there is a way to set the lint level for all lints
/// through the "WARNINGS" lint. To prevent this to happen, we set it back to its "normal" level
/// inside this function.
///
/// It returns a tuple containing:
/// * Vector of tuples of lints' name and their associated "max" level
/// * HashMap of lint id with their associated "max" level
pub(crate) fn init_lints<F>(
mut allowed_lints: Vec<String>,
lint_opts: Vec<(String, lint::Level)>,
filter_call: F,
) -> (Vec<(String, lint::Level)>, FxHashMap<lint::LintId, lint::Level>)
where
F: Fn(&lint::Lint) -> Option<(String, lint::Level)>,
{
let warnings_lint_name = lint::builtin::WARNINGS.name;

allowed_lints.push(warnings_lint_name.to_owned());
allowed_lints.extend(lint_opts.iter().map(|(lint, _)| lint).cloned());

let lints = || {
lint::builtin::HardwiredLints::get_lints()
.into_iter()
.chain(rustc_lint::SoftLints::get_lints().into_iter())
};

let lint_opts = lints()
.filter_map(|lint| {
// Permit feature-gated lints to avoid feature errors when trying to
// allow all lints.
if lint.feature_gate.is_some() || allowed_lints.iter().any(|l| lint.name == l) {
None
} else {
filter_call(lint)
}
})
.chain(lint_opts.into_iter())
.collect::<Vec<_>>();

let lint_caps = lints()
.filter_map(|lint| {
// We don't want to allow *all* lints so let's ignore
// those ones.
if allowed_lints.iter().any(|l| lint.name == l) {
None
} else {
Some((lint::LintId::of(lint), lint::Allow))
}
})
.collect();
(lint_opts, lint_caps)
}

declare_tool_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 rustdoc::BROKEN_INTRA_DOC_LINKS,
Warn,
"failures in resolving intra-doc link targets"
}

declare_tool_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 rustdoc::PRIVATE_INTRA_DOC_LINKS,
Warn,
"linking from a public item to a private one"
}

declare_tool_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 rustdoc::INVALID_CODEBLOCK_ATTRIBUTES,
Warn,
"codeblock attribute looks a lot like a known one"
}

declare_tool_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 rustdoc::MISSING_DOC_CODE_EXAMPLES,
Allow,
"detects publicly-exported items without code samples in their documentation"
}

declare_tool_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 rustdoc::PRIVATE_DOC_TESTS,
Allow,
"detects code samples in docs of private items not documented by rustdoc"
}

declare_tool_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 rustdoc::INVALID_HTML_TAGS,
Allow,
"detects invalid HTML tags in doc comments"
}

declare_tool_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 rustdoc::NON_AUTOLINKS,
Warn,
"detects URLs that could be written using only angle brackets"
}

static RUSTDOC_LINTS: Lazy<Vec<&'static Lint>> = Lazy::new(|| {
vec![
BROKEN_INTRA_DOC_LINKS,
PRIVATE_INTRA_DOC_LINKS,
MISSING_DOC_CODE_EXAMPLES,
PRIVATE_DOC_TESTS,
INVALID_CODEBLOCK_ATTRIBUTES,
INVALID_HTML_TAGS,
NON_AUTOLINKS,
]
});

crate fn register_lints(_sess: &Session, lint_store: &mut LintStore) {
lint_store.register_lints(&**RUSTDOC_LINTS);
lint_store.register_group(
true,
"rustdoc",
None,
RUSTDOC_LINTS.iter().map(|&lint| LintId::of(lint)).collect(),
);
lint_store
.register_renamed("intra_doc_link_resolution_failure", "rustdoc::broken_intra_doc_links");
}

/// Parse, resolve, and typecheck the given crate.
crate fn create_config(
RustdocOptions {
Expand Down Expand Up @@ -418,8 +257,8 @@ crate fn create_config(
let cpath = Some(input.clone());
let input = Input::File(input);

// In addition to those specific lints, we also need to allow those given through
// command line, otherwise they'll get ignored and we don't want that.
// By default, rustdoc ignores all lints.
// Specifically unblock lints relevant to documentation or the lint machinery itself.
let mut lints_to_show = vec![
// it's unclear whether these should be part of rustdoc directly
rustc_lint::builtin::MISSING_DOCS.name.to_string(),
Expand All @@ -428,12 +267,12 @@ crate fn create_config(
rustc_lint::builtin::RENAMED_AND_REMOVED_LINTS.name.to_string(),
rustc_lint::builtin::UNKNOWN_LINTS.name.to_string(),
];
lints_to_show.extend(RUSTDOC_LINTS.iter().map(|lint| lint.name.to_string()));
lints_to_show.extend(crate::lint::RUSTDOC_LINTS.iter().map(|lint| lint.name.to_string()));

let (lint_opts, lint_caps) = init_lints(lints_to_show, lint_opts, |lint| {
let (lint_opts, lint_caps) = crate::lint::init_lints(lints_to_show, lint_opts, |lint| {
// FIXME: why is this necessary?
if lint.name == BROKEN_INTRA_DOC_LINKS.name
|| lint.name == INVALID_CODEBLOCK_ATTRIBUTES.name
if lint.name == crate::lint::BROKEN_INTRA_DOC_LINKS.name
|| lint.name == crate::lint::INVALID_CODEBLOCK_ATTRIBUTES.name
{
None
} else {
Expand Down Expand Up @@ -474,7 +313,7 @@ crate fn create_config(
diagnostic_output: DiagnosticOutput::Default,
stderr: None,
lint_caps,
register_lints: Some(box register_lints),
register_lints: Some(box crate::lint::register_lints),
override_queries: Some(|_sess, providers, _external_providers| {
// Most lints will require typechecking, so just don't run them.
providers.lint_mod = |_, _| {};
Expand Down
9 changes: 4 additions & 5 deletions src/librustdoc/doctest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ use std::str;

use crate::clean::Attributes;
use crate::config::Options;
use crate::core::init_lints;
use crate::html::markdown::{self, ErrorCodes, Ignore, LangString};
use crate::lint::init_lints;
use crate::passes::span_of_attrs;

#[derive(Clone, Default)]
Expand All @@ -44,10 +44,9 @@ crate struct TestOptions {
crate fn run(options: Options) -> Result<(), ErrorReported> {
let input = config::Input::File(options.input.clone());

let invalid_codeblock_attributes_name = crate::core::INVALID_CODEBLOCK_ATTRIBUTES.name;
let invalid_codeblock_attributes_name = crate::lint::INVALID_CODEBLOCK_ATTRIBUTES.name;

// In addition to those specific lints, we also need to allow those given through
// command line, otherwise they'll get ignored and we don't want that.
// See core::create_config for what's going on here.
let allowed_lints = vec![
invalid_codeblock_attributes_name.to_owned(),
lint::builtin::UNKNOWN_LINTS.name.to_owned(),
Expand Down Expand Up @@ -96,7 +95,7 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
diagnostic_output: DiagnosticOutput::Default,
stderr: None,
lint_caps,
register_lints: Some(box crate::core::register_lints),
register_lints: Some(box crate::lint::register_lints),
override_queries: None,
make_codegen_backend: None,
registry: rustc_driver::diagnostics_registry(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ impl<'tcx> ExtraInfo<'tcx> {
(None, None) => return,
};
self.tcx.struct_span_lint_hir(
crate::core::INVALID_CODEBLOCK_ATTRIBUTES,
crate::lint::INVALID_CODEBLOCK_ATTRIBUTES,
hir_id,
self.sp,
|lint| {
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ mod formats;
// used by the error-index generator, so it needs to be public
pub mod html;
mod json;
crate mod lint;
mod markdown;
mod passes;
mod theme;
Expand Down
Loading