Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
70af5cf
Move deref-patterns tests to pattern sub directory
reddevilmidzy Apr 7, 2026
df2fe31
Fix format and bless test
reddevilmidzy Apr 7, 2026
d2e978e
Move unknown_lints tests into lint/unknown-lints dir
reddevilmidzy Apr 10, 2026
e110275
Clean up unknown-lints ui tests
reddevilmidzy Apr 10, 2026
7c23ee6
Move reserved tests to keyword
reddevilmidzy Apr 10, 2026
07d015e
Syntactically reject tuple index shorthands in struct patterns to fix…
fmease Apr 23, 2026
87b0ce5
Remove `AttributeLintKind::MissingOptionsForDiagnosticAttribute` variant
GuillaumeGomez Apr 23, 2026
7a07b79
Remove `AttributeLintKind::NonMetaItemDiagnosticAttribute` variant
GuillaumeGomez Apr 23, 2026
874b7d3
Remove myself as a maintainer of `wasm32-wasip1-threads`
alexcrichton Apr 23, 2026
804e419
Eliminate `CrateMetadataRef`.
nnethercote Apr 22, 2026
70fe8a6
Add `Sender` diagnostic item for `std::sync::mpsc::Sender`
cammeresi Apr 23, 2026
bcb1af0
Forbid `*-pass` and `*-fail` directives in tests/crashes
Zalathar Apr 22, 2026
4b1f392
Avoid query cycles in DataflowConstProp
saethlin Apr 24, 2026
7ba9478
Implement `Read`/`Write`/`Seek` for `Arc<T>`
bushrat011899 Apr 23, 2026
e002c6c
Rollup merge of #155684 - bushrat011899:blanket_io_seek_for_ref, r=jh…
jhpratt Apr 24, 2026
b9cf909
Rollup merge of #155081 - reddevilmidzy:ui-fixme, r=Kivooeo
jhpratt Apr 24, 2026
cdba0ce
Rollup merge of #155379 - ashivaram23:mir-query-cycle, r=saethlin
jhpratt Apr 24, 2026
0c25381
Rollup merge of #155663 - nnethercote:eliminate-CrateMetadataRef, r=m…
jhpratt Apr 24, 2026
46362de
Rollup merge of #155669 - cammeresi:20260422-sender-diag, r=mejrs
jhpratt Apr 24, 2026
1230f74
Rollup merge of #155698 - fmease:no-struct-pat-tuple-index-shorthand,…
jhpratt Apr 24, 2026
7127505
Rollup merge of #155703 - alexcrichton:remove-myself-from-wasm32-wasi…
jhpratt Apr 24, 2026
87c27a9
Rollup merge of #155706 - GuillaumeGomez:rm-attributelintkind, r=Jona…
jhpratt Apr 24, 2026
a2622ef
Rollup merge of #155712 - Zalathar:crashes, r=jieyouxu
jhpratt Apr 24, 2026
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
20 changes: 12 additions & 8 deletions compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_hir::attrs::diagnostic::{
Directive, FilterFormatString, Flag, FormatArg, FormatString, LitOrArg, Name, NameValue,
OnUnimplementedCondition, Piece, Predicate,
};
use rustc_hir::lints::{AttributeLintKind, FormatWarning};
use rustc_hir::lints::FormatWarning;
use rustc_macros::Diagnostic;
use rustc_parse_format::{
Argument, FormatSpec, ParseError, ParseMode, Parser, Piece as RpfPiece, Position,
Expand All @@ -20,7 +20,8 @@ use thin_vec::{ThinVec, thin_vec};
use crate::context::{AcceptContext, Stage};
use crate::errors::{
DisallowedPlaceholder, DisallowedPositionalArgument, IgnoredDiagnosticOption,
InvalidFormatSpecifier, MalFormedDiagnosticAttributeLint, WrappedParserError,
InvalidFormatSpecifier, MalFormedDiagnosticAttributeLint, MissingOptionsForDiagnosticAttribute,
NonMetaItemDiagnosticAttribute, WrappedParserError,
};
use crate::parser::{ArgParser, MetaItemListParser, MetaItemOrLitParser, MetaItemParser};

Expand Down Expand Up @@ -144,18 +145,21 @@ fn parse_list<'p, S: Stage>(
// We're dealing with `#[diagnostic::attr()]`.
// This can be because that is what the user typed, but that's also what we'd see
// if the user used non-metaitem syntax. See `ArgParser::from_attr_args`.
cx.emit_lint(
cx.emit_dyn_lint(
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
AttributeLintKind::NonMetaItemDiagnosticAttribute,
move |dcx, level| NonMetaItemDiagnosticAttribute.into_diag(dcx, level),
list.span,
);
}
ArgParser::NoArgs => {
cx.emit_lint(
cx.emit_dyn_lint(
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
AttributeLintKind::MissingOptionsForDiagnosticAttribute {
attribute: mode.as_str(),
options: mode.expected_options(),
move |dcx, level| {
MissingOptionsForDiagnosticAttribute {
attribute: mode.as_str(),
options: mode.expected_options(),
}
.into_diag(dcx, level)
},
span,
);
Expand Down
15 changes: 15 additions & 0 deletions compiler/rustc_attr_parsing/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,3 +392,18 @@ pub(crate) struct IgnoredDiagnosticOption {
#[label("`{$option_name}` is later redundantly declared here")]
pub later_span: Span,
}

#[derive(Diagnostic)]
#[diag("missing options for `{$attribute}` attribute")]
#[help("{$options}")]
pub(crate) struct MissingOptionsForDiagnosticAttribute {
pub attribute: &'static str,
pub options: &'static str,
}

#[derive(Diagnostic)]
#[diag("expected a literal or missing delimiter")]
#[help(
"only literals are allowed as values for the `message`, `note` and `label` options. These options must be separated by a comma"
)]
pub(crate) struct NonMetaItemDiagnosticAttribute;
10 changes: 0 additions & 10 deletions compiler/rustc_lint/src/early/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use rustc_hir::lints::AttributeLintKind;
use rustc_middle::ty::TyCtxt;
use rustc_session::Session;

use crate::lints;

mod check_cfg;

pub struct DiagAndSess<'sess> {
Expand Down Expand Up @@ -42,14 +40,6 @@ impl<'a> Diagnostic<'a, ()> for DecorateAttrLint<'_, '_, '_> {
check_cfg::unexpected_cfg_value(self.sess, self.tcx, name, value)
.into_diag(dcx, level)
}

&AttributeLintKind::MissingOptionsForDiagnosticAttribute { attribute, options } => {
lints::MissingOptionsForDiagnosticAttribute { attribute, options }
.into_diag(dcx, level)
}
&AttributeLintKind::NonMetaItemDiagnosticAttribute => {
lints::NonMetaItemDiagnosticAttribute.into_diag(dcx, level)
}
}
}
}
15 changes: 0 additions & 15 deletions compiler/rustc_lint/src/lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3282,22 +3282,7 @@ impl Subdiagnostic for MismatchedLifetimeSyntaxesSuggestion {
}
}

#[derive(Diagnostic)]
#[diag("missing options for `{$attribute}` attribute")]
#[help("{$options}")]
pub(crate) struct MissingOptionsForDiagnosticAttribute {
pub attribute: &'static str,
pub options: &'static str,
}

#[derive(Diagnostic)]
#[diag("`Eq::assert_receiver_is_total_eq` should never be implemented by hand")]
#[note("this method was used to add checks to the `Eq` derive macro")]
pub(crate) struct EqInternalMethodImplemented;

#[derive(Diagnostic)]
#[diag("expected a literal or missing delimiter")]
#[help(
"only literals are allowed as values for the `message`, `note` and `label` options. These options must be separated by a comma"
)]
pub(crate) struct NonMetaItemDiagnosticAttribute;
2 changes: 0 additions & 2 deletions compiler/rustc_lint_defs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,6 @@ pub enum DeprecatedSinceKind {
pub enum AttributeLintKind {
UnexpectedCfgName((Symbol, Span), Option<(Symbol, Span)>),
UnexpectedCfgValue((Symbol, Span), Option<(Symbol, Span)>),
MissingOptionsForDiagnosticAttribute { attribute: &'static str, options: &'static str },
NonMetaItemDiagnosticAttribute,
}

#[derive(Debug, Clone, HashStable_Generic)]
Expand Down
54 changes: 17 additions & 37 deletions compiler/rustc_metadata/src/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,6 @@ enum LoadResult {
Loaded(Library),
}

/// A reference to `CrateMetadata` that can also give access to whole crate store when necessary.
#[derive(Clone, Copy)]
pub(crate) struct CrateMetadataRef<'a> {
pub cdata: &'a CrateMetadata,
pub cstore: &'a CStore,
}

impl std::ops::Deref for CrateMetadataRef<'_> {
type Target = CrateMetadata;

fn deref(&self) -> &Self::Target {
self.cdata
}
}

struct CrateDump<'a>(&'a CStore);

impl<'a> std::fmt::Debug for CrateDump<'a> {
Expand Down Expand Up @@ -245,11 +230,8 @@ impl CStore {
self.metas[cnum].is_some()
}

pub(crate) fn get_crate_data(&self, cnum: CrateNum) -> CrateMetadataRef<'_> {
let cdata = self.metas[cnum]
.as_ref()
.unwrap_or_else(|| panic!("Failed to get crate data for {cnum:?}"));
CrateMetadataRef { cdata, cstore: self }
pub(crate) fn get_crate_data(&self, cnum: CrateNum) -> &CrateMetadata {
self.metas[cnum].as_ref().unwrap_or_else(|| panic!("Failed to get crate data for {cnum:?}"))
}

pub(crate) fn get_crate_data_mut(&mut self, cnum: CrateNum) -> &mut CrateMetadata {
Expand Down Expand Up @@ -284,14 +266,13 @@ impl CStore {
}

pub fn all_proc_macro_def_ids(&self, tcx: TyCtxt<'_>) -> impl Iterator<Item = DefId> {
self.iter_crate_data()
.flat_map(move |(krate, data)| data.proc_macros_for_crate(tcx, krate, self))
self.iter_crate_data().flat_map(move |(krate, data)| data.proc_macros_for_crate(tcx, krate))
}

fn push_dependencies_in_postorder(&self, deps: &mut IndexSet<CrateNum>, cnum: CrateNum) {
if !deps.contains(&cnum) {
let data = self.get_crate_data(cnum);
for dep in data.dependencies() {
let cdata = self.get_crate_data(cnum);
for dep in cdata.dependencies() {
if dep != cnum {
self.push_dependencies_in_postorder(deps, dep);
}
Expand Down Expand Up @@ -676,7 +657,6 @@ impl CStore {

let crate_metadata = CrateMetadata::new(
tcx,
self,
metadata,
crate_root,
raw_proc_macros,
Expand Down Expand Up @@ -865,12 +845,12 @@ impl CStore {
// `private-dependency` when `register_crate` is called for the first time. Then it must be updated to
// `public-dependency` here.
let private_dep = self.is_private_dep(&tcx.sess.opts.externs, name, private_dep);
let data = self.get_crate_data_mut(cnum);
if data.is_proc_macro_crate() {
let cdata = self.get_crate_data_mut(cnum);
if cdata.is_proc_macro_crate() {
dep_kind = CrateDepKind::MacrosOnly;
}
data.set_dep_kind(cmp::max(data.dep_kind(), dep_kind));
data.update_and_private_dep(private_dep);
cdata.set_dep_kind(cmp::max(cdata.dep_kind(), dep_kind));
cdata.update_and_private_dep(private_dep);
Ok(cnum)
}
(LoadResult::Loaded(library), host_library) => {
Expand Down Expand Up @@ -1045,14 +1025,14 @@ impl CStore {
) else {
return;
};
let data = self.get_crate_data(cnum);
let cdata = self.get_crate_data(cnum);

// Sanity check the loaded crate to ensure it is indeed a panic runtime
// and the panic strategy is indeed what we thought it was.
if !data.is_panic_runtime() {
if !cdata.is_panic_runtime() {
tcx.dcx().emit_err(errors::CrateNotPanicRuntime { crate_name: name });
}
if data.required_panic_strategy() != Some(desired_strategy) {
if cdata.required_panic_strategy() != Some(desired_strategy) {
tcx.dcx()
.emit_err(errors::NoPanicStrategy { crate_name: name, strategy: desired_strategy });
}
Expand Down Expand Up @@ -1086,10 +1066,10 @@ impl CStore {
) else {
return;
};
let data = self.get_crate_data(cnum);
let cdata = self.get_crate_data(cnum);

// Sanity check the loaded crate to ensure it is indeed a profiler runtime
if !data.is_profiler_runtime() {
if !cdata.is_profiler_runtime() {
tcx.dcx().emit_err(errors::NotProfilerRuntime { crate_name: name });
}
}
Expand Down Expand Up @@ -1243,9 +1223,9 @@ impl CStore {
};

// Sanity check that the loaded crate is `#![compiler_builtins]`
let cmeta = self.get_crate_data(cnum);
if !cmeta.is_compiler_builtins() {
tcx.dcx().emit_err(errors::CrateNotCompilerBuiltins { crate_name: cmeta.name() });
let cdata = self.get_crate_data(cnum);
if !cdata.is_compiler_builtins() {
tcx.dcx().emit_err(errors::CrateNotCompilerBuiltins { crate_name: cdata.name() });
}
}

Expand Down
Loading
Loading