Skip to content
Draft
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
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
rustc_promotable, Normal, template!(Word), WarnFollowing,
EncodeCrossCrate::No, ),
rustc_attr!(
rustc_legacy_const_generics, Normal, template!(List: &["N"]), ErrorFollowing,
rustc_deprecated_legacy_const_generics, Normal, template!(List: &["N"]), ErrorFollowing,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it'd be worth adding a comment here to the effect that this should not be newly applied anywhere.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt anyone who might be tempted to apply it would see a comment deep inside the rustc sources.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, just an hour ago I was thinking to name it legacy_const_generics_do_not_use just to avoid any and all ambiguity

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I considered that name but it seemed a bit too cheesy ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also considered rustc_legacy_const_generics_deprecated (instead of rustc_deprecated_legacy_const_generics), not sure which order makes more sense.

EncodeCrossCrate::Yes,
),
// Do not const-check this function's body. It will always get replaced during CTFE via `hook_special_const_fn`.
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_passes/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -521,11 +521,11 @@ passes_rustc_force_inline_coro =
attribute cannot be applied to a `async`, `gen` or `async gen` function
.label = `async`, `gen` or `async gen` function

passes_rustc_legacy_const_generics_index =
#[rustc_legacy_const_generics] must have one index for each generic parameter
passes_rustc_deprecated_legacy_const_generics_index =
#[rustc_deprecated_legacy_const_generics] must have one index for each generic parameter
.label = generic parameters

passes_rustc_legacy_const_generics_index_exceed =
passes_rustc_deprecated_legacy_const_generics_index_exceed =
index exceeds number of arguments
.label = there {$arg_count ->
[one] is
Expand All @@ -535,11 +535,11 @@ passes_rustc_legacy_const_generics_index_exceed =
*[other] arguments
}

passes_rustc_legacy_const_generics_index_negative =
passes_rustc_deprecated_legacy_const_generics_index_negative =
arguments should be non-negative integers

passes_rustc_legacy_const_generics_only =
#[rustc_legacy_const_generics] functions must only have const generics
passes_rustc_deprecated_legacy_const_generics_only =
#[rustc_deprecated_legacy_const_generics] functions must only have const generics
.label = non-const generic parameter

passes_rustc_lint_opt_deny_field_access =
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
[sym::rustc_never_returns_null_ptr, ..] => {
self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target)
}
[sym::rustc_legacy_const_generics, ..] => {
self.check_rustc_legacy_const_generics(hir_id, attr, span, target, item)
[sym::rustc_deprecated_legacy_const_generics, ..] => {
self.check_rustc_deprecated_legacy_const_generics(hir_id, attr, span, target, item)
}
[sym::rustc_lint_query_instability, ..] => {
self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target)
Expand Down Expand Up @@ -1423,8 +1423,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
}
}

/// Checks if `#[rustc_legacy_const_generics]` is applied to a function and has a valid argument.
fn check_rustc_legacy_const_generics(
/// Checks if `#[rustc_deprecated_legacy_const_generics]` is applied to a function and has a valid argument.
fn check_rustc_deprecated_legacy_const_generics(
&self,
hir_id: HirId,
attr: &Attribute,
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ pub(crate) struct NoLink {
}

#[derive(Diagnostic)]
#[diag(passes_rustc_legacy_const_generics_only)]
#[diag(passes_rustc_deprecated_legacy_const_generics_only)]
pub(crate) struct RustcLegacyConstGenericsOnly {
#[primary_span]
pub attr_span: Span,
Expand All @@ -415,7 +415,7 @@ pub(crate) struct RustcLegacyConstGenericsOnly {
}

#[derive(Diagnostic)]
#[diag(passes_rustc_legacy_const_generics_index)]
#[diag(passes_rustc_deprecated_legacy_const_generics_index)]
pub(crate) struct RustcLegacyConstGenericsIndex {
#[primary_span]
pub attr_span: Span,
Expand All @@ -424,7 +424,7 @@ pub(crate) struct RustcLegacyConstGenericsIndex {
}

#[derive(Diagnostic)]
#[diag(passes_rustc_legacy_const_generics_index_exceed)]
#[diag(passes_rustc_deprecated_legacy_const_generics_index_exceed)]
pub(crate) struct RustcLegacyConstGenericsIndexExceed {
#[primary_span]
#[label]
Expand All @@ -433,7 +433,7 @@ pub(crate) struct RustcLegacyConstGenericsIndexExceed {
}

#[derive(Diagnostic)]
#[diag(passes_rustc_legacy_const_generics_index_negative)]
#[diag(passes_rustc_deprecated_legacy_const_generics_index_negative)]
pub(crate) struct RustcLegacyConstGenericsIndexNegative {
#[primary_span]
pub invalid_args: Vec<Span>,
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2352,7 +2352,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
}

/// Checks if an expression refers to a function marked with
/// `#[rustc_legacy_const_generics]` and returns the argument index list
/// `#[rustc_deprecated_legacy_const_generics]` and returns the argument index list
/// from the attribute.
fn legacy_const_generic_args(&mut self, expr: &Expr) -> Option<Vec<usize>> {
if let ExprKind::Path(None, path) = &expr.kind {
Expand All @@ -2375,7 +2375,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
return v.clone();
}

let attr = self.tcx.get_attr(def_id, sym::rustc_legacy_const_generics)?;
let attr =
self.tcx.get_attr(def_id, sym::rustc_deprecated_legacy_const_generics)?;
let mut ret = Vec::new();
for meta in attr.meta_item_list()? {
match meta.lit()?.kind {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1872,6 +1872,7 @@ symbols! {
rustc_default_body_unstable,
rustc_delayed_bug_from_inside_query,
rustc_deny_explicit_impl,
rustc_deprecated_legacy_const_generics,
rustc_deprecated_safe_2024,
rustc_diagnostic_item,
rustc_diagnostic_macros,
Expand Down Expand Up @@ -1900,7 +1901,6 @@ symbols! {
rustc_layout,
rustc_layout_scalar_valid_range_end,
rustc_layout_scalar_valid_range_start,
rustc_legacy_const_generics,
rustc_lint_diagnostics,
rustc_lint_opt_deny_field_access,
rustc_lint_opt_ty,
Expand Down
Loading
Loading