Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
36ef11a
Update expect messages in library/alloc/boxed.rs and library/alloc/st…
Colepng Jul 25, 2026
05bb184
sembr src/variance.md
tshepang Jul 25, 2026
5d19c92
Prepare for merging from rust-lang/rust
invalid-email-address Jul 25, 2026
bb4b62b
Merge ref 'da86f4d0726b' from rust-lang/rust
invalid-email-address Jul 25, 2026
acb9407
Split multiline derives into std/rustc macros
mejrs Jul 25, 2026
d57ee22
improve variance.md
tshepang Jul 25, 2026
4196283
Add warning for breakage hazard for introducing new builtin attrs
jieyouxu Jul 25, 2026
d44d12d
Merge pull request #2944 from jieyouxu/builtin_attr
jieyouxu Jul 25, 2026
f36f2b9
sembr src/rustdoc-internals/rustdoc-gui-test-suite.md
tshepang Jul 25, 2026
0d9c6a4
overlong
tshepang Jul 25, 2026
c565998
punctuation
tshepang Jul 25, 2026
54c2643
sembr src/rustdoc-internals/search.md
tshepang Jul 25, 2026
3aecf93
Fix `find_attr` hygiene issues
mejrs Jul 25, 2026
71f1401
typo
tshepang Jul 25, 2026
19ec811
sembr src/stability-guarantees.md
tshepang Jul 25, 2026
2500a68
sembr src/pat-exhaustive-checking.md
tshepang Jul 25, 2026
beddeb0
remove `extern crate self as rustc_hir;` statement
mejrs Jul 25, 2026
72da0f5
improve pat-exhaustive-checking.md
tshepang Jul 25, 2026
a477499
sembr src/ast-validation.md
tshepang Jul 25, 2026
8da4c50
sembr src/notification-groups/gpu-target.md
tshepang Jul 25, 2026
a88b4f0
improve notification-groups/gpu-target.md
tshepang Jul 25, 2026
be78fc8
sembr src/notification-groups/wasm.md
tshepang Jul 25, 2026
01f3867
select the right text to link
tshepang Jul 25, 2026
5c30492
sembr src/const-eval.md
tshepang Jul 25, 2026
721d2b3
Merge pull request #2945 from rust-lang/tshepang/misc
tshepang Jul 25, 2026
ac7ecbd
Merge pull request #2943 from rust-lang/rustc-pull
tshepang Jul 25, 2026
6ce8067
sembr src/attributes.md
tshepang Jul 25, 2026
0dc322b
reflow
tshepang Jul 25, 2026
67e048e
sembr src/tests/autodiff-ci-job.md
tshepang Jul 25, 2026
b5803d3
sembr src/profiling/with-perf.md
tshepang Jul 25, 2026
b7f7f0d
improve profiling/with-perf.md
tshepang Jul 25, 2026
c39587c
Merge pull request #2946 from rust-lang/tshepang/misc
tshepang Jul 25, 2026
4d31be2
Flatten `nested_filter` module, and rename `None`.
mejrs Jul 25, 2026
b41588f
Replace `unreachable!` with `!`
mejrs Jul 25, 2026
c49a172
Note that the expected runtime signature is for the current target only
Urgau Jul 25, 2026
029a240
fix: error in diagnostic on_unmatched_args
amirHdev Jul 25, 2026
b8fd8a8
spare capacity mut constification
bend-n Jul 25, 2026
ecc8402
rename abort_unwind → abort_on_unwind
RalfJung Jul 25, 2026
7697f3d
Fix obsolete `P` reference
mejrs Jul 25, 2026
e24189e
Update `SyntheticAttr` docs
mejrs Jul 25, 2026
b81e756
Minor doc comment formatting
mejrs Jul 25, 2026
d097b81
Update expect messages in library/core/src/ptr/non_null.rs
nirmaladvani Jul 26, 2026
38776dc
Rollup merge of #159882 - Colepng:main, r=Darksonn
chenyukang Jul 26, 2026
4d77a84
Rollup merge of #159891 - mejrs:split_derives, r=JonathanBrouwer
chenyukang Jul 26, 2026
8578ec9
Rollup merge of #159893 - mejrs:find_attr_hygiene, r=JonathanBrouwer
chenyukang Jul 26, 2026
4682545
Rollup merge of #159895 - tshepang:rdg-sync, r=tshepang
chenyukang Jul 26, 2026
fa490b7
Rollup merge of #159902 - Urgau:runtime-symbols-for-current-target, r…
chenyukang Jul 26, 2026
3943d47
Rollup merge of #159914 - amirHdev:fix-on-unmatched-args, r=mejrs
chenyukang Jul 26, 2026
04d59e8
Rollup merge of #159917 - bend-n:split_at_capacity_constifications, r…
chenyukang Jul 26, 2026
170d6fe
Rollup merge of #159918 - RalfJung:abort_unwind, r=hanna-kruppe
chenyukang Jul 26, 2026
9f38a97
Rollup merge of #159936 - mejrs:ast_docs, r=chenyukang
chenyukang Jul 26, 2026
7006855
Rollup merge of #159945 - nirmaladvani:nonnull_expect, r=jhpratt
chenyukang Jul 26, 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
25 changes: 17 additions & 8 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ pub struct PathSegment {
/// `None` means that no parameter list is supplied (`Path`),
/// `Some` means that parameter list is supplied (`Path<X, Y>`)
/// but it can be empty (`Path<>`).
/// `P` is used as a size optimization for the common case with no parameters.
/// `Box` is used as a size optimization for the common case with no parameters.
pub args: Option<Box<GenericArgs>>,
}

Expand Down Expand Up @@ -557,9 +557,10 @@ pub struct Crate {
pub is_placeholder: bool,
}

/// A semantic representation of a meta item. A meta item is a slightly
/// restricted form of an attribute -- it can only contain expressions in
/// certain leaf positions, rather than arbitrary token streams -- that is used
/// A semantic representation of a meta item.
///
/// A meta item is a slightly restricted form of an attribute -- it can only contain
/// expressions in certain leaf positions, rather than arbitrary token streams -- that is used
/// for most built-in attributes.
///
/// E.g., `#[test]`, `#[derive(..)]`, `#[rustfmt::skip]` or `#[feature = "foo"]`.
Expand Down Expand Up @@ -806,6 +807,7 @@ impl ByRef {
}

/// The mode of a binding (`mut`, `ref mut`, etc).
///
/// Used for both the explicit binding annotations given in the HIR for a binding
/// and the final binding mode that we infer after type inference/match ergonomics.
/// `.0` is the by-reference mode (`ref`, `ref mut`, or by value),
Expand Down Expand Up @@ -1184,7 +1186,9 @@ impl UnOp {
}
}

/// A statement. No `attrs` or `tokens` fields because each `StmtKind` variant
/// A statement.
///
/// No `attrs` or `tokens` fields because each `StmtKind` variant
/// contains an AST node with those fields. (Except for `StmtKind::Empty`,
/// which never has attrs or tokens)
#[derive(Clone, Encodable, Decodable, Debug)]
Expand Down Expand Up @@ -1375,6 +1379,8 @@ pub enum UnsafeSource {
UserProvided,
}

/// An anonymous constant.
///
/// A constant (expression) that's not an item or associated item,
/// but needs its own `DefId` for type-checking, const-eval, etc.
/// These are usually found nested inside types (e.g., array lengths)
Expand Down Expand Up @@ -1962,8 +1968,9 @@ pub enum UnsafeBinderCastKind {
Unwrap,
}

/// The explicit `Self` type in a "qualified path". The actual
/// path, including the trait and the associated item, is stored
/// The explicit `Self` type in a "qualified path".
///
/// The actual path, including the trait and the associated item, is stored
/// separately. `position` represents the index of the associated
/// item qualified with this `Self` type.
///
Expand Down Expand Up @@ -3491,6 +3498,8 @@ pub struct AttrItem {
pub span: Span,
}

/// A synthetic attribute.
///
/// Synthetic attributes are inserted by the compiler. They cannot be written in source code, and
/// so cannot be pretty-printed by the AST pretty printer (because its output should be valid Rust
/// code). They receive special treatment because they must not affect observable language
Expand All @@ -3513,7 +3522,7 @@ pub enum SyntheticAttr {
/// evaluated true or not (or even failed to parse). The `pred` and `attrs` are not recorded
/// because they are not needed.
///
/// The attribute is used by some clippy lints.
/// The attribute is used by rustdoc to display `doc_cfg` information and by some clippy lints.
CfgAttrTrace(CfgEntry),
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ impl AttributeParser for OnUnmatchedArgsParser {
AttributeStability::Stable, // Unstable, stability checked manually in the parser
|this, cx, args| {
if !cx.features().diagnostic_on_unmatched_args() {
// `UnknownDiagnosticAttribute` is emitted in rustc_resolve/macros.rs
args.ignore_args();
return;
}

Expand Down
13 changes: 2 additions & 11 deletions compiler/rustc_data_structures/src/svh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,8 @@ use rustc_macros::{Decodable_NoContext, Encodable_NoContext, StableHash};

use crate::fingerprint::Fingerprint;

#[derive(
Copy,
Clone,
PartialEq,
Eq,
Debug,
Encodable_NoContext,
Decodable_NoContext,
Hash,
StableHash
)]
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
#[derive(Encodable_NoContext, Decodable_NoContext, StableHash)]
pub struct Svh {
hash: Fingerprint,
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_hir/src/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ macro_rules! arena_types {
$macro!([
// HIR types
[] asm_template: rustc_ast::InlineAsmTemplatePiece,
[] attribute: rustc_hir::Attribute,
[] owner_info: rustc_hir::OwnerInfo<'tcx>,
[] attribute: crate::Attribute,
[] owner_info: crate::OwnerInfo<'tcx>,
[] macro_def: rustc_ast::MacroDef,
[] delegation_info: rustc_hir::DelegationInfo,
[] delegation_info: crate::DelegationInfo,
]);
)
}
18 changes: 3 additions & 15 deletions compiler/rustc_hir/src/attrs/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use rustc_ast::{AttrStyle, Path, ast};
use rustc_data_structures::Limit;
use rustc_data_structures::fx::FxIndexMap;
use rustc_error_messages::{DiagArgValue, IntoDiagArg};
use rustc_hir::LangItem;
use rustc_macros::{Decodable, Encodable, PrintAttribute, StableHash};
use rustc_span::def_id::DefId;
use rustc_span::hygiene::Transparency;
Expand All @@ -22,7 +21,7 @@ use thin_vec::ThinVec;

use crate::attrs::diagnostic::*;
use crate::attrs::pretty_printing::PrintAttribute;
use crate::{DefaultBodyStability, PartialConstStability, RustcVersion, Stability};
use crate::{DefaultBodyStability, LangItem, PartialConstStability, RustcVersion, Stability};

#[derive(Copy, Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)]
pub enum EiiImplResolution {
Expand Down Expand Up @@ -370,19 +369,8 @@ pub enum PeImportNameType {
Undecorated,
}

#[derive(
Copy,
Clone,
Debug,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Encodable,
Decodable,
PrintAttribute
)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Encodable, Decodable, PrintAttribute)]
#[derive(StableHash)]
pub enum NativeLibKind {
/// Static library (e.g. `libfoo.a` on Linux or `foo.lib` on Windows/MSVC)
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_hir/src/attrs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ macro_rules! find_attr {
'done: {
for i in $attributes_list {
#[allow(unused_imports)]
use rustc_hir::attrs::AttributeKind::*;
let i: &rustc_hir::Attribute = i;
use $crate::attrs::AttributeKind::*;
let i: &$crate::Attribute = i;
match i {
rustc_hir::Attribute::Parsed($pattern) $(if $guard)? => {
$crate::Attribute::Parsed($pattern) $(if $guard)? => {
break 'done Some($e);
}
rustc_hir::Attribute::Unparsed(..) => {}
$crate::Attribute::Unparsed(..) => {}
// In lint emitting, there's a specific exception for this warning.
// It's not usually emitted from inside macros from other crates
// (see https://github.com/rust-lang/rust/issues/110613)
Expand Down
98 changes: 46 additions & 52 deletions compiler/rustc_hir/src/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,71 +114,65 @@ pub trait HirTyCtxt<'hir> {
fn hir_foreign_item(&self, id: ForeignItemId) -> &'hir ForeignItem<'hir>;
}

// Used when no tcx is actually available, forcing manual implementation of nested visitors.
/// Used when no tcx is actually available, forcing manual implementation of nested visitors.
impl<'hir> HirTyCtxt<'hir> for ! {
fn hir_node(&self, _: HirId) -> Node<'hir> {
unreachable!();
*self
}
fn hir_body(&self, _: BodyId) -> &'hir Body<'hir> {
unreachable!();
*self
}
fn hir_item(&self, _: ItemId) -> &'hir Item<'hir> {
unreachable!();
*self
}
fn hir_trait_item(&self, _: TraitItemId) -> &'hir TraitItem<'hir> {
unreachable!();
*self
}
fn hir_impl_item(&self, _: ImplItemId) -> &'hir ImplItem<'hir> {
unreachable!();
*self
}
fn hir_foreign_item(&self, _: ForeignItemId) -> &'hir ForeignItem<'hir> {
unreachable!();
*self
}
}

pub mod nested_filter {
use super::HirTyCtxt;

/// Specifies what nested things a visitor wants to visit. By "nested
/// things", we are referring to bits of HIR that are not directly embedded
/// within one another but rather indirectly, through a table in the crate.
/// This is done to control dependencies during incremental compilation: the
/// non-inline bits of HIR can be tracked and hashed separately.
///
/// The most common choice is `OnlyBodies`, which will cause the visitor to
/// visit fn bodies for fns that it encounters, and closure bodies, but
/// skip over nested item-like things.
///
/// See the comments at [`rustc_hir::intravisit`] for more details on the overall
/// visit strategy.
pub trait NestedFilter<'hir> {
type MaybeTyCtxt: HirTyCtxt<'hir>;

/// Whether the visitor visits nested "item-like" things.
/// E.g., item, impl-item.
const INTER: bool;
/// Whether the visitor visits "intra item-like" things.
/// E.g., function body, closure, `AnonConst`
const INTRA: bool;
}

/// Do not visit any nested things. When you add a new
/// "non-nested" thing, you will want to audit such uses to see if
/// they remain valid.
///
/// Use this if you are only walking some particular kind of tree
/// (i.e., a type, or fn signature) and you don't want to thread a
/// `tcx` around.
pub struct None(());
impl NestedFilter<'_> for None {
type MaybeTyCtxt = !;
const INTER: bool = false;
const INTRA: bool = false;
}
/// Specifies what nested things a visitor wants to visit. By "nested
/// things", we are referring to bits of HIR that are not directly embedded
/// within one another but rather indirectly, through a table in the crate.
/// This is done to control dependencies during incremental compilation: the
/// non-inline bits of HIR can be tracked and hashed separately.
///
/// The most common choice is `OnlyBodies`, which will cause the visitor to
/// visit fn bodies for fns that it encounters, and closure bodies, but
/// skip over nested item-like things.
///
/// See the [module level documentation](self) for more details on the overall
/// visit strategy.
pub trait NestedFilter<'hir> {
type MaybeTyCtxt: HirTyCtxt<'hir>;

/// Whether the visitor visits nested "item-like" things.
/// E.g., item, impl-item.
const INTER: bool;
/// Whether the visitor visits "intra item-like" things.
/// E.g., function body, closure, `AnonConst`
const INTRA: bool;
}

/// Do not visit any nested things. When you add a new
/// "non-nested" thing, you will want to audit such uses to see if
/// they remain valid.
///
/// Use this if you are only walking some particular kind of tree
/// (i.e., a type, or fn signature) and you don't want to thread a
/// `tcx` around.
pub struct IgnoreNested(());
impl NestedFilter<'_> for IgnoreNested {
type MaybeTyCtxt = !;
const INTER: bool = false;
const INTRA: bool = false;
}

use nested_filter::NestedFilter;

/// Each method of the Visitor trait is a hook to be potentially
/// overridden. Each method's default implementation recursively visits
/// the substructure of the input via the corresponding `walk` method;
Expand Down Expand Up @@ -215,7 +209,7 @@ pub trait Visitor<'v>: Sized {
/// `visit_nested_XXX` methods. If a new `visit_nested_XXX` variant is
/// added in the future, it will cause a panic which can be detected
/// and fixed appropriately.
type NestedFilter: NestedFilter<'v> = nested_filter::None;
type NestedFilter: NestedFilter<'v> = IgnoreNested;

/// The result type of the `visit_*` methods. Can be either `()`,
/// or `ControlFlow<T>`.
Expand All @@ -226,16 +220,16 @@ pub trait Visitor<'v>: Sized {
fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
panic!(
"maybe_tcx must be implemented or consider using \
`type NestedFilter = nested_filter::None` (the default)"
`type NestedFilter = Skip` (the default)"
);
}

/// Invoked when a nested item is encountered. By default, when
/// `Self::NestedFilter` is `nested_filter::None`, this method does
/// `Self::NestedFilter` is `Skip`, this method does
/// nothing. **You probably don't want to override this method** --
/// instead, override [`Self::NestedFilter`] or use the "shallow" or
/// "deep" visit patterns described at
/// [`rustc_hir::intravisit`]. The only reason to override
/// [`intravisit`](self). The only reason to override
/// this method is if you want a nested pattern but cannot supply a
/// `TyCtxt`; see `maybe_tcx` for advice.
fn visit_nested_item(&mut self, id: ItemId) -> Self::Result {
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_hir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
#![recursion_limit = "256"]
// tidy-alphabetical-end

extern crate self as rustc_hir;

mod arena;
pub mod attrs;
pub mod canonical_symbols;
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ pub(crate) enum RedefiningRuntimeSymbolsDiag<'tcx> {
"invalid definition of the runtime `{$symbol_name}` symbol used by the standard library"
)]
#[note(
"expected `{$expected_fn_sig}`
"expected `{$expected_fn_sig}` (for the current target)
found `{$found_fn_sig}`"
)]
#[help(
Expand All @@ -851,7 +851,7 @@ pub(crate) enum RedefiningRuntimeSymbolsDiag<'tcx> {
"suspicious definition of the runtime `{$symbol_name}` symbol used by the standard library"
)]
#[note(
"expected `{$expected_fn_sig}`
"expected `{$expected_fn_sig}` (for the current target)
found `{$found_fn_sig}`"
)]
#[help(
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_lint_defs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,8 @@ impl From<StableLintExpectationId> for LintExpectationId {
/// Setting for how to handle a lint.
///
/// See: <https://doc.rust-lang.org/rustc/lints/levels.html>
#[derive(
Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash, Encodable, Decodable, StableHash
)]
#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
#[derive(Encodable, Decodable, StableHash)]
pub enum Level {
/// The `allow` level will not issue any message.
Allow,
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_middle/src/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,8 @@ pub struct DepKindVTable<'tcx> {
/// some independent path or string that persists between runs without
/// the need to be mapped or unmapped. (This ensures we can serialize
/// them even in the absence of a tcx.)
#[derive(
Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable, StableHash
)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Encodable, Decodable, StableHash)]
pub struct WorkProductId {
hash: Fingerprint,
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/hir/nested_filter.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rustc_hir::intravisit::nested_filter::NestedFilter;
use rustc_hir::intravisit::NestedFilter;

use crate::ty::TyCtxt;

Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2126,10 +2126,8 @@ impl fmt::Debug for SourceFile {
///
/// When `SourceFile`s are exported in crate metadata, the `StableSourceFileId`
/// is updated to incorporate the `StableCrateId` of the exporting crate.
#[derive(
Debug, Clone, Copy, Hash, PartialEq, Eq, StableHash, Encodable, Decodable, Default, PartialOrd,
Ord
)]
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Default, Ord)]
#[derive(StableHash, Encodable, Decodable)]
pub struct StableSourceFileId(Hash128);

impl StableSourceFileId {
Expand Down
Loading
Loading