Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0d0aaa1
Some arena macro tweaks.
nnethercote Apr 20, 2026
cdefdd0
Fix a metadata table name.
nnethercote Apr 22, 2026
3b5dd18
Fix some comments.
nnethercote Apr 24, 2026
3c83d3a
llvm: Use correct type for splat mask
maurer May 5, 2026
411a932
ImproperCTypes: merge outer_ty information into VisitorState
niacdoial Sep 10, 2025
6839797
ImproperCTypes: Use more `Unnormalized` type wrappers
niacdoial Apr 24, 2026
803c7ba
Some fold/visit tweaks.
nnethercote Apr 24, 2026
814fc17
Deny warnings in rustc crates on stable
jdonszelmann Apr 29, 2026
0afe083
Avoid some global `node_id_to_def_id` lookups in import resolution
oli-obk May 5, 2026
191cda5
Avoid using `id` followed by `local_def_id` if we can just call `def_…
oli-obk May 5, 2026
400240a
Avoid hitting the global node_id_to_def_id table for unused macros
oli-obk May 5, 2026
a082567
Follow-up cleanups reusing the now-available `LocalDefId`s
oli-obk May 5, 2026
b8e547a
fix warnings in rustc_type_ir
jdonszelmann Apr 29, 2026
7ccd895
add passing test that should fail
lqd May 6, 2026
c44e922
Refactor dead code liveness plumbing
mu001999 Apr 6, 2026
325b013
prevent directives from having multiple revisions
lqd May 6, 2026
27a8bb6
Implement unused_pub_items_in_binary lint
mu001999 Apr 6, 2026
26bfcf3
Rename unused_pub_items_in_binary to dead_code_pub_in_binary
mu001999 Apr 28, 2026
ccd70c1
move coercion tests out of ui/issues into its folder
danieljofficial May 6, 2026
c5cf608
add issue links and bless
danieljofficial May 6, 2026
ff25d8a
Use special DefIds for aliases
ChayimFriedman2 Apr 9, 2026
aadf600
Document wasi-sdk minimum versions for WASI targets
alexcrichton May 6, 2026
4790f04
Rollup merge of #146273 - niacdoial:improperctypes-refactor2, r=petro…
jhpratt May 7, 2026
264c767
Rollup merge of #149509 - mu001999-contrib:flag/pub-as-pub-crate, r=j…
jhpratt May 7, 2026
a95afa6
Rollup merge of #156173 - oli-obk:fewer-global-lookups, r=petrochenkov
jhpratt May 7, 2026
7fadbe4
Rollup merge of #155961 - jdonszelmann:deny-warnings-stable, r=mejrs
jhpratt May 7, 2026
a4b9a18
Rollup merge of #155981 - ChayimFriedman2:alias-def-id, r=lcnr
jhpratt May 7, 2026
7aef47f
Rollup merge of #156130 - nnethercote:fold-visit-tweaks, r=WaffleLapkin
jhpratt May 7, 2026
966d962
Rollup merge of #156131 - nnethercote:rm-unnecessary-decode, r=Zalathar
jhpratt May 7, 2026
f9c0b1c
Rollup merge of #156202 - maurer:splat, r=nikic
jhpratt May 7, 2026
28f1bcb
Rollup merge of #156237 - lqd:compiletest-revisions, r=wesleywiser,ji…
jhpratt May 7, 2026
5992e0f
Rollup merge of #156241 - danieljofficial:move-tests-coercion, r=Kivooeo
jhpratt May 7, 2026
59f7031
Rollup merge of #156258 - alexcrichton:update-some-docs, r=jieyouxu
jhpratt May 7, 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
5 changes: 3 additions & 2 deletions compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2086,7 +2086,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
}

if name == sym::simd_splat {
let (_out_len, out_ty) = require_simd!(ret_ty, SimdReturn);
let (out_len, out_ty) = require_simd!(ret_ty, SimdReturn);

require!(
args[0].layout.ty == out_ty,
Expand All @@ -2105,7 +2105,8 @@ fn generic_simd_intrinsic<'ll, 'tcx>(

// `shufflevector <N x elem> v0, <N x elem> poison, <N x i32> zeroinitializer`
// The masks is all zeros, so this splats lane 0 (which has our element in it).
let splat = bx.shuffle_vector(v0, poison_vec, bx.const_null(llret_ty));
let mask_ty = bx.type_vector(bx.type_i32(), out_len);
let splat = bx.shuffle_vector(v0, poison_vec, bx.const_null(mask_ty));

return Ok(splat);
}
Expand Down
286 changes: 172 additions & 114 deletions compiler/rustc_lint/src/types/improper_ctypes.rs

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ declare_lint_pass! {
CONST_EVALUATABLE_UNCHECKED,
CONST_ITEM_MUTATION,
DEAD_CODE,
DEAD_CODE_PUB_IN_BINARY,
DEPENDENCY_ON_UNIT_NEVER_TYPE_FALLBACK,
DEPRECATED,
DEPRECATED_IN_FUTURE,
Expand Down Expand Up @@ -789,6 +790,37 @@ declare_lint! {
"detect unused, unexported items"
}

declare_lint! {
/// The `dead_code_pub_in_binary` lint detects unused `pub` items in
/// executable crates.
///
/// ### Example
///
/// ```rust
/// #![deny(dead_code_pub_in_binary)]
///
/// pub fn unused_pub_fn() {}
///
/// fn main() {}
/// ```
///
/// {{produces}}
///
/// ### Explanation
///
/// In executable crates, `pub` items are often implementation details
/// rather than part of an external API. This lint helps find those items
/// when they are never used.
///
/// This lint only applies to executable crates. In library crates, public
/// items are considered part of the crate's API and are not reported by
/// this lint.
pub DEAD_CODE_PUB_IN_BINARY,
Allow,
"detect public items in executable crates that are never used",
crate_level_only
}

declare_lint! {
/// The `unused_attributes` lint detects attributes that were not used by
/// the compiler.
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ provide! { tcx, def_id, other, cdata,
.coerce_unsized_info
.get(cdata, def_id.index)
.map(|lazy| lazy.decode((cdata, tcx)))
.process_decoded(tcx, || panic!("{def_id:?} does not have coerce_unsized_info"))) }
.process_decoded(tcx, || panic!("{def_id:?} does not have coerce_unsized_info")))
}
mir_const_qualif => { table }
rendered_const => { table }
rendered_precise_capturing_args => { table }
Expand Down Expand Up @@ -300,10 +301,10 @@ provide! { tcx, def_id, other, cdata,
Ok(cdata
.root
.tables
.trait_impl_trait_tys
.collect_return_position_impl_trait_in_trait_tys
.get(cdata, def_id.index)
.map(|lazy| lazy.decode((cdata, tcx)))
.process_decoded(tcx, || panic!("{def_id:?} does not have trait_impl_trait_tys")))
.process_decoded(tcx, || panic!("{def_id:?} does not have collect_return_position_impl_trait_in_trait_tys")))
}

associated_types_for_impl_traits_in_trait_or_impl => { table }
Expand Down Expand Up @@ -695,6 +696,7 @@ impl CrateStore for CStore {
fn as_any(&self) -> &dyn Any {
self
}

fn untracked_as_any(&mut self) -> &mut dyn Any {
self
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
if tcx.impl_method_has_trait_impl_trait_tys(def_id)
&& let Ok(table) = self.tcx.collect_return_position_impl_trait_in_trait_tys(def_id)
{
record!(self.tables.trait_impl_trait_tys[def_id] <- table);
record!(self.tables.collect_return_position_impl_trait_in_trait_tys[def_id] <- table);
}
if let DefKind::Impl { .. } | DefKind::Trait = def_kind {
let table = tcx.associated_types_for_impl_traits_in_trait_or_impl(def_id);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/src/rmeta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ define_tables! {
macro_definition: Table<DefIndex, LazyValue<ast::DelimArgs>>,
proc_macro: Table<DefIndex, MacroKind>,
deduced_param_attrs: Table<DefIndex, LazyArray<DeducedParamAttrs>>,
trait_impl_trait_tys: Table<DefIndex, LazyValue<DefIdMap<ty::EarlyBinder<'static, Ty<'static>>>>>,
collect_return_position_impl_trait_in_trait_tys: Table<DefIndex, LazyValue<DefIdMap<ty::EarlyBinder<'static, Ty<'static>>>>>,
doc_link_resolutions: Table<DefIndex, LazyValue<DocLinkResMap>>,
doc_link_traits_in_scope: Table<DefIndex, LazyArray<DefId>>,
assumed_wf_types_for_rpitit: Table<DefIndex, LazyArray<(Ty<'static>, Span)>>,
Expand Down
11 changes: 5 additions & 6 deletions compiler/rustc_middle/src/arena.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
/// This higher-order macro declares a list of types which can be allocated by `Arena`.
///
/// Specifying the `decode` modifier will add decode impls for `&T` and `&[T]` where `T` is the type
/// listed. These impls will appear in the implement_ty_decoder! macro.
/// listed. See the `impl_arena_allocatable_decoder!` macro for more.
#[macro_export]
macro_rules! arena_types {
($macro:path) => (
$macro!([
[] layout: rustc_abi::LayoutData<rustc_abi::FieldIdx, rustc_abi::VariantIdx>,
[] proxy_coroutine_layout: rustc_middle::mir::CoroutineLayout<'tcx>,
[] fn_abi: rustc_target::callconv::FnAbi<'tcx, rustc_middle::ty::Ty<'tcx>>,
// AdtDef are interned and compared by address
[decode] adt_def: rustc_middle::ty::AdtDefData,
[] adt_def: rustc_middle::ty::AdtDefData,
[] steal_thir: rustc_data_structures::steal::Steal<rustc_middle::thir::Thir<'tcx>>,
[] steal_mir: rustc_data_structures::steal::Steal<rustc_middle::mir::Body<'tcx>>,
[decode] mir: rustc_middle::mir::Body<'tcx>,
Expand All @@ -27,7 +26,7 @@ macro_rules! arena_types {
rustc_middle::mir::Body<'tcx>
>,
[decode] typeck_results: rustc_middle::ty::TypeckResults<'tcx>,
[decode] borrowck_result: rustc_data_structures::fx::FxIndexMap<
[] borrowck_result: rustc_data_structures::fx::FxIndexMap<
rustc_hir::def_id::LocalDefId,
rustc_middle::ty::DefinitionSiteHiddenType<'tcx>,
>,
Expand Down Expand Up @@ -100,7 +99,7 @@ macro_rules! arena_types {
// (during lowering) and the `rustc_middle` arena (for decoding MIR)
[decode] asm_template: rustc_ast::InlineAsmTemplatePiece,
[decode] used_trait_imports: rustc_data_structures::unord::UnordSet<rustc_hir::def_id::LocalDefId>,
[decode] is_late_bound_map: rustc_data_structures::fx::FxIndexSet<rustc_hir::ItemLocalId>,
[] is_late_bound_map: rustc_data_structures::fx::FxIndexSet<rustc_hir::ItemLocalId>,
[decode] impl_source: rustc_middle::traits::ImplSource<'tcx, ()>,

[] dep_kind_vtable: rustc_middle::dep_graph::DepKindVTable<'tcx>,
Expand All @@ -111,7 +110,7 @@ macro_rules! arena_types {
rustc_middle::ty::EarlyBinder<'tcx, rustc_middle::ty::Ty<'tcx>>
>,
[] external_constraints: rustc_middle::traits::solve::ExternalConstraintsData<rustc_middle::ty::TyCtxt<'tcx>>,
[decode] doc_link_resolutions: rustc_hir::def::DocLinkResMap,
[] doc_link_resolutions: rustc_hir::def::DocLinkResMap,
[] stripped_cfg_items: rustc_hir::attrs::StrippedCfgItem,
[] mod_child: rustc_middle::metadata::ModChild,
[] features: rustc_feature::Features,
Expand Down
23 changes: 23 additions & 0 deletions compiler/rustc_middle/src/middle/dead_code.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use rustc_data_structures::fx::FxIndexSet;
use rustc_hir::def_id::{DefId, LocalDefIdMap, LocalDefIdSet};
use rustc_macros::StableHash;

/// A single snapshot of dead-code liveness analysis state.
#[derive(Clone, Debug, StableHash)]
pub struct DeadCodeLivenessSnapshot {
pub live_symbols: LocalDefIdSet,
/// Maps each ADT to derived traits (for example `Debug` and `Clone`) that should be ignored
/// when checking for dead code diagnostics.
pub ignored_derived_traits: LocalDefIdMap<FxIndexSet<DefId>>,
}

/// Dead-code liveness data for both analysis phases.
///
/// `pre_deferred_seeding` is computed before reachable-public and `#[allow(dead_code)]` seeding,
/// and is used for lint `dead_code_pub_in_binary`.
/// `final_result` is the final liveness snapshot used for lint `dead_code`.
#[derive(Clone, Debug, StableHash)]
pub struct DeadCodeLivenessSummary {
pub pre_deferred_seeding: DeadCodeLivenessSnapshot,
pub final_result: DeadCodeLivenessSnapshot,
}
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/middle/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod codegen_fn_attrs;
pub mod dead_code;
pub mod debugger_visualizer;
pub mod deduced_param_attrs;
pub mod dependency_format;
Expand Down
14 changes: 4 additions & 10 deletions compiler/rustc_middle/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ use rustc_errors::{ErrorGuaranteed, catch_fatal_errors};
use rustc_hir as hir;
use rustc_hir::attrs::{EiiDecl, EiiImpl, StrippedCfgItem};
use rustc_hir::def::{DefKind, DocLinkResMap};
use rustc_hir::def_id::{
CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdMap, LocalDefIdSet, LocalModDefId,
};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdSet, LocalModDefId};
use rustc_hir::lang_items::{LangItem, LanguageItems};
use rustc_hir::{ItemLocalId, ItemLocalMap, PreciseCapturingArgKind, TraitCandidate};
use rustc_index::IndexVec;
Expand All @@ -87,6 +85,7 @@ use crate::infer::canonical::{self, Canonical};
use crate::lint::LintExpectation;
use crate::metadata::ModChild;
use crate::middle::codegen_fn_attrs::{CodegenFnAttrs, SanitizerFnAttrs};
use crate::middle::dead_code::DeadCodeLivenessSummary;
use crate::middle::debugger_visualizer::DebuggerVisualizerFile;
use crate::middle::deduced_param_attrs::DeducedParamAttrs;
use crate::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo};
Expand Down Expand Up @@ -1203,13 +1202,8 @@ rustc_queries! {
desc { "checking liveness of variables in `{}`", tcx.def_path_str(key.to_def_id()) }
}

/// Return the live symbols in the crate for dead code check.
///
/// The second return value maps from ADTs to ignored derived traits (e.g. Debug and Clone).
query live_symbols_and_ignored_derived_traits(_: ()) -> Result<&'tcx (
LocalDefIdSet,
LocalDefIdMap<FxIndexSet<DefId>>,
), ErrorGuaranteed> {
/// Return dead-code liveness summary for the crate.
query live_symbols_and_ignored_derived_traits(_: ()) -> Result<&'tcx DeadCodeLivenessSummary, ErrorGuaranteed> {
arena_cache
desc { "finding live symbols in crate" }
}
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_middle/src/ty/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,8 @@ macro_rules! __impl_decoder_methods {
}

macro_rules! impl_arena_allocatable_decoder {
([]$args:tt) => {};
([decode $(, $attrs:ident)*]
[$name:ident: $ty:ty]) => {
([] $name:ident: $ty:ty) => {};
([decode] $name:ident: $ty:ty) => {
impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for $ty {
#[inline]
fn decode(decoder: &mut D) -> &'tcx Self {
Expand All @@ -535,7 +534,7 @@ macro_rules! impl_arena_allocatable_decoder {
macro_rules! impl_arena_allocatable_decoders {
([$($a:tt $name:ident: $ty:ty,)*]) => {
$(
impl_arena_allocatable_decoder!($a [$name: $ty]);
impl_arena_allocatable_decoder!($a $name: $ty);
)*
}
}
Expand Down
37 changes: 29 additions & 8 deletions compiler/rustc_middle/src/ty/context/impl_interner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_hir::def::{CtorKind, CtorOf, DefKind};
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::lang_items::LangItem;
use rustc_span::{DUMMY_SP, Span, Symbol};
use rustc_type_ir::lang_items::{SolverAdtLangItem, SolverLangItem, SolverTraitLangItem};
use rustc_type_ir::lang_items::{SolverAdtLangItem, SolverProjectionLangItem, SolverTraitLangItem};
use rustc_type_ir::{CollectAndApply, Interner, TypeFoldable, Unnormalized, search_graph};

use crate::dep_graph::{DepKind, DepNodeIndex};
Expand Down Expand Up @@ -39,6 +39,20 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
type AdtId = DefId;
type ImplId = DefId;
type UnevaluatedConstId = DefId;
type TraitAssocTyId = DefId;
type TraitAssocConstId = DefId;
type TraitAssocTermId = DefId;
type OpaqueTyId = DefId;
type LocalOpaqueTyId = LocalDefId;
type FreeTyAliasId = DefId;
type FreeConstAliasId = DefId;
type FreeTermAliasId = DefId;
type ImplOrTraitAssocTyId = DefId;
type ImplOrTraitAssocConstId = DefId;
type ImplOrTraitAssocTermId = DefId;
type InherentAssocTyId = DefId;
type InherentAssocConstId = DefId;
type InherentAssocTermId = DefId;
type Span = Span;

type GenericArgs = ty::GenericArgsRef<'tcx>;
Expand Down Expand Up @@ -288,7 +302,15 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
self.mk_type_list_from_iter(args)
}

fn parent(self, def_id: DefId) -> DefId {
fn projection_parent(self, def_id: Self::TraitAssocTermId) -> Self::TraitId {
self.parent(def_id)
}

fn impl_or_trait_assoc_term_parent(self, def_id: Self::ImplOrTraitAssocTyId) -> DefId {
self.parent(def_id)
}

fn inherent_alias_term_parent(self, def_id: Self::InherentAssocTermId) -> Self::ImplId {
self.parent(def_id)
}

Expand Down Expand Up @@ -446,7 +468,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
!self.codegen_fn_attrs(def_id).target_features.is_empty()
}

fn require_lang_item(self, lang_item: SolverLangItem) -> DefId {
fn require_projection_lang_item(self, lang_item: SolverProjectionLangItem) -> DefId {
self.require_lang_item(solver_lang_item_to_lang_item(lang_item), DUMMY_SP)
}

Expand All @@ -458,7 +480,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
self.require_lang_item(solver_adt_lang_item_to_lang_item(lang_item), DUMMY_SP)
}

fn is_lang_item(self, def_id: DefId, lang_item: SolverLangItem) -> bool {
fn is_projection_lang_item(self, def_id: DefId, lang_item: SolverProjectionLangItem) -> bool {
self.is_lang_item(def_id, solver_lang_item_to_lang_item(lang_item))
}

Expand All @@ -478,7 +500,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
self.is_sizedness_trait(def_id)
}

fn as_lang_item(self, def_id: DefId) -> Option<SolverLangItem> {
fn as_projection_lang_item(self, def_id: DefId) -> Option<SolverProjectionLangItem> {
lang_item_to_solver_lang_item(self.lang_items().from_def_id(def_id)?)
}

Expand Down Expand Up @@ -757,7 +779,7 @@ macro_rules! bidirectional_lang_item_map {
}

bidirectional_lang_item_map! {
SolverLangItem, fn lang_item_to_solver_lang_item, fn solver_lang_item_to_lang_item;
SolverProjectionLangItem, fn lang_item_to_solver_lang_item, fn solver_lang_item_to_lang_item;

// tidy-alphabetical-start
AsyncFnKindUpvars,
Expand All @@ -766,7 +788,6 @@ bidirectional_lang_item_map! {
CallRefFuture,
CoroutineReturn,
CoroutineYield,
DynMetadata,
FieldBase,
FieldType,
FutureOutput,
Expand All @@ -778,6 +799,7 @@ bidirectional_lang_item_map! {
SolverAdtLangItem, fn lang_item_to_solver_adt_lang_item, fn solver_adt_lang_item_to_lang_item;

// tidy-alphabetical-start
DynMetadata,
Option,
Poll,
// tidy-alphabetical-end
Expand All @@ -791,7 +813,6 @@ bidirectional_lang_item_map! {
AsyncFnKindHelper,
AsyncFnMut,
AsyncFnOnce,
AsyncFnOnceOutput,
AsyncIterator,
BikeshedGuaranteedNoDrop,
Clone,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_next_trait_solver/src/delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub trait SolverDelegate: Deref<Target = Self::Infcx> + Sized {

fn add_item_bounds_for_hidden_type(
&self,
def_id: <Self::Interner as Interner>::DefId,
def_id: <Self::Interner as Interner>::OpaqueTyId,
args: <Self::Interner as Interner>::GenericArgs,
param_env: <Self::Interner as Interner>::ParamEnv,
hidden_ty: <Self::Interner as Interner>::Ty,
Expand All @@ -79,7 +79,7 @@ pub trait SolverDelegate: Deref<Target = Self::Infcx> + Sized {
fn fetch_eligible_assoc_item(
&self,
goal_trait_ref: ty::TraitRef<Self::Interner>,
trait_assoc_def_id: <Self::Interner as Interner>::DefId,
trait_assoc_def_id: <Self::Interner as Interner>::TraitAssocTermId,
impl_def_id: <Self::Interner as Interner>::ImplId,
) -> FetchEligibleAssocItemResponse<Self::Interner>;

Expand Down
Loading
Loading