Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b66eb69
Refactored verbose print into a function
hencrice Dec 13, 2020
830ceaa
Remap instrument-coverage line numbers in doctests
Swatinem Dec 6, 2020
f9fa3fe
add an attribute to inner doctest fn
Swatinem Dec 20, 2020
087101e
make path normalization compatible with mac python2
Swatinem Dec 21, 2020
a272d62
Implemented a compiler diagnostic for move async mistake
diondokter Dec 18, 2020
aec3575
Rename rustc_middle::lint::LintSource
pierwill Dec 21, 2020
d3900d3
Document rustc_middle::lint::LevelSource
pierwill Dec 21, 2020
163f5da
Add installation commands to `x` tool README
pierwill Dec 22, 2020
9414f0b
Revert "Remove missing_fragment_specifier lint"
wesleywiser Dec 19, 2020
f1eb88b
Revert "Promote missing_fragment_specifier to hard error"
wesleywiser Dec 19, 2020
56154a1
Add example to lint docs
wesleywiser Dec 21, 2020
a6d377d
Include rustdoc in the compiler docs index.
ehuss Dec 23, 2020
732afd4
Exclude unnecessary info from CodegenResults
Dec 19, 2020
e8a564e
Add a test that rustc compiles and links separately
Dec 23, 2020
1a30823
Improvements to NatVis support
sivadeilra Dec 22, 2020
c625d31
Updated the match with the matches macro
Polkaverse Dec 23, 2020
f459b0f
Addressed feedbacks
hencrice Dec 23, 2020
ecba49c
Fixed formatting
hencrice Dec 23, 2020
68ad606
Add edition 2021.
m-ou-se Nov 30, 2020
0a3ff20
Consistently call editions "Rust 20xx" in messages.
m-ou-se Nov 30, 2020
b3428fc
Require `-Z unstable-options` for unstable editions.
m-ou-se Dec 24, 2020
cfee9fb
Enable OrPatNonterminalMode::TopPat in edition 2021.
m-ou-se Dec 24, 2020
72b0df9
Rollup merge of #79576 - m-ou-se:2021, r=Mark-Simulacrum
Dylan-DPC Dec 24, 2020
2fb533c
Rollup merge of #79762 - Swatinem:remap-doctest-coverage, r=Swatinem
Dylan-DPC Dec 24, 2020
2f2741b
Rollup merge of #79999 - hencrice:yenlinc/79799, r=oli-obk
Dylan-DPC Dec 24, 2020
ba00a23
Rollup merge of #80160 - diondokter:move_async_fix, r=davidtwco
Dylan-DPC Dec 24, 2020
d11537d
Rollup merge of #80187 - 0dvictor:nativelib, r=bjorn3
Dylan-DPC Dec 24, 2020
5a43cec
Rollup merge of #80274 - pierwill:lintlevelsource, r=petrochenkov
Dylan-DPC Dec 24, 2020
b1b78a4
Rollup merge of #80280 - pierwill:x-readme, r=Mark-Simulacrum
Dylan-DPC Dec 24, 2020
58b28e2
Rollup merge of #80296 - wesleywiser:revert_missing_fragment_specifie…
Dylan-DPC Dec 24, 2020
3e8894e
Rollup merge of #80311 - sivadeilra:natvis, r=petrochenkov
Dylan-DPC Dec 24, 2020
f4d9a3d
Rollup merge of #80316 - ehuss:rustdoc-index, r=Mark-Simulacrum
Dylan-DPC Dec 24, 2020
d5f651c
Rollup merge of #80327 - PankajChaudhary5:PankajChaudhary, r=Guillaum…
Dylan-DPC Dec 24, 2020
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
22 changes: 12 additions & 10 deletions compiler/rustc_lint/src/levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ use rustc_hir::{intravisit, HirId};
use rustc_middle::hir::map::Map;
use rustc_middle::lint::LevelSource;
use rustc_middle::lint::LintDiagnosticBuilder;
use rustc_middle::lint::{struct_lint_level, LintLevelMap, LintLevelSets, LintSet, LintSource};
use rustc_middle::lint::{
struct_lint_level, LintLevelMap, LintLevelSets, LintLevelSource, LintSet,
};
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::TyCtxt;
use rustc_session::lint::{builtin, Level, Lint, LintId};
Expand Down Expand Up @@ -91,7 +93,7 @@ impl<'s> LintLevelsBuilder<'s> {
};
for id in ids {
self.check_gated_lint(id, DUMMY_SP);
let src = LintSource::CommandLine(lint_flag_val, orig_level);
let src = LintLevelSource::CommandLine(lint_flag_val, orig_level);
specs.insert(id, (level, src));
}
}
Expand Down Expand Up @@ -128,19 +130,19 @@ impl<'s> LintLevelsBuilder<'s> {
);
diag_builder.span_label(src.span(), "overruled by previous forbid");
match old_src {
LintSource::Default => {
LintLevelSource::Default => {
diag_builder.note(&format!(
"`forbid` lint level is the default for {}",
id.to_string()
));
}
LintSource::Node(_, forbid_source_span, reason) => {
LintLevelSource::Node(_, forbid_source_span, reason) => {
diag_builder.span_label(forbid_source_span, "`forbid` level set here");
if let Some(rationale) = reason {
diag_builder.note(&rationale.as_str());
}
}
LintSource::CommandLine(_, _) => {
LintLevelSource::CommandLine(_, _) => {
diag_builder.note("`forbid` lint level was set on command line");
}
}
Expand Down Expand Up @@ -276,7 +278,7 @@ impl<'s> LintLevelsBuilder<'s> {
let name = meta_item.path.segments.last().expect("empty lint name").ident.name;
match store.check_lint_name(&name.as_str(), tool_name) {
CheckLintNameResult::Ok(ids) => {
let src = LintSource::Node(name, li.span(), reason);
let src = LintLevelSource::Node(name, li.span(), reason);
for &id in ids {
self.check_gated_lint(id, attr.span);
self.insert_spec(&mut specs, id, (level, src));
Expand All @@ -287,7 +289,7 @@ impl<'s> LintLevelsBuilder<'s> {
match result {
Ok(ids) => {
let complete_name = &format!("{}::{}", tool_name.unwrap(), name);
let src = LintSource::Node(
let src = LintLevelSource::Node(
Symbol::intern(complete_name),
li.span(),
reason,
Expand Down Expand Up @@ -324,7 +326,7 @@ impl<'s> LintLevelsBuilder<'s> {
},
);

let src = LintSource::Node(
let src = LintLevelSource::Node(
Symbol::intern(&new_lint_name),
li.span(),
reason,
Expand Down Expand Up @@ -403,7 +405,7 @@ impl<'s> LintLevelsBuilder<'s> {
}

let (lint_attr_name, lint_attr_span) = match *src {
LintSource::Node(name, span, _) => (name, span),
LintLevelSource::Node(name, span, _) => (name, span),
_ => continue,
};

Expand Down Expand Up @@ -460,7 +462,7 @@ impl<'s> LintLevelsBuilder<'s> {
}

/// Find the lint level for a lint.
pub fn lint_level(&self, lint: &'static Lint) -> (Level, LintSource) {
pub fn lint_level(&self, lint: &'static Lint) -> (Level, LintLevelSource) {
self.sets.get_lint_level(lint, self.cur, None, self.sess)
}

Expand Down
33 changes: 17 additions & 16 deletions compiler/rustc_middle/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc_span::{symbol, Span, Symbol, DUMMY_SP};

/// How a lint level was set.
#[derive(Clone, Copy, PartialEq, Eq, HashStable)]
pub enum LintSource {
pub enum LintLevelSource {
/// Lint is at the default level as declared
/// in rustc or a plugin.
Default,
Expand All @@ -27,25 +27,26 @@ pub enum LintSource {
CommandLine(Symbol, Level),
}

impl LintSource {
impl LintLevelSource {
pub fn name(&self) -> Symbol {
match *self {
LintSource::Default => symbol::kw::Default,
LintSource::Node(name, _, _) => name,
LintSource::CommandLine(name, _) => name,
LintLevelSource::Default => symbol::kw::Default,
LintLevelSource::Node(name, _, _) => name,
LintLevelSource::CommandLine(name, _) => name,
}
}

pub fn span(&self) -> Span {
match *self {
LintSource::Default => DUMMY_SP,
LintSource::Node(_, span, _) => span,
LintSource::CommandLine(_, _) => DUMMY_SP,
LintLevelSource::Default => DUMMY_SP,
LintLevelSource::Node(_, span, _) => span,
LintLevelSource::CommandLine(_, _) => DUMMY_SP,
}
}
}

pub type LevelSource = (Level, LintSource);
/// A tuple of a lint level and its source.
pub type LevelSource = (Level, LintLevelSource);

pub struct LintLevelSets {
pub list: Vec<LintSet>,
Expand Down Expand Up @@ -113,7 +114,7 @@ impl LintLevelSets {
id: LintId,
mut idx: u32,
aux: Option<&FxHashMap<LintId, LevelSource>>,
) -> (Option<Level>, LintSource) {
) -> (Option<Level>, LintLevelSource) {
if let Some(specs) = aux {
if let Some(&(level, src)) = specs.get(&id) {
return (Some(level), src);
Expand All @@ -125,7 +126,7 @@ impl LintLevelSets {
if let Some(&(level, src)) = specs.get(&id) {
return (Some(level), src);
}
return (None, LintSource::Default);
return (None, LintLevelSource::Default);
}
LintSet::Node { ref specs, parent } => {
if let Some(&(level, src)) = specs.get(&id) {
Expand Down Expand Up @@ -213,7 +214,7 @@ pub fn struct_lint_level<'s, 'd>(
sess: &'s Session,
lint: &'static Lint,
level: Level,
src: LintSource,
src: LintLevelSource,
span: Option<MultiSpan>,
decorate: impl for<'a> FnOnce(LintDiagnosticBuilder<'a>) + 'd,
) {
Expand All @@ -223,7 +224,7 @@ pub fn struct_lint_level<'s, 'd>(
sess: &'s Session,
lint: &'static Lint,
level: Level,
src: LintSource,
src: LintLevelSource,
span: Option<MultiSpan>,
decorate: Box<dyn for<'b> FnOnce(LintDiagnosticBuilder<'b>) + 'd>,
) {
Expand Down Expand Up @@ -274,14 +275,14 @@ pub fn struct_lint_level<'s, 'd>(

let name = lint.name_lower();
match src {
LintSource::Default => {
LintLevelSource::Default => {
sess.diag_note_once(
&mut err,
DiagnosticMessageId::from(lint),
&format!("`#[{}({})]` on by default", level.as_str(), name),
);
}
LintSource::CommandLine(lint_flag_val, orig_level) => {
LintLevelSource::CommandLine(lint_flag_val, orig_level) => {
let flag = match orig_level {
Level::Warn => "-W",
Level::Deny => "-D",
Expand Down Expand Up @@ -310,7 +311,7 @@ pub fn struct_lint_level<'s, 'd>(
);
}
}
LintSource::Node(lint_attr_name, src, reason) => {
LintLevelSource::Node(lint_attr_name, src, reason) => {
if let Some(rationale) = reason {
err.note(&rationale.as_str());
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::dep_graph::{self, DepGraph, DepKind, DepNode, DepNodeExt};
use crate::hir::exports::ExportMap;
use crate::ich::{NodeIdHashingMode, StableHashingContext};
use crate::infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos};
use crate::lint::{struct_lint_level, LintDiagnosticBuilder, LintSource};
use crate::lint::{struct_lint_level, LintDiagnosticBuilder, LintLevelSource};
use crate::middle;
use crate::middle::cstore::{CrateStoreDyn, EncodedMetadata};
use crate::middle::resolve_lifetime::{self, ObjectLifetimeDefault};
Expand Down Expand Up @@ -2559,7 +2559,7 @@ impl<'tcx> TyCtxt<'tcx> {
self,
lint: &'static Lint,
mut id: hir::HirId,
) -> (Level, LintSource) {
) -> (Level, LintLevelSource) {
let sets = self.lint_levels(LOCAL_CRATE);
loop {
if let Some(pair) = sets.level_and_source(lint, id, self.sess) {
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/passes/calculate_doc_coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::html::markdown::{find_testable_code, ErrorCodes};
use crate::passes::doc_test_lints::{should_have_doc_example, Tests};
use crate::passes::Pass;
use rustc_lint::builtin::MISSING_DOCS;
use rustc_middle::lint::LintSource;
use rustc_middle::lint::LintLevelSource;
use rustc_session::lint;
use rustc_span::symbol::sym;
use rustc_span::FileName;
Expand Down Expand Up @@ -254,7 +254,7 @@ impl<'a, 'b> fold::DocFolder for CoverageCalculator<'a, 'b> {
// `missing_docs` is allow-by-default, so don't treat this as ignoring the item
// unless the user had an explicit `allow`
let should_have_docs =
level != lint::Level::Allow || matches!(source, LintSource::Default);
level != lint::Level::Allow || matches!(source, LintLevelSource::Default);
debug!("counting {:?} {:?} in {}", i.type_(), i.name, filename);
self.items.entry(filename).or_default().count_item(
has_docs,
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/passes/doc_test_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::clean::*;
use crate::core::DocContext;
use crate::fold::DocFolder;
use crate::html::markdown::{find_testable_code, ErrorCodes, Ignore, LangString};
use rustc_middle::lint::LintSource;
use rustc_middle::lint::LintLevelSource;
use rustc_session::lint;

crate const CHECK_PRIVATE_ITEMS_DOC_TESTS: Pass = Pass {
Expand Down Expand Up @@ -77,7 +77,7 @@ crate fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -> boo
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(item.def_id.expect_local());
let (level, source) =
cx.tcx.lint_level_at_node(lint::builtin::MISSING_DOC_CODE_EXAMPLES, hir_id);
level != lint::Level::Allow || matches!(source, LintSource::Default)
level != lint::Level::Allow || matches!(source, LintLevelSource::Default)
}

crate fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) {
Expand Down