Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
7530fc1
Mark the compile unit for `-Zdebuginfo-for-profiling`
apolloww Nov 4, 2026
1a9e176
Don't blindly say that a macro call doesn't expand to a certain fragment
fmease Nov 4, 2026
a7c41c1
Turn `pattern_type` into a macro 2.0 that expands to `k#pattern_type(…
fmease Sep 3, 2026
8f7bf49
Turn `view_type` into a macro 2.0 that expands to `k#view_type(...)`
fmease Nov 4, 2026
ad13cdf
fix NumScalableVectors::from_field_count
malezjaa Nov 8, 2026
41ed8b9
Remove parsed arm of `check_attr`
JonathanBrouwer Nov 9, 2026
a8e1a33
Move `check_attr` to attribute parsing
JonathanBrouwer Nov 9, 2026
fb94dbd
Add test checking that the behaviour for diagnostic attrs is preserved
JonathanBrouwer Nov 9, 2026
3cf3c87
std Miri testing: use skip_unsupported_miri_tests to control when tes…
RalfJung Oct 29, 2026
0aa6251
Unignore passing GCC backend tests
GuillaumeGomez Nov 8, 2026
0e99915
mpsc_sync::stream_send_recv_stress: wait for all thread to finish
RalfJung Nov 9, 2026
f03fbea
Rollup merge of #165117 - RalfJung:skip_missing_miri_shims, r=maxdexh
JonathanBrouwer Nov 9, 2026
e5f6cb4
Rollup merge of #165487 - fmease:built-in-macro-to-internal-syntax, r…
JonathanBrouwer Nov 9, 2026
fdb7c62
Rollup merge of #165490 - apolloww:debuginfo-for-profiling-compile-un…
JonathanBrouwer Nov 9, 2026
1d03644
Rollup merge of #165646 - malezjaa:fix-from_field_count, r=workingjub…
JonathanBrouwer Nov 9, 2026
d2a6a09
Rollup merge of #165655 - GuillaumeGomez:gcc-tests, r=antoyo
JonathanBrouwer Nov 9, 2026
5acd95a
Rollup merge of #165693 - JonathanBrouwer:check-attr, r=mejrs
JonathanBrouwer Nov 9, 2026
9542910
Rollup merge of #165717 - RalfJung:stream_send_recv_stress, r=maxdexh
JonathanBrouwer Nov 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1778,12 +1778,12 @@ impl NumScalableVectors {
NumScalableVectors(1)
}

// Returns `NumScalableVectors` for values of two through eight, which are a valid number of
// fields for a tuple of scalable vectors to have. `1` is a valid value of `NumScalableVectors`
// but not for a tuple which would have a field count.
/// Returns `NumScalableVectors` for values of two through eight, which are a valid number of
/// fields for a tuple of scalable vectors to have. `1` is a valid value of `NumScalableVectors`
/// but not for a tuple which would have a field count.
pub fn from_field_count(count: usize) -> Option<Self> {
match count {
2..8 => Some(NumScalableVectors(count as u8)),
2..=8 => Some(NumScalableVectors(count as u8)),
_ => None,
}
}
Expand Down
5 changes: 0 additions & 5 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use rustc_abi::{CVariadicStatus, CanonAbi, ExternAbi, InterruptKind};
use rustc_ast::visit::{AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor, walk_list};
use rustc_ast::*;
use rustc_ast_pretty::pprust::{self, State};
use rustc_attr_parsing::validate_attr;
use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::{DiagCtxtHandle, Diagnostic, LintBuffer};
use rustc_feature::Features;
Expand Down Expand Up @@ -1402,10 +1401,6 @@ fn validate_generic_param_order(dcx: DiagCtxtHandle<'_>, generics: &[GenericPara
}

impl Visitor<'_> for AstValidator<'_> {
fn visit_attribute(&mut self, attr: &Attribute) {
validate_attr::check_attr(&self.sess.psess, attr);
}

fn visit_ty(&mut self, ty: &Ty) {
self.visit_ty_common(ty);
self.walk_ty(ty)
Expand Down
7 changes: 0 additions & 7 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
// Function pointers cannot be `const`
self.check_late_bound_lifetime_defs(&fn_ptr_ty.generic_params);
}
ast::TyKind::Pat(..) => {
gate!(self, pattern_types, ty.span, "pattern types are unstable");
}
ast::TyKind::View(..) => {
gate!(self, view_types, ty.span, "view types are unstable");
}
_ => {}
}
visit::walk_ty(self, ty)
Expand Down Expand Up @@ -469,7 +463,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
gate_all!(unnamed_enum_variants, "unnamed enum variants are experimental");
gate_all!(unsafe_binders, "unsafe binder types are experimental");
gate_all!(unsafe_fields, "`unsafe` fields are experimental");
gate_all!(view_types, "view types are experimental");
gate_all!(where_clause_attrs, "attributes in `where` clause are unstable");
gate_all!(yeet_expr, "`do yeet` expression is experimental");
// tidy-alphabetical-end
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1437,9 +1437,12 @@ impl<'a> State<'a> {
self.word("...");
}
ast::TyKind::Pat(ty, pat) => {
self.word("k#pattern_type");
self.popen();
self.print_type(ty);
self.word(" is ");
self.print_ty_pat(pat);
self.pclose();
}
ast::TyKind::FieldOf(ty, variant, field) => {
self.word("k#field_of");
Expand All @@ -1459,8 +1462,11 @@ impl<'a> State<'a> {
self.pclose();
}
ast::TyKind::View(ty, fields) => {
self.word("k#view_type");
self.popen();
self.print_type(ty);
self.print_view(fields);
self.pclose();
}
ast::TyKind::GcaMacro(expr) => {
self.word_nbsp("core::gca!");
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_pretty/src/pprust/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ fn test_field_view() {
};

let ty_str = ty_to_string(&ty);
assert_eq!(ty_str, "(/*DUMMY*/).{ milhouse, apu }");
assert_eq!(ty_str, "k#view_type((/*DUMMY*/).{ milhouse, apu })");
});
}
16 changes: 15 additions & 1 deletion compiler/rustc_attr_parsing/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::diagnostics::ParsedDescription;
use crate::generated::GeneratedAttrState;
use crate::parser::{AllowExprMetavar, ArgParser, PathParser, RefPathParser};
use crate::synthetic::SyntheticAttrState;
use crate::validate_attr::parse_meta;
use crate::{AttributeTemplate, ShouldEmit, diagnostics};

pub struct EmitAttribute(
Expand Down Expand Up @@ -359,7 +360,8 @@ impl<'sess> AttributeParser<'sess> {
n.item.path.segments.iter().map(|seg| seg.ident.name).collect::<Vec<_>>();
let inner_span = lower_span(n.item.span);

if let Some(accept) = ATTRIBUTE_PARSERS.accepters.get(parts.as_slice()) {
let accepter = ATTRIBUTE_PARSERS.accepters.get(parts.as_slice());
if let Some(accept) = accepter {
self.check_attribute_safety(
&attr_path,
inner_span,
Expand Down Expand Up @@ -492,6 +494,18 @@ impl<'sess> AttributeParser<'sess> {

attributes.push(attr);
};

if accepter.is_none()
&& let rustc_ast::AttrArgs::Eq { .. } = n.item.args
{
// All key-value attributes are restricted to meta-item syntax.
match parse_meta(&self.sess.psess, &attr) {
Ok(_) => {}
Err(err) => {
err.emit();
}
}
}
}
}
}
Expand Down
54 changes: 2 additions & 52 deletions compiler/rustc_attr_parsing/src/validate_attr.rs
Original file line number Diff line number Diff line change
@@ -1,72 +1,22 @@
//! Meta-syntax validation logic of attributes for post-expansion.

use std::convert::identity;
use std::slice;

use rustc_ast::SyntheticAttr::CfgAttrTrace;
use rustc_ast::token::Delimiter;
use rustc_ast::tokenstream::DelimSpan;
use rustc_ast::{
self as ast, AttrArgs, AttrKind, Attribute, DelimArgs, MetaItem, MetaItemInner, MetaItemKind,
Safety,
self as ast, AttrArgs, Attribute, DelimArgs, MetaItem, MetaItemInner, MetaItemKind, Safety,
};
use rustc_attr_ir::AttrPath;
use rustc_errors::{Applicability, Diagnostic, PResult};
use rustc_feature::BUILTIN_ATTRIBUTE_SET;
use rustc_lint_defs::builtin::ILL_FORMED_ATTRIBUTE_INPUT;
use rustc_parse::parse_in;
use rustc_session::diagnostics::report_lit_error;
use rustc_session::parse::ParseSess;
use rustc_span::{Span, Symbol, sym};

use crate::{AttributeParser, AttributeTemplate, diagnostics as errors, template};

pub fn check_attr(psess: &ParseSess, attr: &Attribute) {
use ast::SyntheticAttr::*;
match &attr.kind {
AttrKind::Normal(_) => {}
AttrKind::Synthetic(CfgTrace(_) | CfgAttrTrace(_))
| AttrKind::DocComment(..)
| AttrKind::Generated(..) => return,
}

let builtin_attr_info = attr.name().and_then(|name| BUILTIN_ATTRIBUTE_SET.get(&name));

// Check input tokens for built-in and key-value attributes.
if let Some(name) = builtin_attr_info {
if AttributeParser::is_parsed_attribute(slice::from_ref(name)) {
return;
}
match parse_meta(psess, attr) {
// Don't check safety again, we just did that
Ok(meta) => {
// FIXME The only unparsed builtin attributes that are left are the lint attributes, so we can hardcode the template here
let lint_attrs = [sym::forbid, sym::allow, sym::warn, sym::deny, sym::expect];
assert!(lint_attrs.contains(name));

let template = template!(
List: &["lint1", "lint1, lint2, ...", r#"lint1, lint2, lint3, reason = "...""#],
"https://doc.rust-lang.org/reference/attributes/diagnostics.html#lint-check-attributes"
);
check_builtin_meta_item(psess, &meta, attr.style, *name, template, false)
}
Err(err) => {
err.emit();
}
}
} else {
let attr_item = attr.get_normal_item();
if let AttrArgs::Eq { .. } = attr_item.args {
// All key-value attributes are restricted to meta-item syntax.
match parse_meta(psess, attr) {
Ok(_) => {}
Err(err) => {
err.emit();
}
}
}
}
}
use crate::{AttributeTemplate, diagnostics as errors};

pub fn parse_meta<'a>(psess: &'a ParseSess, attr: &Attribute) -> PResult<'a, MetaItem> {
let item = attr.get_normal_item();
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_builtin_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ mod global_allocator;
mod iter;
mod log_syntax;
mod offload;
mod pattern_type;
mod rustdoc_skip_body;
mod source_util;
mod test;
mod test_binder_constraints;
mod trace_macros;
mod view_type;

pub mod asm;
pub mod cmdline_attrs;
Expand Down Expand Up @@ -100,13 +98,11 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
module_path: source_util::expand_mod,
naked_asm: asm::expand_naked_asm,
option_env: env::expand_option_env,
pattern_type: pattern_type::expand,
std_panic: edition_panic::expand_panic,
stringify: source_util::expand_stringify,
test_binder_constraints: test_binder_constraints::expand,
trace_macros: trace_macros::expand_trace_macros,
unreachable: edition_panic::expand_unreachable,
view_type: view_type::expand,
// tidy-alphabetical-end
}

Expand Down
75 changes: 0 additions & 75 deletions compiler/rustc_builtin_macros/src/pattern_type.rs

This file was deleted.

47 changes: 0 additions & 47 deletions compiler/rustc_builtin_macros/src/view_type.rs

This file was deleted.

12 changes: 5 additions & 7 deletions compiler/rustc_codegen_cranelift/example/mini_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
extern_types,
decl_macro,
rustc_attrs,
allow_internal_unstable,
forced_keywords,
rustc_private,
transparent_unions,
pattern_types,
auto_traits,
freeze_impls
)]
Expand Down Expand Up @@ -591,12 +592,9 @@ pub trait Deref {
fn deref(&self) -> &Self::Target;
}

#[rustc_builtin_macro(pattern_type)]
#[macro_export]
macro_rules! pattern_type {
($($arg:tt)*) => {
/* compiler built-in */
};
#[allow_internal_unstable(internal_syntax)]
pub macro pattern_type($($arg:tt)*) {
k#pattern_type($($arg)*)
}

impl<T: PointeeSized, U: PointeeSized> CoerceUnsized<pattern_type!(*const U is !null)> for pattern_type!(*const T is !null) where
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
#![feature(
no_core,
lang_items,
extern_types,
thread_local,
repr_simd,
pattern_types,
rustc_private
)]
#![feature(no_core, lang_items, extern_types, thread_local, repr_simd, rustc_private)]
#![cfg_attr(not(any(jit, target_vendor = "apple", windows)), feature(linkage))]
#![no_core]
#![allow(dead_code, non_camel_case_types, internal_features)]
Expand Down
Loading
Loading