Skip to content
Closed
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
3 changes: 2 additions & 1 deletion compiler/rustc_abi/src/layout/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ use crate::{
// Explicitly import `Float` to avoid ambiguity with `Primitive::Float`.

#[derive(Copy, Clone, PartialEq, Eq, Hash, StableHash)]
#[rustc_pass_by_value]
#[cfg_attr(bootstrap, rustc_pass_by_value)]
#[cfg_attr(not(bootstrap), lint::pass_by_value)]
pub struct Layout<'a>(pub Interned<'a, LayoutData<FieldIdx, VariantIdx>>);

impl<'a> fmt::Debug for Layout<'a> {
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// tidy-alphabetical-start
#![cfg_attr(feature = "nightly", allow(internal_features))]
#![cfg_attr(feature = "nightly", feature(register_tool))]
#![cfg_attr(feature = "nightly", feature(rustc_attrs))]
#![cfg_attr(feature = "nightly", feature(step_trait))]
#![cfg_attr(feature = "nightly", register_tool(lint))]
// tidy-alphabetical-end

/*! ABI handling for rustc
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#![feature(deref_patterns)]
#![feature(iter_order_by)]
#![feature(macro_metavar_expr)]
#![feature(register_tool)]
#![recursion_limit = "256"]
#![register_tool(lint)]
// tidy-alphabetical-end

pub mod util {
Expand Down
16 changes: 16 additions & 0 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,4 +780,20 @@ fn check_features_requiring_new_solver(sess: &Session, features: &Features) {
missing: String::from("-Znext-solver=globally"),
});
}

// Require the new solver with unsafe binders. It's just too much work to
// support both solvers.
if let Some(unsafe_binders_span) = features
.enabled_lang_features()
.iter()
.find(|feat| feat.gate_name == sym::unsafe_binders)
.map(|feat| feat.attr_sp)
{
#[allow(rustc::symbol_intern_string_literal)]
sess.dcx().emit_err(diagnostics::MissingDependentFeatures {
parent_span: unsafe_binders_span,
parent: sym::unsafe_binders,
missing: String::from("-Znext-solver=globally"),
});
}
}
27 changes: 14 additions & 13 deletions compiler/rustc_attr_ir/src/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -991,9 +991,22 @@ pub enum AttributeKind {
/// Represents `#[allow]`, `#[warn]`, `#[deny]`, `#[forbid]`, and `#[expect]`.
LintCheck(ThinVec<LintCheck>),

/// Represents `#[lint::must_match_exhaustively]` (used by the
/// `rustc::must_match_exhaustively` lint).
LintMustMatchExhaustively(Span),

/// Represents `#[lint::never_returns_null_ptr]` (used by the `useless_ptr_null_checks` lint).
LintNeverReturnsNullPtr,

/// Represents `#[lint::no_implicit_autorefs]` (used by the `dangerous_implicit_autorefs` lint).
LintNoImplicitAutorefs,

/// Represents `#[lint::panics_when_zero]` (used by the `unconditional_panic` lint).
LintPanicsWhenZero,

/// Represents `#[lint::pass_by_value)]` (used by the `rustc::disallowed_pass_by_ref` lint).
LintPassByValue,

/// Represents `#[lint::should_not_be_called_on_const_items]` (used by the
/// `const_item_interior_mutations` lint).
LintShouldNotBeCalledOnConstItems,
Expand Down Expand Up @@ -1421,13 +1434,6 @@ pub enum AttributeKind {
attr_span: Span,
fn_names: ThinVec<Ident>,
},

/// Represents `#[rustc_must_match_exhaustively]`
RustcMustMatchExhaustively(Span),

/// Represents `#[rustc_no_implicit_autorefs]`
RustcNoImplicitAutorefs,

/// Represents `#[rustc_no_implicit_bounds]`
RustcNoImplicitBounds,

Expand Down Expand Up @@ -1459,18 +1465,13 @@ pub enum AttributeKind {
/// Represents `#[rustc_offload_kernel]`
RustcOffloadKernel,

/// Represents `#[rustc_panics_when_zero]` (used for linting).
RustcPanicsWhenZero,

/// Represents `#[rustc_paren_sugar]`.
RustcParenSugar,

/// Represents `#[rustc_pass_by_value]` (used by the `rustc_pass_by_value` lint).
RustcPassByValue,

/// Represents `#[rustc_pass_indirectly_in_non_rustic_abis]`,
///
/// See `TyAndLayout::pass_indirectly_in_non_rustic_abis` for details.
/// Represents `#[rustc_pass_indirectly_in_non_rustic_abis]`
RustcPassIndirectlyInNonRusticAbis(Span),

/// Represents `#[rustc_preserve_ub_checks]`
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_attr_ir/src/encode_cross_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ impl AttributeKind {
Linkage(..) => No,
LintAsPtr => Yes,
LintCheck(..) => No,
LintMustMatchExhaustively(..) => Yes,
LintNeverReturnsNullPtr => Yes,
LintNoImplicitAutorefs => Yes,
LintPanicsWhenZero => Yes,
LintPassByValue => Yes,
LintShouldNotBeCalledOnConstItems => Yes,
LoopMatch(..) => No,
MacroEscape => No,
Expand Down Expand Up @@ -168,8 +172,6 @@ impl AttributeKind {
RustcMain => No,
RustcMir(..) => Yes,
RustcMustImplementOneOf { .. } => No,
RustcMustMatchExhaustively(..) => Yes,
RustcNoImplicitAutorefs => Yes,
RustcNoImplicitBounds => No,
RustcNoMirInline => Yes,
RustcNoWritable => Yes,
Expand All @@ -179,9 +181,7 @@ impl AttributeKind {
RustcObjcClass { .. } => No,
RustcObjcSelector { .. } => No,
RustcOffloadKernel => Yes,
RustcPanicsWhenZero => Yes,
RustcParenSugar => No,
RustcPassByValue => Yes,
RustcPassIndirectlyInNonRusticAbis(..) => No,
RustcPreserveUbChecks => No,
RustcProcMacroDecls => No,
Expand Down Expand Up @@ -279,7 +279,11 @@ impl AttributeKind {
},
LintAsPtr => false,
LintCheck(_) => false,
LintMustMatchExhaustively(..) => false,
LintNeverReturnsNullPtr => false,
LintNoImplicitAutorefs => false,
LintPanicsWhenZero => false,
LintPassByValue => false,
LintShouldNotBeCalledOnConstItems => false,
LoopMatch(..) => false,
MacroEscape => false,
Expand Down Expand Up @@ -387,8 +391,6 @@ impl AttributeKind {
RustcMain => false,
RustcMir(..) => false,
RustcMustImplementOneOf { .. } => false,
RustcMustMatchExhaustively(..) => false,
RustcNoImplicitAutorefs => false,
RustcNoImplicitBounds => false,
RustcNoMirInline => false,
RustcNoWritable => false,
Expand All @@ -398,9 +400,7 @@ impl AttributeKind {
RustcObjcClass { .. } => false,
RustcObjcSelector { .. } => false,
RustcOffloadKernel => true,
RustcPanicsWhenZero => false,
RustcParenSugar => false,
RustcPassByValue => false,
RustcPassIndirectlyInNonRusticAbis(..) => false,
RustcPreserveUbChecks => false,
RustcProcMacroDecls => false,
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ impl NoArgsAttributeParser for RustcPubTransparentParser {
}
}

pub(crate) struct RustcPassByValueParser;
impl NoArgsAttributeParser for RustcPassByValueParser {
const PATH: &[Symbol] = &[sym::rustc_pass_by_value];
pub(crate) struct LintPassByValueParser;
impl NoArgsAttributeParser for LintPassByValueParser {
const PATH: &[Symbol] = &[sym::lint, sym::pass_by_value];
const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[
Allow(Target::Struct),
Allow(Target::Enum),
Allow(Target::TyAlias),
]);
const STABILITY: AttributeStability = unstable!(rustc_attrs);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcPassByValue;
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::LintPassByValue;
}

pub(crate) struct LintShouldNotBeCalledOnConstItemsParser;
Expand Down
20 changes: 10 additions & 10 deletions compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,21 @@ impl SingleAttributeParser for RustcMustImplementOneOfParser {
}
}

pub(crate) struct RustcPanicsWhenZeroParser;
pub(crate) struct LintPanicsWhenZeroParser;

impl NoArgsAttributeParser for RustcPanicsWhenZeroParser {
const PATH: &[Symbol] = &[sym::rustc_panics_when_zero];
impl NoArgsAttributeParser for LintPanicsWhenZeroParser {
const PATH: &[Symbol] = &[sym::lint, sym::panics_when_zero];
const ALLOWED_TARGETS: AllowedTargets<'_> =
AllowedTargets::AllowList(&[Allow(Target::ConstParam)]);
const STABILITY: AttributeStability = unstable!(rustc_attrs);

const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcPanicsWhenZero;
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::LintPanicsWhenZero;
}

pub(crate) struct RustcNoImplicitAutorefsParser;
pub(crate) struct LintNoImplicitAutorefsParser;

impl NoArgsAttributeParser for RustcNoImplicitAutorefsParser {
const PATH: &[Symbol] = &[sym::rustc_no_implicit_autorefs];
impl NoArgsAttributeParser for LintNoImplicitAutorefsParser {
const PATH: &[Symbol] = &[sym::lint, sym::no_implicit_autorefs];
const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[
Allow(Target::Fn),
Allow(Target::Method(MethodKind::Inherent)),
Expand All @@ -113,7 +113,7 @@ impl NoArgsAttributeParser for RustcNoImplicitAutorefsParser {
]);
const STABILITY: AttributeStability = unstable!(rustc_attrs);

const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcNoImplicitAutorefs;
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::LintNoImplicitAutorefs;
}

pub(crate) struct RustcLegacyConstGenericsParser;
Expand Down Expand Up @@ -1149,10 +1149,10 @@ impl NoArgsAttributeParser for RustcIntrinsicConstStableIndirectParser {
pub(crate) struct RustcExhaustiveParser;

impl NoArgsAttributeParser for RustcExhaustiveParser {
const PATH: &'static [Symbol] = &[sym::rustc_must_match_exhaustively];
const PATH: &'static [Symbol] = &[sym::lint, sym::must_match_exhaustively];
const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::Enum)]);
const STABILITY: AttributeStability = unstable!(rustc_attrs);
const CREATE: fn(Span) -> AttributeKind = AttributeKind::RustcMustMatchExhaustively;
const CREATE: fn(Span) -> AttributeKind = AttributeKind::LintMustMatchExhaustively;
}

pub(crate) struct RustcCanonicalSymbolParser;
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ attribute_parsers!(
Single<WithoutArgs<FundamentalParser>>,
Single<WithoutArgs<LintAsPtrParser>>,
Single<WithoutArgs<LintNeverReturnsNullPtrParser>>,
Single<WithoutArgs<LintNoImplicitAutorefsParser>>,
Single<WithoutArgs<LintPanicsWhenZeroParser>>,
Single<WithoutArgs<LintPassByValueParser>>,
Single<WithoutArgs<LintShouldNotBeCalledOnConstItemsParser>>,
Single<WithoutArgs<LoopMatchParser>>,
Single<WithoutArgs<MacroEscapeParser>>,
Expand Down Expand Up @@ -337,17 +340,14 @@ attribute_parsers!(
Single<WithoutArgs<RustcLintQueryInstabilityParser>>,
Single<WithoutArgs<RustcLintUntrackedQueryInformationParser>>,
Single<WithoutArgs<RustcMainParser>>,
Single<WithoutArgs<RustcNoImplicitAutorefsParser>>,
Single<WithoutArgs<RustcNoImplicitBoundsParser>>,
Single<WithoutArgs<RustcNoMirInlineParser>>,
Single<WithoutArgs<RustcNoWritableParser>>,
Single<WithoutArgs<RustcNonConstTraitMethodParser>>,
Single<WithoutArgs<RustcNonnullOptimizationGuaranteedParser>>,
Single<WithoutArgs<RustcNounwindParser>>,
Single<WithoutArgs<RustcOffloadKernelParser>>,
Single<WithoutArgs<RustcPanicsWhenZeroParser>>,
Single<WithoutArgs<RustcParenSugarParser>>,
Single<WithoutArgs<RustcPassByValueParser>>,
Single<WithoutArgs<RustcPassIndirectlyInNonRusticAbisParser>>,
Single<WithoutArgs<RustcPreserveUbChecksParser>>,
Single<WithoutArgs<RustcProcMacroDeclsParser>>,
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_attr_parsing/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ impl<'sess> AttributeParser<'sess> {
/// This can be used for attributes that would be removed before `rustc_ast_lowering`, such as attributes on macro calls.
///
/// Try to use this as little as possible. Attributes *should* be lowered during
/// `rustc_ast_lowering`. Some attributes require access to features to parse, which would
/// crash if you tried to do so through [`parse_limited_all`](Self::parse_limited_all).
/// Therefore, if `parse_filter` is None, then features *must* be provided.
/// `rustc_ast_lowering`.
pub fn parse_limited_all(
sess: &'sess Session,
attrs: &[ast::Attribute],
Expand All @@ -159,6 +157,10 @@ impl<'sess> AttributeParser<'sess> {
should_emit: ShouldEmit,
attr_tools: Option<&'sess RegisteredTools>,
) -> Vec<Attribute> {
// Some attributes require access to features to parse.
// Therefore, if `parse_filter` is None, then features *must* be provided.
assert!(parse_filter.is_some() || features.is_some());

let mut p = AttributeParser { features, attr_tools, parse_filter, sess, should_emit };
p.parse_attribute_list(
attrs,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
#![feature(file_buffered)]
#![feature(negative_impls)]
#![feature(option_into_flat_iter)]
#![feature(register_tool)]
#![feature(rustc_attrs)]
#![feature(stmt_expr_attributes)]
#![feature(try_blocks)]
#![register_tool(lint)]
// tidy-alphabetical-end

use std::borrow::Cow;
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_codegen_llvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
#![feature(iter_intersperse)]
#![feature(macro_derive)]
#![feature(once_cell_try)]
#![feature(register_tool)]
#![feature(rustc_attrs)]
#![feature(try_blocks)]
#![register_tool(lint)]
// tidy-alphabetical-end

pub use crate::back::llvm_backend::{LlvmCodegenBackend, ModuleLlvm};
Expand Down
15 changes: 10 additions & 5 deletions compiler/rustc_codegen_llvm/src/llvm/ffi/branded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ type PhantomInvariantLifetime<'a> = PhantomData<fn(&'a ()) -> &'a ()>;
/// Corresponds to `LLVMContextRef`.
#[derive(Clone, Copy)]
#[repr(transparent)]
#[rustc_pass_by_value]
#[cfg_attr(bootstrap, rustc_pass_by_value)]
#[cfg_attr(not(bootstrap), lint::pass_by_value)]
pub(crate) struct Context<'ll> {
llcx_raw: ptr::NonNull<ContextRaw>,
_invariant_ll: PhantomInvariantLifetime<'ll>,
Expand All @@ -18,7 +19,8 @@ pub(crate) struct Context<'ll> {
/// Corresponds to `LLVMModuleRef`.
#[derive(Clone, Copy)]
#[repr(transparent)]
#[rustc_pass_by_value]
#[cfg_attr(bootstrap, rustc_pass_by_value)]
#[cfg_attr(not(bootstrap), lint::pass_by_value)]
pub(crate) struct Module<'ll> {
llmod_raw: ptr::NonNull<ModuleRaw>,
_invariant_ll: PhantomInvariantLifetime<'ll>,
Expand Down Expand Up @@ -65,7 +67,8 @@ pub(crate) unsafe fn wrap_llmod<'ll>(
/// can be compared for equality (and hashed) based on their pointer address.
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
#[repr(transparent)]
#[rustc_pass_by_value]
#[cfg_attr(bootstrap, rustc_pass_by_value)]
#[cfg_attr(not(bootstrap), lint::pass_by_value)]
pub(crate) struct Type<'ll> {
llty_raw: ptr::NonNull<TypeRaw>,
_invariant_ll: PhantomInvariantLifetime<'ll>,
Expand All @@ -79,7 +82,8 @@ unsafe extern "C" {
/// Corresponds to `LLVMValueRef`.
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
#[repr(transparent)]
#[rustc_pass_by_value]
#[cfg_attr(bootstrap, rustc_pass_by_value)]
#[cfg_attr(not(bootstrap), lint::pass_by_value)]
pub(crate) struct Value<'ll> {
llval_raw: ptr::NonNull<ValueRaw>,
_invariant_ll: PhantomInvariantLifetime<'ll>,
Expand All @@ -93,7 +97,8 @@ unsafe extern "C" {
/// Corresponds to `LLVMAttributeRef`.
#[derive(Clone, Copy)]
#[repr(transparent)]
#[rustc_pass_by_value]
#[cfg_attr(bootstrap, rustc_pass_by_value)]
#[cfg_attr(not(bootstrap), lint::pass_by_value)]
pub(crate) struct Attribute<'ll> {
llattr_raw: ptr::NonNull<AttributeRaw>,
_invariant_ll: PhantomInvariantLifetime<'ll>,
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_data_structures/src/intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ mod private {
/// The `PrivateZst` field means you can pattern match with `Interned(v, _)` but you can only
/// construct a `Interned` with `new_unchecked`, and not directly. This means that all creation
/// points can be audited easily.
#[rustc_pass_by_value]
#[cfg_attr(bootstrap, rustc_pass_by_value)]
#[cfg_attr(not(bootstrap), lint::pass_by_value)]
pub struct Interned<'a, T>(pub &'a T, pub private::PrivateZst);

impl<'a, T> Interned<'a, T> {
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_data_structures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
#![feature(negative_impls)]
#![feature(nonzero_internals)]
#![feature(pattern_types)]
#![feature(register_tool)]
#![feature(rustc_attrs)]
#![feature(sized_hierarchy)]
#![feature(thread_id_value)]
#![feature(trait_alias)]
#![feature(trusted_len)]
#![feature(type_alias_impl_trait)]
#![register_tool(lint)]
// tidy-alphabetical-end

// This allows derive macros to reference this crate
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#![feature(default_field_values)]
#![feature(macro_metavar_expr_concat)]
#![feature(negative_impls)]
#![feature(register_tool)]
#![register_tool(lint)]
// tidy-alphabetical-end

extern crate self as rustc_errors;
Expand Down
Loading
Loading