Skip to content

Rollup of 12 pull requests #144101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
fba4177
Simplify assignments.
cjgillot Jun 23, 2025
ac70dc8
Introduce Value::RawPtr as it behaves differently from other aggregates.
cjgillot Jun 30, 2025
be41333
Store a full Ty with each Value.
cjgillot Jun 30, 2025
4750dff
Remove extraneous types.
cjgillot Jun 30, 2025
cbc3cf7
Avoid computing layouts inside coroutines.
cjgillot Jul 1, 2025
4a95b16
Move crashes tests.
cjgillot Jul 2, 2025
24a25db
Revert `tests/run-make/mte-ffi` changes
jieyouxu Jun 10, 2025
37136dd
Disable `tests/run-make/mte-ffi`
jieyouxu Jul 8, 2025
728017e
Make AsyncDrop check that it's being implemented on a local ADT
compiler-errors Jul 9, 2025
c9bdba3
So many test updates x_x
scottmcm Jul 12, 2025
faa6ded
Update cranelift tests
scottmcm Jul 13, 2025
d53b104
Update Miri Tests
scottmcm Jul 13, 2025
fa7734a
Ban projecting into SIMD types [MCP838]
scottmcm Mar 7, 2025
b7d024b
moved tests
Kivooeo Jul 13, 2025
f5485e5
docs(alloc::fmt): Make `type` optional, instead of matching the empty…
nik-rev Jul 13, 2025
c6e1b21
Use hygenic macros for stable-mir
Coder-256 Jul 16, 2025
4e054fc
Port `#[coverage]` to the new attribute system
scrabsha Jul 13, 2025
af39c0c
Emit warning when there is no space between `-o` and confusing arg
xizheyin Jul 10, 2025
c0597fb
cleaned up some tests
Kivooeo Jul 13, 2025
2f5722c
Make `Option` `const PartialEq`
oli-obk Jul 11, 2025
9d29583
Make `NonZero` `const PartialEq`
oli-obk Jul 11, 2025
250648e
Make `derive_const` usable within libcore again
oli-obk Jul 11, 2025
cecf9ea
Add test raw-underscore-lifetime.rs
xizheyin Jul 1, 2025
848d4a5
Remove similar errors about raw underscore lifetime
xizheyin Jul 1, 2025
68b415a
Make slices `[const] PartialEq`
oli-obk Jul 11, 2025
c375244
Add test for `default_field_values` and `const_default`
estebank Jul 8, 2025
aa8647b
Rollup merge of #142300 - jieyouxu:exp-partial-revert-141576, r=Waffl…
jhpratt Jul 18, 2025
c837add
Rollup merge of #143271 - cjgillot:gvn-types, r=oli-obk
jhpratt Jul 18, 2025
e62471d
Rollup merge of #143280 - xizheyin:143152-1, r=compiler-errors
jhpratt Jul 18, 2025
bc55faf
Rollup merge of #143649 - estebank:const-trait-default-field-value, r…
jhpratt Jul 18, 2025
e0d7a2d
Rollup merge of #143699 - compiler-errors:async-drop-fund, r=oli-obk
jhpratt Jul 18, 2025
3bcc727
Rollup merge of #143719 - xizheyin:142812-1, r=jieyouxu
jhpratt Jul 18, 2025
169bde2
Rollup merge of #143833 - scottmcm:final-mcp-838, r=compiler-errors
jhpratt Jul 18, 2025
bfed9c3
Rollup merge of #143891 - scrabsha:push-xxtttopqoprr, r=jdonszelmann
jhpratt Jul 18, 2025
fe8be86
Rollup merge of #143908 - Kivooeo:tf0, r=jieyouxu
jhpratt Jul 18, 2025
119597a
Rollup merge of #143909 - nik-rev:patch-1, r=jhpratt
jhpratt Jul 18, 2025
ce0ca25
Rollup merge of #143925 - oli-obk:slice-const-partialeq, r=fee1-dead
jhpratt Jul 18, 2025
bf6e9b6
Rollup merge of #143997 - Coder-256:stable-mir-macro-hygiene, r=oli-obk
jhpratt Jul 18, 2025
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
19 changes: 19 additions & 0 deletions compiler/rustc_attr_data_structures/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,22 @@ pub enum DeprecatedSince {
Err,
}

#[derive(
Copy,
Debug,
Eq,
PartialEq,
Encodable,
Decodable,
Clone,
HashStable_Generic,
PrintAttribute
)]
pub enum CoverageStatus {
On,
Off,
}

impl Deprecation {
/// Whether an item marked with #[deprecated(since = "X")] is currently
/// deprecated (i.e., whether X is not greater than the current rustc
Expand Down Expand Up @@ -274,6 +290,9 @@ pub enum AttributeKind {
/// Represents `#[const_trait]`.
ConstTrait(Span),

/// Represents `#[coverage]`.
Coverage(Span, CoverageStatus),

///Represents `#[rustc_deny_explicit_impl]`.
DenyExplicitImpl(Span),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ impl AttributeKind {
ConstStability { .. } => Yes,
ConstStabilityIndirect => No,
ConstTrait(..) => No,
Coverage(..) => No,
DenyExplicitImpl(..) => No,
Deprecation { .. } => Yes,
DoNotImplementViaObject(..) => No,
Expand Down
41 changes: 40 additions & 1 deletion compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rustc_attr_data_structures::{AttributeKind, OptimizeAttr, UsedBy};
use rustc_attr_data_structures::{AttributeKind, CoverageStatus, OptimizeAttr, UsedBy};
use rustc_feature::{AttributeTemplate, template};
use rustc_session::parse::feature_err;
use rustc_span::{Span, Symbol, sym};
Expand Down Expand Up @@ -52,6 +52,45 @@ impl<S: Stage> NoArgsAttributeParser<S> for ColdParser {
const CREATE: fn(Span) -> AttributeKind = AttributeKind::Cold;
}

pub(crate) struct CoverageParser;

impl<S: Stage> SingleAttributeParser<S> for CoverageParser {
const PATH: &[Symbol] = &[sym::coverage];
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const TEMPLATE: AttributeTemplate = template!(OneOf: &[sym::off, sym::on]);

fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
let Some(args) = args.list() else {
cx.expected_specific_argument_and_list(cx.attr_span, vec!["on", "off"]);
return None;
};

let Some(arg) = args.single() else {
cx.expected_single_argument(args.span);
return None;
};

let fail_incorrect_argument = |span| cx.expected_specific_argument(span, vec!["on", "off"]);

let Some(arg) = arg.meta_item() else {
fail_incorrect_argument(args.span);
return None;
};

let status = match arg.path().word_sym() {
Some(sym::off) => CoverageStatus::Off,
Some(sym::on) => CoverageStatus::On,
None | Some(_) => {
fail_incorrect_argument(arg.span());
return None;
}
};

Some(AttributeKind::Coverage(cx.attr_span, status))
}
}

pub(crate) struct ExportNameParser;

impl<S: Stage> SingleAttributeParser<S> for ExportNameParser {
Expand Down
26 changes: 24 additions & 2 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ use crate::attributes::allow_unstable::{
AllowConstFnUnstableParser, AllowInternalUnstableParser, UnstableFeatureBoundParser,
};
use crate::attributes::codegen_attrs::{
ColdParser, ExportNameParser, NakedParser, NoMangleParser, OmitGdbPrettyPrinterSectionParser,
OptimizeParser, TargetFeatureParser, TrackCallerParser, UsedParser,
ColdParser, CoverageParser, ExportNameParser, NakedParser, NoMangleParser,
OmitGdbPrettyPrinterSectionParser, OptimizeParser, TargetFeatureParser, TrackCallerParser,
UsedParser,
};
use crate::attributes::confusables::ConfusablesParser;
use crate::attributes::deprecation::DeprecationParser;
Expand Down Expand Up @@ -139,6 +140,7 @@ attribute_parsers!(
// tidy-alphabetical-end

// tidy-alphabetical-start
Single<CoverageParser>,
Single<DeprecationParser>,
Single<DummyParser>,
Single<ExportNameParser>,
Expand Down Expand Up @@ -452,6 +454,25 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
reason: AttributeParseErrorReason::ExpectedSpecificArgument {
possibilities,
strings: false,
list: false,
},
})
}

pub(crate) fn expected_specific_argument_and_list(
&self,
span: Span,
possibilities: Vec<&'static str>,
) -> ErrorGuaranteed {
self.emit_err(AttributeParseError {
span,
attr_span: self.attr_span,
template: self.template.clone(),
attribute: self.attr_path.clone(),
reason: AttributeParseErrorReason::ExpectedSpecificArgument {
possibilities,
strings: false,
list: true,
},
})
}
Expand All @@ -469,6 +490,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
reason: AttributeParseErrorReason::ExpectedSpecificArgument {
possibilities,
strings: true,
list: false,
},
})
}
Expand Down
49 changes: 46 additions & 3 deletions compiler/rustc_attr_parsing/src/session_diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,15 +533,22 @@ pub(crate) struct LinkOrdinalOutOfRange {

pub(crate) enum AttributeParseErrorReason {
ExpectedNoArgs,
ExpectedStringLiteral { byte_string: Option<Span> },
ExpectedStringLiteral {
byte_string: Option<Span>,
},
ExpectedIntegerLiteral,
ExpectedAtLeastOneArgument,
ExpectedSingleArgument,
ExpectedList,
UnexpectedLiteral,
ExpectedNameValue(Option<Symbol>),
DuplicateKey(Symbol),
ExpectedSpecificArgument { possibilities: Vec<&'static str>, strings: bool },
ExpectedSpecificArgument {
possibilities: Vec<&'static str>,
strings: bool,
/// Should we tell the user to write a list when they didn't?
list: bool,
},
}

pub(crate) struct AttributeParseError {
Expand Down Expand Up @@ -615,7 +622,11 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AttributeParseError {
format!("expected this to be of the form `{name} = \"...\"`"),
);
}
AttributeParseErrorReason::ExpectedSpecificArgument { possibilities, strings } => {
AttributeParseErrorReason::ExpectedSpecificArgument {
possibilities,
strings,
list: false,
} => {
let quote = if strings { '"' } else { '`' };
match possibilities.as_slice() {
&[] => {}
Expand All @@ -641,6 +652,38 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AttributeParseError {
}
}
}
AttributeParseErrorReason::ExpectedSpecificArgument {
possibilities,
strings,
list: true,
} => {
let quote = if strings { '"' } else { '`' };
match possibilities.as_slice() {
&[] => {}
&[x] => {
diag.span_label(
self.span,
format!(
"this attribute is only valid with {quote}{x}{quote} as an argument"
),
);
}
[first, second] => {
diag.span_label(self.span, format!("this attribute is only valid with either {quote}{first}{quote} or {quote}{second}{quote} as an argument"));
}
[first @ .., second_to_last, last] => {
let mut res = String::new();
for i in first {
res.push_str(&format!("{quote}{i}{quote}, "));
}
res.push_str(&format!(
"{quote}{second_to_last}{quote} or {quote}{last}{quote}"
));

diag.span_label(self.span, format!("this attribute is only valid with one of the following arguments: {res}"));
}
}
}
}

let suggestions = self.template.suggestions(false, &name);
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_builtin_macros/src/deriving/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub(crate) fn expand_deriving_copy(
methods: Vec::new(),
associated_types: Vec::new(),
is_const,
is_staged_api_crate: cx.ecfg.features.staged_api(),
};

trait_def.expand(cx, mitem, item, push);
Expand All @@ -46,6 +47,7 @@ pub(crate) fn expand_deriving_const_param_ty(
methods: Vec::new(),
associated_types: Vec::new(),
is_const,
is_staged_api_crate: cx.ecfg.features.staged_api(),
};

trait_def.expand(cx, mitem, item, push);
Expand All @@ -60,6 +62,7 @@ pub(crate) fn expand_deriving_const_param_ty(
methods: Vec::new(),
associated_types: Vec::new(),
is_const,
is_staged_api_crate: cx.ecfg.features.staged_api(),
};

trait_def.expand(cx, mitem, item, push);
Expand All @@ -83,6 +86,7 @@ pub(crate) fn expand_deriving_unsized_const_param_ty(
methods: Vec::new(),
associated_types: Vec::new(),
is_const,
is_staged_api_crate: cx.ecfg.features.staged_api(),
};

trait_def.expand(cx, mitem, item, push);
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_builtin_macros/src/deriving/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ pub(crate) fn expand_deriving_clone(
}],
associated_types: Vec::new(),
is_const,
is_staged_api_crate: cx.ecfg.features.staged_api(),
};

trait_def.expand_ext(cx, mitem, item, push, is_simple)
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub(crate) fn expand_deriving_eq(
}],
associated_types: Vec::new(),
is_const,
is_staged_api_crate: cx.ecfg.features.staged_api(),
};
trait_def.expand_ext(cx, mitem, item, push, true)
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub(crate) fn expand_deriving_ord(
}],
associated_types: Vec::new(),
is_const,
is_staged_api_crate: cx.ecfg.features.staged_api(),
};

trait_def.expand(cx, mitem, item, push)
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub(crate) fn expand_deriving_partial_eq(
methods: Vec::new(),
associated_types: Vec::new(),
is_const: false,
is_staged_api_crate: cx.ecfg.features.staged_api(),
};
structural_trait_def.expand(cx, mitem, item, push);

Expand Down Expand Up @@ -58,6 +59,7 @@ pub(crate) fn expand_deriving_partial_eq(
methods,
associated_types: Vec::new(),
is_const,
is_staged_api_crate: cx.ecfg.features.staged_api(),
};
trait_def.expand(cx, mitem, item, push)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ pub(crate) fn expand_deriving_partial_ord(
methods: vec![partial_cmp_def],
associated_types: Vec::new(),
is_const,
is_staged_api_crate: cx.ecfg.features.staged_api(),
};
trait_def.expand(cx, mitem, item, push)
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_builtin_macros/src/deriving/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub(crate) fn expand_deriving_debug(
}],
associated_types: Vec::new(),
is_const,
is_staged_api_crate: cx.ecfg.features.staged_api(),
};
trait_def.expand(cx, mitem, item, push)
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_builtin_macros/src/deriving/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub(crate) fn expand_deriving_default(
}],
associated_types: Vec::new(),
is_const,
is_staged_api_crate: cx.ecfg.features.staged_api(),
};
trait_def.expand(cx, mitem, item, push)
}
Expand Down
47 changes: 44 additions & 3 deletions compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,11 @@ use std::{iter, vec};
pub(crate) use StaticFields::*;
pub(crate) use SubstructureFields::*;
use rustc_ast::ptr::P;
use rustc_ast::token::{IdentIsRaw, LitKind, Token, TokenKind};
use rustc_ast::tokenstream::{DelimSpan, Spacing, TokenTree};
use rustc_ast::{
self as ast, AnonConst, BindingMode, ByRef, EnumDef, Expr, GenericArg, GenericParamKind,
Generics, Mutability, PatKind, VariantData,
self as ast, AnonConst, AttrArgs, BindingMode, ByRef, DelimArgs, EnumDef, Expr, GenericArg,
GenericParamKind, Generics, Mutability, PatKind, Safety, VariantData,
};
use rustc_attr_data_structures::{AttributeKind, ReprPacked};
use rustc_attr_parsing::AttributeParser;
Expand Down Expand Up @@ -222,6 +224,8 @@ pub(crate) struct TraitDef<'a> {
pub associated_types: Vec<(Ident, Ty)>,

pub is_const: bool,

pub is_staged_api_crate: bool,
}

pub(crate) struct MethodDef<'a> {
Expand Down Expand Up @@ -784,8 +788,45 @@ impl<'a> TraitDef<'a> {
// Create the type of `self`.
let path = cx.path_all(self.span, false, vec![type_ident], self_params);
let self_type = cx.ty_path(path);
let rustc_const_unstable =
cx.path_ident(self.span, Ident::new(sym::rustc_const_unstable, self.span));

let mut attrs = thin_vec![cx.attr_word(sym::automatically_derived, self.span),];

// Only add `rustc_const_unstable` attributes if `derive_const` is used within libcore/libstd,
// Other crates don't need stability attributes, so adding them is not useful, but libcore needs them
// on all const trait impls.
if self.is_const && self.is_staged_api_crate {
attrs.push(
cx.attr_nested(
rustc_ast::AttrItem {
unsafety: Safety::Default,
path: rustc_const_unstable,
args: AttrArgs::Delimited(DelimArgs {
dspan: DelimSpan::from_single(self.span),
delim: rustc_ast::token::Delimiter::Parenthesis,
tokens: [
TokenKind::Ident(sym::feature, IdentIsRaw::No),
TokenKind::Eq,
TokenKind::lit(LitKind::Str, sym::derive_const, None),
TokenKind::Comma,
TokenKind::Ident(sym::issue, IdentIsRaw::No),
TokenKind::Eq,
TokenKind::lit(LitKind::Str, sym::derive_const_issue, None),
]
.into_iter()
.map(|kind| {
TokenTree::Token(Token { kind, span: self.span }, Spacing::Alone)
})
.collect(),
}),
tokens: None,
},
self.span,
),
)
}

let attrs = thin_vec![cx.attr_word(sym::automatically_derived, self.span),];
let opt_trait_ref = Some(trait_ref);

cx.item(
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_builtin_macros/src/deriving/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub(crate) fn expand_deriving_hash(
}],
associated_types: Vec::new(),
is_const,
is_staged_api_crate: cx.ecfg.features.staged_api(),
};

hash_trait_def.expand(cx, mitem, item, push);
Expand Down
Loading
Loading