Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
797b6c9
remove deprecated/remove/rustdoc_internal doc attributes from suggest…
mejrs Aug 31, 2026
25e99b2
Warn on `#[doc()]`
mejrs Aug 31, 2026
da1a5df
take `&Item` instead of `Annotatable` as derive macro input
cyrgani Aug 24, 2026
12beb43
take `Box<Item>` instead of `Annotatable` as the `push` argument
cyrgani Aug 24, 2026
6221469
several small cleanups
cyrgani Aug 26, 2026
a054d6f
remove one use of `expand_ext`
cyrgani Aug 27, 2026
2bc7a87
dissolve the `cmp` subdirectory
cyrgani Aug 27, 2026
c186774
split `bounds` module into `const_param_ty` and `copy` modules
cyrgani Aug 27, 2026
38adf7b
remove last `StaticFields` usage
cyrgani Aug 27, 2026
3c3c3cd
remove `StaticFields` and `IsTuple`
cyrgani Aug 27, 2026
5f0a64e
Use attribute parser for `#[non_exhaustive]` attribute check
obeis Aug 21, 2026
cca9f30
Refactored the handling of the indirect return pointer in cg_ssa to a…
FractalFir Aug 5, 2025
e6b7dc8
Ported cg_gcc to the new cg_ssa version
FractalFir Aug 5, 2025
74bba56
Apply suggestions from code review
FractalFir Sep 19, 2025
43965ea
Add missing indirect return argument to new calls
antoyo Nov 1, 2025
a714a9e
Improve the new indirect return API
antoyo Jul 19, 2026
d244854
Address review
antoyo Jul 27, 2026
7d0d273
Add missing direct return arguments
antoyo Aug 21, 2026
a551126
The fuchsia team maintains `riscv64gc-unknown-fuchsia`
erickt Sep 8, 2026
225a061
Implement arbitrary casts in custom mir
maxdexh Aug 18, 2026
676862d
Add extra linebreak to weird test
maxdexh Sep 10, 2026
15d0810
split `macroless_generic_const_args` in two
BoxyUwU Sep 9, 2026
2319a0c
regression test for opaque field projection in closure capture
malezjaa Sep 11, 2026
ad89677
Skip linting unused braces for FunctionArg and MethodArg context for …
chenyukang Mar 25, 2026
69afc99
Refactor `HygieneEncodeContext`
aerooneqq Sep 11, 2026
8e35cfe
Update platform support docs for `i686-pc-windows-msvc`
jieyouxu Sep 10, 2026
c5eb55c
Fix target spec metadata for `i686-pc-windows-msvc`
jieyouxu Sep 10, 2026
7125897
Update platform support page for `windows-msvc`
jieyouxu Sep 10, 2026
04547c1
Update VS 2022 => VS 2026
jieyouxu Sep 11, 2026
01d381c
Rollup merge of #162520 - aerooneqq:hygiene-perf, r=petrochenkov
Zalathar Sep 11, 2026
4c0ae0b
Rollup merge of #154373 - chenyukang:yukang-fix-154247-unused-braces-…
Zalathar Sep 11, 2026
581804a
Rollup merge of #160023 - antoyo:ssa-indirect-return, r=workingjubilee
Zalathar Sep 11, 2026
08a090c
Rollup merge of #160860 - maxdexh:custom-mir-casts, r=oli-obk
Zalathar Sep 11, 2026
aa4dc4e
Rollup merge of #161482 - obeis:check-non-exhaustive, r=JonathanBrouwer
Zalathar Sep 11, 2026
c67880d
Rollup merge of #161867 - cyrgani:builtin-macros-deeper-clean, r=adwi…
Zalathar Sep 11, 2026
48eb921
Rollup merge of #162099 - mejrs:doc_values, r=JonathanBrouwer
Zalathar Sep 11, 2026
7516892
Rollup merge of #162541 - BoxyUwU:twos_a_crowd, r=khyperia
Zalathar Sep 11, 2026
67298ee
Rollup merge of #162549 - erickt:riscv64, r=JonathanBrouwer
Zalathar Sep 11, 2026
b475daf
Rollup merge of #162577 - jieyouxu:i686-msvc-no-host-tools, r=khyperia
Zalathar Sep 11, 2026
4b63200
Rollup merge of #162624 - malezjaa:test-opaque-field-projection-closu…
Zalathar Sep 11, 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
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let old_attrs =
self.curr_owner.attrs.get(&ex.hir_id.local_id).copied().unwrap_or(&[]);
let new_attrs = self
.lower_attrs_vec(&e.attrs, e.span, ex.hir_id, Target::from_expr(e))
.lower_attrs_vec(&e.attrs, e.span, ex.hir_id, Target::from_expr(e), None)
.into_iter()
.chain(old_attrs.iter().cloned());
let new_attrs = &*self.arena.alloc_from_iter(new_attrs);
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
&i.attrs,
i.span,
Target::from_ast_item(i),
Some(i),
&extra_hir_attributes,
);

Expand Down
9 changes: 6 additions & 3 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
target_span: Span,
target: Target,
) -> &'hir [hir::Attribute] {
self.lower_attrs_with_extra(id, attrs, target_span, target, &[])
self.lower_attrs_with_extra(id, attrs, target_span, target, None, &[])
}

fn lower_attrs_with_extra(
Expand All @@ -1191,13 +1191,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
attrs: &[Attribute],
target_span: Span,
target: Target,
target_item: Option<&ast::Item>,
extra_hir_attributes: &[hir::Attribute],
) -> &'hir [hir::Attribute] {
if attrs.is_empty() && extra_hir_attributes.is_empty() {
&[]
} else {
let mut lowered_attrs =
self.lower_attrs_vec(attrs, self.lower_span(target_span), id, target);
self.lower_attrs_vec(attrs, self.lower_span(target_span), id, target, target_item);
lowered_attrs.extend(extra_hir_attributes.iter().cloned());

assert_eq!(id.owner, self.curr_owner.owner_id);
Expand All @@ -1224,12 +1225,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
target_span: Span,
target_hir_id: HirId,
target: Target,
target_item: Option<&ast::Item>,
) -> Vec<hir::Attribute> {
let l = self.span_lowerer();
self.attribute_parser.parse_attribute_list(
attrs,
target_span,
target,
target_item,
|s| l.lower(s),
|lint_id, span, kind| {
self.curr_owner.delayed_lints.push(DelayedLint {
Expand Down Expand Up @@ -2685,7 +2688,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
match (body, kind) {
(body, ConstItemKind::Body) => {
let is_direct = |body| {
if self.tcx.features().macroless_generic_const_args() {
if self.tcx.features().macroless_const_item_generic_const_args() {
self.can_lower_expr_to_const_arg_direct(
body,
DirectConstArgContext::MacrolessMinGenericConstArgs,
Expand Down
32 changes: 11 additions & 21 deletions compiler/rustc_attr_parsing/src/attributes/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,16 +705,7 @@ impl DocParser {

fn accept_single_doc_attr(&mut self, cx: &mut AcceptContext<'_, '_>, args: &ArgParser) {
match args {
ArgParser::NoArgs => {
let suggestions = cx.adcx().suggestions();
let span = cx.inner_span;
cx.emit_lint(
INVALID_DOC_ATTRIBUTES,
IllFormedAttributeInput::new(&suggestions, None, None),
span,
);
}
ArgParser::List(items) => {
ArgParser::List(items) if !items.is_empty() => {
for i in items.mixed() {
match i {
MetaItemOrLitParser::MetaItemParser(mip) => {
Expand All @@ -739,6 +730,15 @@ impl DocParser {
);
}
}
_ => {
let suggestions = cx.adcx().suggestions();
let span = cx.inner_span;
cx.emit_lint(
INVALID_DOC_ATTRIBUTES,
IllFormedAttributeInput::new(&suggestions, None, None),
span,
);
}
}
}
}
Expand All @@ -749,7 +749,6 @@ impl AttributeParser for DocParser {
template!(
List: &[
"alias",
"attribute",
"hidden",
"html_favicon_url",
"html_logo_url",
Expand All @@ -762,19 +761,10 @@ impl AttributeParser for DocParser {
"masked",
"cfg",
"notable_trait",
"keyword",
"fake_variadic",
"search_unbox",
"rust_logo",
"auto_cfg",
"test",
"spotlight",
"include",
"no_default_passes",
"passes",
"plugins",
],
NameValueStr: "string"
NameValueStr: "doc comment"
),
AttributeStability::Stable, // Some parts of the attribute are unstable, manually checked in parser
|this, cx, args| {
Expand Down
28 changes: 22 additions & 6 deletions compiler/rustc_attr_parsing/src/attributes/non_exhaustive.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
use rustc_attr_ir::AttributeKind;
use rustc_attr_ir::target::Target;
use rustc_ast::{ItemKind, VariantData};
use rustc_feature::AttributeStability;
use rustc_span::{Span, Symbol, sym};

use crate::attributes::{NoArgsAttributeParser, OnDuplicate};
use crate::target_checking::AllowedTargets;
use crate::target_checking::Policy::{Allow, Warn};
use super::prelude::*;
use crate::diagnostics::NonExhaustiveWithDefaultFieldValues;

pub(crate) struct NonExhaustiveParser;

Expand All @@ -23,4 +20,23 @@ impl NoArgsAttributeParser for NonExhaustiveParser {
]);
const STABILITY: AttributeStability = AttributeStability::Stable;
const CREATE: fn(Span) -> AttributeKind = AttributeKind::NonExhaustive;

fn finalize_check(cx: &FinalizeCheckContext<'_, '_>, attr_span: Span) {
if cx.target != Target::Struct {
return;
}

let item = cx.target_item.expect("missing AST target item for Target::Struct");
let ItemKind::Struct(_, _, data) = &item.kind else {
panic!("expected struct AST target item for Target::Struct");
};
if let VariantData::Struct { fields, .. } = data
&& fields.iter().any(|f| f.default_value().is_some())
{
cx.emit_err(NonExhaustiveWithDefaultFieldValues {
attr_span,
defn_span: cx.target_span,
});
}
}
}
4 changes: 4 additions & 0 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,10 @@ pub(crate) struct FinalizeCheckContext<'p, 'sess> {
///
/// Unlike [`all_attrs`](Self::all_attrs), this contains the fully parsed attributes.
pub(crate) parsed_attrs: &'p [Attribute],

/// The AST item these attributes were applied to, when the target is an item.
/// Used by `finalize_check` to inspect item structure that is not encoded in [`Target`].
pub(crate) target_item: Option<&'p rustc_ast::ast::Item>,
}

impl<'p, 'sess: 'p> Deref for FinalizeCheckContext<'p, 'sess> {
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_attr_parsing/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,15 @@ pub(crate) struct DeprecatedAnnotationHasNoEffect {
pub span: Span,
}

#[derive(Diagnostic)]
#[diag("`#[non_exhaustive]` can't be used to annotate items with default field values")]
pub(crate) struct NonExhaustiveWithDefaultFieldValues {
#[primary_span]
pub attr_span: Span,
#[label("this struct has default field values")]
pub defn_span: Span,
}

#[derive(Diagnostic)]
#[diag("expected single version literal")]
pub(crate) struct ExpectedSingleVersionLiteral {
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_attr_parsing/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ impl<'sess> AttributeParser<'sess> {
attrs,
target_span,
target,
None,
std::convert::identity,
|lint_id, span, kind| {
sess.psess.dyn_buffer_lint_sess(lint_id.lint, span, target_node_id, kind.0)
Expand Down Expand Up @@ -315,6 +316,7 @@ impl<'sess> AttributeParser<'sess> {
attrs: &[ast::Attribute],
target_span: Span,
target: Target,
target_item: Option<&ast::Item>,
lower_span: impl Copy + Fn(Span) -> Span,
mut emit_lint: impl FnMut(LintId, MultiSpan, EmitAttribute),
) -> Vec<Attribute> {
Expand Down Expand Up @@ -521,6 +523,7 @@ impl<'sess> AttributeParser<'sess> {
},
all_attrs: &attr_paths,
parsed_attrs: &attributes,
target_item,
},
attr_span,
);
Expand Down
56 changes: 0 additions & 56 deletions compiler/rustc_builtin_macros/src/deriving/bounds.rs

This file was deleted.

57 changes: 26 additions & 31 deletions compiler/rustc_builtin_macros/src/deriving/clone.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rustc_ast::{self as ast, Generics, ItemKind, MetaItem, Safety, VariantData};
use rustc_data_structures::fx::FxHashSet;
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_expand::base::ExtCtxt;
use rustc_span::{DUMMY_SP, Ident, Span, kw, sym};
use thin_vec::{ThinVec, thin_vec};

Expand All @@ -12,8 +12,8 @@ pub(crate) fn expand_deriving_clone(
cx: &ExtCtxt<'_>,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
push: &mut dyn FnMut(Annotatable),
item: &ast::Item,
push: &mut dyn FnMut(Box<ast::Item>),
is_const: bool,
) {
// The simple form is `fn clone(&self) -> Self { *self }`, possibly with
Expand All @@ -32,35 +32,30 @@ pub(crate) fn expand_deriving_clone(
let bounds;
let substructure;
let is_simple;
match item {
Annotatable::Item(annitem) => match &annitem.kind {
ItemKind::Struct(_, Generics { params, .. }, _)
| ItemKind::Enum(_, Generics { params, .. }, _) => {
let container_id = cx.current_expansion.id.expn_data().parent.expect_local();
let has_derive_copy = cx.resolver.has_derive_copy(container_id);
bounds = smallvec![];
if has_derive_copy
&& !params
.iter()
.any(|param| matches!(param.kind, ast::GenericParamKind::Type { .. }))
{
is_simple = true;
substructure =
combine_substructure(|c, s, sub| cs_clone_simple(c, s, sub, false));
} else {
is_simple = false;
substructure = combine_substructure(cs_clone);
}
}
ItemKind::Union(..) => {
bounds = smallvec![Path(path_std!(marker::Copy))];
match &item.kind {
ItemKind::Struct(_, Generics { params, .. }, _)
| ItemKind::Enum(_, Generics { params, .. }, _) => {
let container_id = cx.current_expansion.id.expn_data().parent.expect_local();
let has_derive_copy = cx.resolver.has_derive_copy(container_id);
bounds = smallvec![];
if has_derive_copy
&& !params
.iter()
.any(|param| matches!(param.kind, ast::GenericParamKind::Type { .. }))
{
is_simple = true;
substructure = combine_substructure(|c, s, sub| cs_clone_simple(c, s, sub, true));
substructure = combine_substructure(|c, s, sub| cs_clone_simple(c, s, sub, false));
} else {
is_simple = false;
substructure = combine_substructure(cs_clone);
}
_ => cx.dcx().span_bug(span, "`#[derive(Clone)]` on wrong item kind"),
},

_ => cx.dcx().span_bug(span, "`#[derive(Clone)]` on trait item or impl item"),
}
ItemKind::Union(..) => {
bounds = smallvec![Path(path_std!(marker::Copy))];
is_simple = true;
substructure = combine_substructure(|c, s, sub| cs_clone_simple(c, s, sub, true));
}
_ => cx.dcx().span_bug(span, "`#[derive(Clone)]` on wrong item kind"),
}

// If the clone method is just copying the value, also mark the type as
Expand All @@ -82,7 +77,7 @@ pub(crate) fn expand_deriving_clone(
document: false,
};

trivial_def.expand_ext(cx, mitem, item, push, true);
trivial_def.expand(cx, mitem, item, push);
}

let trait_def = TraitDef {
Expand Down
Loading
Loading