Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7a7f8df
rustc_on_unimplemented: emit notes in declared order
mejrs Apr 28, 2026
f9e052d
rename "condition" to "filter"
mejrs Apr 28, 2026
7313fc6
Remove unused `IntoVisitor` trait.
nnethercote Apr 30, 2026
e92ca90
Remove unused `Captures` trait.
nnethercote Apr 30, 2026
bc0e581
Eliminate `IsPrefixOf` trait.
nnethercote Apr 30, 2026
82cfcaf
Remove useless bounds on `Self` for impls of concrete types.
nnethercote Apr 30, 2026
9119225
Remove unnecessary trait bound on `Subdiagnostic`.
nnethercote Apr 30, 2026
548cdc1
Add a `Local::arg(i)` helper constructor
scottmcm May 1, 2026
f77fc05
Add AcceptContext::expect_no_args
scrabsha Apr 28, 2026
a9da612
Add missing alias to mailmap
GuillaumeGomez May 1, 2026
f19e850
Improve source code for `librustdoc/visit_ast.rs`
GuillaumeGomez Apr 30, 2026
f14ce9d
Make `diverging_type_vars` a set of `TyVid`
JonathanBrouwer May 1, 2026
c17d24e
Make `diverging_type_vars` a `Vec`
JonathanBrouwer May 1, 2026
31c7253
Rollup merge of #155940 - mejrs:filter, r=jdonszelmann
GuillaumeGomez May 1, 2026
c20ba2a
Rollup merge of #156020 - GuillaumeGomez:cleanup-code, r=urgau
GuillaumeGomez May 1, 2026
18c9b0b
Rollup merge of #156021 - nnethercote:clean-up-some-traits, r=jackh726
GuillaumeGomez May 1, 2026
7635b46
Rollup merge of #156028 - scottmcm:local-arg, r=wesleywiser
GuillaumeGomez May 1, 2026
4b84ee0
Rollup merge of #156037 - scrabsha:attributes/expect-no-args, r=Jonat…
GuillaumeGomez May 1, 2026
e39936e
Rollup merge of #156040 - GuillaumeGomez:mailmap, r=lqd
GuillaumeGomez May 1, 2026
a80f8b5
Rollup merge of #156048 - JonathanBrouwer:diverging_ty_vids, r=Waffle…
GuillaumeGomez May 1, 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
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ Grzegorz Bartoszek <grzegorz.bartoszek@thaumatec.com>
Guanqun Lu <guanqun.lu@gmail.com>
Guillaume Gomez <contact@guillaume-gomez.fr>
Guillaume Gomez <contact@guillaume-gomez.fr> Guillaume Gomez <guillaume1.gomez@gmail.com>
Guillaume Gomez <contact@guillaume-gomez.fr> ggomez <guillaume1.gomez@gmail.com>
Guillaume Gomez <contact@guillaume-gomez.fr> ggomez <ggomez@ggo.ifr.lan>
Guillaume Gomez <contact@guillaume-gomez.fr> Guillaume Gomez <ggomez@ggo.ifr.lan>
Guillaume Gomez <contact@guillaume-gomez.fr> Guillaume Gomez <guillaume.gomez@huawei.com>
Expand Down
11 changes: 2 additions & 9 deletions compiler/rustc_attr_parsing/src/attributes/autodiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ impl SingleAttributeParser for RustcAutodiffParser {
cx.adcx().expected_identifier(mode.span());
return None;
};
let Ok(()) = mode.args().no_args() else {
cx.adcx().expected_identifier(mode.span());
return None;
};
cx.expect_no_args(mode.args())?;
let Some(mode) = mode.path().word() else {
cx.adcx().expected_identifier(mode.span());
return None;
Expand Down Expand Up @@ -85,11 +82,7 @@ impl SingleAttributeParser for RustcAutodiffParser {
.expected_specific_argument(activity.span(), DiffActivity::all_activities());
return None;
};
let Ok(()) = activity.args().no_args() else {
cx.adcx()
.expected_specific_argument(activity.span(), DiffActivity::all_activities());
return None;
};
cx.expect_no_args(activity.args())?;
let Some(activity) = activity.path().word() else {
cx.adcx()
.expected_specific_argument(activity.span(), DiffActivity::all_activities());
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,9 @@ pub(crate) struct NakedParser {
impl AttributeParser for NakedParser {
const ATTRIBUTES: AcceptMapping<Self> =
&[(&[sym::naked], template!(Word), |this, cx, args| {
if let Err(span) = args.no_args() {
cx.adcx().expected_no_args(span);
let Some(()) = cx.expect_no_args(args) else {
return;
}
};

if let Some(earlier) = this.span {
let span = cx.attr_span;
Expand Down
11 changes: 4 additions & 7 deletions compiler/rustc_attr_parsing/src/attributes/crate_level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,9 @@ impl CombineAttributeParser for FeatureParser {
cx.adcx().expected_identifier(elem.span());
continue;
};
if let Err(arg_span) = elem.args().no_args() {
cx.adcx().expected_no_args(arg_span);
let Some(()) = cx.expect_no_args(elem.args()) else {
continue;
}

};
let path = elem.path();
let Some(ident) = path.word() else {
cx.adcx().expected_identifier(path.span());
Expand Down Expand Up @@ -340,10 +338,9 @@ impl CombineAttributeParser for RegisterToolParser {
cx.adcx().expected_identifier(elem.span());
continue;
};
if let Err(arg_span) = elem.args().no_args() {
cx.adcx().expected_no_args(arg_span);
let Some(()) = cx.expect_no_args(elem.args()) else {
continue;
}
};

let path = elem.path();
let Some(ident) = path.word() else {
Expand Down
38 changes: 16 additions & 22 deletions compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::ops::Range;
use rustc_errors::E0232;
use rustc_hir::AttrPath;
use rustc_hir::attrs::diagnostic::{
Directive, FilterFormatString, Flag, FormatArg, FormatString, LitOrArg, Name, NameValue,
OnUnimplementedCondition, Piece, Predicate,
Directive, Filter, FilterFormatString, Flag, FormatArg, FormatString, LitOrArg, Name,
NameValue, Piece, Predicate,
};
use rustc_macros::Diagnostic;
use rustc_parse_format::{
Expand Down Expand Up @@ -201,12 +201,11 @@ fn parse_directive_items<'p>(
items: impl Iterator<Item = &'p MetaItemOrLitParser>,
is_root: bool,
) -> Option<Directive> {
let condition = None;
let mut message: Option<(Span, _)> = None;
let mut label: Option<(Span, _)> = None;
let mut notes = ThinVec::new();
let mut parent_label = None;
let mut subcommands = ThinVec::new();
let mut filters = ThinVec::new();

for item in items {
let span = item.span();
Expand Down Expand Up @@ -330,29 +329,27 @@ fn parse_directive_items<'p>(
if is_root {
let items = or_malformed!(item.args().as_list()?);
let mut iter = items.mixed();
let condition: &MetaItemOrLitParser = match iter.next() {
let filter: &MetaItemOrLitParser = match iter.next() {
Some(c) => c,
None => {
cx.emit_err(InvalidOnClause::Empty { span });
continue;
}
};

let condition = parse_condition(condition);
let filter = parse_filter(filter);

if items.len() < 2 {
// Something like `#[rustc_on_unimplemented(on(.., /* nothing */))]`
// There's a condition but no directive behind it, this is a mistake.
// There's a filter but no directive behind it, this is a mistake.
malformed!();
}

let mut directive =
or_malformed!(parse_directive_items(cx, mode, iter, false)?);

match condition {
Ok(c) => {
directive.condition = Some(c);
subcommands.push(directive);
match filter {
Ok(filter) => {
let directive =
or_malformed!(parse_directive_items(cx, mode, iter, false)?);
filters.push((filter, directive));
}
Err(e) => {
cx.emit_err(e);
Expand All @@ -371,8 +368,7 @@ fn parse_directive_items<'p>(

Some(Directive {
is_rustc_attr: matches!(mode, Mode::RustcOnUnimplemented),
condition,
subcommands,
filters,
message,
label,
notes,
Expand Down Expand Up @@ -513,12 +509,10 @@ fn slice_span(input: Span, Range { start, end }: Range<usize>, is_source_literal
if is_source_literal { input.from_inner(InnerSpan { start, end }) } else { input }
}

pub(crate) fn parse_condition(
input: &MetaItemOrLitParser,
) -> Result<OnUnimplementedCondition, InvalidOnClause> {
pub(crate) fn parse_filter(input: &MetaItemOrLitParser) -> Result<Filter, InvalidOnClause> {
let span = input.span();
let pred = parse_predicate(input)?;
Ok(OnUnimplementedCondition { span, pred })
Ok(Filter { span, pred })
}

fn parse_predicate(input: &MetaItemOrLitParser) -> Result<Predicate, InvalidOnClause> {
Expand Down Expand Up @@ -553,7 +547,7 @@ fn parse_predicate(input: &MetaItemOrLitParser) -> Result<Predicate, InvalidOnCl
return Err(InvalidOnClause::UnsupportedLiteral { span: p.args_span() });
};
let name = parse_name(predicate.name);
let value = parse_filter(value.name);
let value = parse_filter_format(value.name);
let kv = NameValue { name, value };
Ok(Predicate::Match(kv))
}
Expand Down Expand Up @@ -588,7 +582,7 @@ fn parse_name(name: Symbol) -> Name {
}
}

fn parse_filter(input: Symbol) -> FilterFormatString {
fn parse_filter_format(input: Symbol) -> FilterFormatString {
let pieces = Parser::new(input.as_str(), None, None, false, ParseMode::Diagnostic)
.map(|p| match p {
RpfPiece::Lit(s) => LitOrArg::Lit(Symbol::intern(s)),
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_attr_parsing/src/attributes/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl DocParser {

match path.word_sym() {
Some(sym::no_crate_inject) => {
if let Err(span) = args.no_args() {
if let Err(span) = args.as_no_args() {
expected_no_args(cx, span);
return;
}
Expand Down Expand Up @@ -280,7 +280,7 @@ impl DocParser {
args: &ArgParser,
inline: DocInline,
) {
if let Err(span) = args.no_args() {
if let Err(span) = args.as_no_args() {
expected_no_args(cx, span);
return;
}
Expand Down Expand Up @@ -426,7 +426,7 @@ impl DocParser {

macro_rules! no_args {
($ident: ident) => {{
if let Err(span) = args.no_args() {
if let Err(span) = args.as_no_args() {
expected_no_args(cx, span);
return;
}
Expand All @@ -445,7 +445,7 @@ impl DocParser {
}
macro_rules! no_args_and_not_crate_level {
($ident: ident) => {{
if let Err(span) = args.no_args() {
if let Err(span) = args.as_no_args() {
expected_no_args(cx, span);
return;
}
Expand All @@ -461,7 +461,7 @@ impl DocParser {
no_args_and_crate_level!($ident, |span| {});
}};
($ident: ident, |$span:ident| $extra_validation:block) => {{
if let Err(span) = args.no_args() {
if let Err(span) = args.as_no_args() {
expected_no_args(cx, span);
return;
}
Expand Down
9 changes: 3 additions & 6 deletions compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,9 @@ impl AttributeParser for MacroUseParser {
cx.adcx().expected_identifier(item.span());
continue;
};
if let Err(err_span) = item.args().no_args() {
cx.adcx().expected_no_args(err_span);
let Some(()) = cx.expect_no_args(item.args()) else {
continue;
}
};
let Some(item) = item.path().word() else {
cx.adcx().expected_identifier(item.span());
continue;
Expand Down Expand Up @@ -179,9 +178,7 @@ impl SingleAttributeParser for CollapseDebugInfoParser {
cx.adcx().expected_not_literal(single.span());
return None;
};
if let Err(err) = mi.args().no_args() {
cx.adcx().expected_no_args(err);
}
let _ = cx.expect_no_args(mi.args());
let path = mi.path().word_sym();
let info = match path {
Some(sym::yes) => CollapseMacroDebuginfo::Yes,
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_attr_parsing/src/attributes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,7 @@ impl<T: NoArgsAttributeParser> SingleAttributeParser for WithoutArgs<T> {
const TEMPLATE: AttributeTemplate = template!(Word);

fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
if let Err(span) = args.no_args() {
cx.adcx().expected_no_args(span);
}
let _ = cx.expect_no_args(args);
Some(T::CREATE(cx.attr_span))
}
}
Expand Down
12 changes: 3 additions & 9 deletions compiler/rustc_attr_parsing/src/attributes/proc_macro_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fn parse_derive_like(
) -> Option<(Option<Symbol>, ThinVec<Symbol>)> {
let Some(list) = args.as_list() else {
// For #[rustc_builtin_macro], it is permitted to leave out the trait name
if args.no_args().is_ok() && !trait_name_mandatory {
if args.as_no_args().is_ok() && !trait_name_mandatory {
return Some((None, ThinVec::new()));
}
let attr_span = cx.attr_span;
Expand All @@ -84,10 +84,7 @@ fn parse_derive_like(
cx.adcx().expected_identifier(trait_ident.span);
return None;
}
if let Err(e) = trait_attr.args().no_args() {
cx.adcx().expected_no_args(e);
return None;
};
cx.expect_no_args(trait_attr.args())?;

// Parse optional attributes
let mut attributes = ThinVec::new();
Expand All @@ -108,10 +105,7 @@ fn parse_derive_like(
cx.adcx().expected_identifier(attr.span());
return None;
};
if let Err(e) = attr.args().no_args() {
cx.adcx().expected_no_args(e);
return None;
};
cx.expect_no_args(attr.args())?;
let Some(ident) = attr.path().word() else {
cx.adcx().expected_identifier(attr.path().span());
return None;
Expand Down
10 changes: 2 additions & 8 deletions compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ impl SingleAttributeParser for RustcDumpDefPathParser {
]);
const TEMPLATE: AttributeTemplate = template!(Word);
fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
if let Err(span) = args.no_args() {
cx.adcx().expected_no_args(span);
return None;
}
cx.expect_no_args(args)?;
Some(AttributeKind::RustcDumpDefPath(cx.attr_span))
}
}
Expand Down Expand Up @@ -203,10 +200,7 @@ impl SingleAttributeParser for RustcDumpSymbolNameParser {
]);
const TEMPLATE: AttributeTemplate = template!(Word);
fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
if let Err(span) = args.no_args() {
cx.adcx().expected_no_args(span);
return None;
}
cx.expect_no_args(args)?;
Some(AttributeKind::RustcDumpSymbolName(cx.attr_span))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ impl SingleAttributeParser for RustcScalableVectorParser {
const TEMPLATE: AttributeTemplate = template!(Word, List: &["count"]);

fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
if args.no_args().is_ok() {
if args.as_no_args().is_ok() {
return Some(AttributeKind::RustcScalableVector {
element_count: None,
span: cx.attr_span,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/attributes/test_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl SingleAttributeParser for IgnoreParser {
ArgParser::List(list) => {
let help =
list.as_single().and_then(|item| item.meta_item()).and_then(|item| {
item.args().no_args().ok()?;
item.args().as_no_args().ok()?;
Some(item.path().to_string())
});
cx.adcx().warn_ill_formed_attribute_input_with_help(
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_attr_parsing/src/attributes/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ impl SingleAttributeParser for RustcSkipDuringMethodDispatchParser {
cx.adcx().expected_not_literal(arg.span());
continue;
};
if let Err(span) = arg.args().no_args() {
cx.adcx().expected_no_args(span);
}
let _ = cx.expect_no_args(arg.args());
let path = arg.path();
let (key, skip): (Symbol, &mut bool) = match path.word_sym() {
Some(key @ sym::array) => (key, &mut array),
Expand Down
10 changes: 10 additions & 0 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,16 @@ impl<'f, 'sess: 'f> AcceptContext<'f, 'sess> {
{
arg.expect_name_value(self, span, name)
}

/// Assert that an [`ArgParser`] has no args, or emits an error and return `None`.
pub(crate) fn expect_no_args<'arg>(&mut self, arg: &'arg ArgParser) -> Option<()> {
if let Err(span) = arg.as_no_args() {
self.adcx().expected_no_args(span);
return None;
}

Some(())
}
}

pub(crate) trait ExpectNameValue {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl ArgParser {
/// Assert that there were no args.
/// If there were, get a span to the arguments
/// (to pass to [`AttributeDiagnosticContext::expected_no_args`](crate::context::AttributeDiagnosticContext::expected_no_args)).
pub fn no_args(&self) -> Result<(), Span> {
pub fn as_no_args(&self) -> Result<(), Span> {
match self {
Self::NoArgs => Ok(()),
Self::List(args) => Err(args.span),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ use super::{DescribePlaceOpt, RegionName, RegionNameSource, UseSpans};
use crate::borrow_set::{BorrowData, TwoPhaseActivation};
use crate::diagnostics::conflict_errors::StorageDeadOrDrop::LocalStorageDead;
use crate::diagnostics::{CapturedMessageOpt, call_kind, find_all_local_uses};
use crate::prefixes::IsPrefixOf;
use crate::{InitializationRequiringAction, MirBorrowckCtxt, WriteKind, borrowck_errors};

#[derive(Debug)]
Expand Down
12 changes: 0 additions & 12 deletions compiler/rustc_borrowck/src/prefixes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@ use rustc_middle::mir::{PlaceRef, ProjectionElem};

use super::MirBorrowckCtxt;

pub(crate) trait IsPrefixOf<'tcx> {
fn is_prefix_of(&self, other: PlaceRef<'tcx>) -> bool;
}

impl<'tcx> IsPrefixOf<'tcx> for PlaceRef<'tcx> {
fn is_prefix_of(&self, other: PlaceRef<'tcx>) -> bool {
self.local == other.local
&& self.projection.len() <= other.projection.len()
&& self.projection == &other.projection[..self.projection.len()]
}
}

pub(super) struct Prefixes<'tcx> {
kind: PrefixSet,
next: Option<PlaceRef<'tcx>>,
Expand Down
Loading
Loading