Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use std::sync::Arc;
use rustc_ast::node_id::NodeMap;
use rustc_ast::visit::Visitor;
use rustc_ast::{self as ast, *};
use rustc_attr_parsing::{AttributeParser, EmitAttribute, Late, OmitDoc};
use rustc_attr_parsing::{AttributeParser, EmitAttribute, OmitDoc, Recovery, ShouldEmit};
use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::fx::FxIndexSet;
use rustc_data_structures::sorted_map::SortedMap;
Expand Down Expand Up @@ -212,7 +212,7 @@ impl<'a, 'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'a, 'hir, R> {
tcx.sess,
tcx.features(),
registered_tools,
Late,
ShouldEmit::ErrorsAndLints { recovery: Recovery::Allowed },
),
delayed_lints: Vec::new(),
}
Expand Down
22 changes: 11 additions & 11 deletions compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::prelude::*;
use crate::session_diagnostics;

pub(crate) struct AllowInternalUnstableParser;
impl<S: Stage> CombineAttributeParser<S> for AllowInternalUnstableParser {
impl CombineAttributeParser for AllowInternalUnstableParser {
const PATH: &[Symbol] = &[sym::allow_internal_unstable];
type Item = (Symbol, Span);
const CONVERT: ConvertFn<Self::Item> =
Expand All @@ -18,17 +18,17 @@ impl<S: Stage> CombineAttributeParser<S> for AllowInternalUnstableParser {
const TEMPLATE: AttributeTemplate = template!(Word, List: &["feat1, feat2, ..."]);

fn extend(
cx: &mut AcceptContext<'_, '_, S>,
cx: &mut AcceptContext<'_, '_>,
args: &ArgParser,
) -> impl IntoIterator<Item = Self::Item> {
parse_unstable(cx, args, <Self as CombineAttributeParser<S>>::PATH[0])
parse_unstable(cx, args, <Self as CombineAttributeParser>::PATH[0])
.into_iter()
.zip(iter::repeat(cx.attr_span))
}
}

pub(crate) struct UnstableFeatureBoundParser;
impl<S: Stage> CombineAttributeParser<S> for UnstableFeatureBoundParser {
impl CombineAttributeParser for UnstableFeatureBoundParser {
const PATH: &[rustc_span::Symbol] = &[sym::unstable_feature_bound];
type Item = (Symbol, Span);
const CONVERT: ConvertFn<Self::Item> = |items, _| AttributeKind::UnstableFeatureBound(items);
Expand All @@ -40,20 +40,20 @@ impl<S: Stage> CombineAttributeParser<S> for UnstableFeatureBoundParser {
const TEMPLATE: AttributeTemplate = template!(Word, List: &["feat1, feat2, ..."]);

fn extend(
cx: &mut AcceptContext<'_, '_, S>,
cx: &mut AcceptContext<'_, '_>,
args: &ArgParser,
) -> impl IntoIterator<Item = Self::Item> {
if !cx.features().staged_api() {
cx.emit_err(session_diagnostics::StabilityOutsideStd { span: cx.attr_span });
}
parse_unstable(cx, args, <Self as CombineAttributeParser<S>>::PATH[0])
parse_unstable(cx, args, <Self as CombineAttributeParser>::PATH[0])
.into_iter()
.zip(iter::repeat(cx.attr_span))
}
}

pub(crate) struct RustcAllowConstFnUnstableParser;
impl<S: Stage> CombineAttributeParser<S> for RustcAllowConstFnUnstableParser {
impl CombineAttributeParser for RustcAllowConstFnUnstableParser {
const PATH: &[Symbol] = &[sym::rustc_allow_const_fn_unstable];
type Item = Symbol;
const CONVERT: ConvertFn<Self::Item> =
Expand All @@ -67,15 +67,15 @@ impl<S: Stage> CombineAttributeParser<S> for RustcAllowConstFnUnstableParser {
const TEMPLATE: AttributeTemplate = template!(Word, List: &["feat1, feat2, ..."]);

fn extend(
cx: &mut AcceptContext<'_, '_, S>,
cx: &mut AcceptContext<'_, '_>,
args: &ArgParser,
) -> impl IntoIterator<Item = Self::Item> {
parse_unstable(cx, args, <Self as CombineAttributeParser<S>>::PATH[0])
parse_unstable(cx, args, <Self as CombineAttributeParser>::PATH[0])
}
}

fn parse_unstable<S: Stage>(
cx: &AcceptContext<'_, '_, S>,
fn parse_unstable(
cx: &AcceptContext<'_, '_>,
args: &ArgParser,
symbol: Symbol,
) -> impl IntoIterator<Item = Symbol> {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_attr_parsing/src/attributes/autodiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ use thin_vec::ThinVec;

use crate::attributes::SingleAttributeParser;
use crate::attributes::prelude::Allow;
use crate::context::{AcceptContext, Stage};
use crate::context::AcceptContext;
use crate::parser::{ArgParser, MetaItemOrLitParser};
use crate::target_checking::AllowedTargets;

pub(crate) struct RustcAutodiffParser;

impl<S: Stage> SingleAttributeParser<S> for RustcAutodiffParser {
impl SingleAttributeParser for RustcAutodiffParser {
const PATH: &[Symbol] = &[sym::rustc_autodiff];
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::Fn),
Expand All @@ -30,7 +30,7 @@ impl<S: Stage> SingleAttributeParser<S> for RustcAutodiffParser {
"https://doc.rust-lang.org/std/autodiff/index.html"
);

fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
let list = match args {
ArgParser::NoArgs => return Some(AttributeKind::RustcAutodiff(None)),
ArgParser::List(list) => list,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/attributes/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::prelude::*;

pub(crate) struct CoroutineParser;

impl<S: Stage> NoArgsAttributeParser<S> for CoroutineParser {
impl NoArgsAttributeParser for CoroutineParser {
const PATH: &[Symbol] = &[sym::coroutine];
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Closure)]);
const CREATE: fn(rustc_span::Span) -> AttributeKind = |span| AttributeKind::Coroutine(span);
Expand Down
23 changes: 10 additions & 13 deletions compiler/rustc_attr_parsing/src/attributes/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use rustc_span::{ErrorGuaranteed, Span, Symbol, sym};
use thin_vec::ThinVec;

use crate::attributes::AttributeSafety;
use crate::context::{AcceptContext, ShouldEmit, Stage};
use crate::context::{AcceptContext, ShouldEmit};
use crate::parser::{
AllowExprMetavar, ArgParser, MetaItemListParser, MetaItemOrLitParser, NameValueParser,
};
Expand All @@ -40,10 +40,7 @@ const CFG_ATTR_TEMPLATE: AttributeTemplate = template!(
"https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute"
);

pub fn parse_cfg<S: Stage>(
cx: &mut AcceptContext<'_, '_, S>,
args: &ArgParser,
) -> Option<CfgEntry> {
pub fn parse_cfg(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<CfgEntry> {
let ArgParser::List(list) = args else {
let attr_span = cx.attr_span;
cx.adcx().expected_list(attr_span, args);
Expand Down Expand Up @@ -85,8 +82,8 @@ pub fn parse_cfg<S: Stage>(
parse_cfg_entry(cx, single).ok()
}

pub fn parse_cfg_entry<S: Stage>(
cx: &mut AcceptContext<'_, '_, S>,
pub fn parse_cfg_entry(
cx: &mut AcceptContext<'_, '_>,
item: &MetaItemOrLitParser,
) -> Result<CfgEntry, ErrorGuaranteed> {
Ok(match item {
Expand Down Expand Up @@ -130,8 +127,8 @@ pub fn parse_cfg_entry<S: Stage>(
})
}

fn parse_cfg_entry_version<S: Stage>(
cx: &mut AcceptContext<'_, '_, S>,
fn parse_cfg_entry_version(
cx: &mut AcceptContext<'_, '_>,
list: &MetaItemListParser,
meta_span: Span,
) -> Result<CfgEntry, ErrorGuaranteed> {
Expand Down Expand Up @@ -162,8 +159,8 @@ fn parse_cfg_entry_version<S: Stage>(
Ok(CfgEntry::Version(min_version, list.span))
}

fn parse_cfg_entry_target<S: Stage>(
cx: &mut AcceptContext<'_, '_, S>,
fn parse_cfg_entry_target(
cx: &mut AcceptContext<'_, '_>,
list: &MetaItemListParser,
meta_span: Span,
) -> Result<CfgEntry, ErrorGuaranteed> {
Expand Down Expand Up @@ -205,12 +202,12 @@ fn parse_cfg_entry_target<S: Stage>(
Ok(CfgEntry::All(result, list.span))
}

pub(crate) fn parse_name_value<S: Stage>(
pub(crate) fn parse_name_value(
name: Symbol,
name_span: Span,
value: Option<&NameValueParser>,
span: Span,
cx: &mut AcceptContext<'_, '_, S>,
cx: &mut AcceptContext<'_, '_>,
) -> Result<CfgEntry, ErrorGuaranteed> {
try_gate_cfg(name, span, cx.sess(), cx.features_option());

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_attr_parsing/src/attributes/cfi_encoding.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::prelude::*;
pub(crate) struct CfiEncodingParser;
impl<S: Stage> SingleAttributeParser<S> for CfiEncodingParser {
impl SingleAttributeParser for CfiEncodingParser {
const PATH: &[Symbol] = &[sym::cfi_encoding];
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowListWarnRest(&[
Allow(Target::Struct),
Expand All @@ -10,7 +10,7 @@ impl<S: Stage> SingleAttributeParser<S> for CfiEncodingParser {
]);
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "encoding");

fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
let Some(name_value) = args.name_value() else {
let attr_span = cx.attr_span;
cx.adcx().expected_name_value(attr_span, Some(sym::cfi_encoding));
Expand Down
Loading
Loading