Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
63c15e4
test: cover current if let closure capture behavior
Embers-of-the-Fire Mar 22, 2026
923ef1f
fix: drop eager if let scrutinee borrow during capture analysis
Embers-of-the-Fire Mar 22, 2026
665416d
test(ui): add regression for if-let closure capture size
Embers-of-the-Fire Mar 22, 2026
2aadcee
feat: remove callback param for walk_local method
Embers-of-the-Fire Mar 22, 2026
1f81a55
test: add if let test for partial capture
Embers-of-the-Fire Apr 18, 2026
f491a6c
test(miri): add if-let closure capture UB smoke tests
Embers-of-the-Fire May 21, 2026
0e87c76
Adding diagnostic markers for multiple fs functions
asder8215 Aug 4, 2026
e6b20c8
diagnostics: unify foreign-trait label for ADT and primitive types in…
Omar1H1 Aug 8, 2026
b685be1
reflection: Add TypeId::variant() returning new Variant
yara-blue Aug 13, 2026
2b7d180
reflection: add non-exhaustive to meme::type_info::Variant
yara-blue Aug 13, 2026
74890b1
reflection: update tests to use methods on TypeId
yara-blue Aug 13, 2026
f5fc985
reflection: update FieldRepresentingType debug to use methods on TypeId
yara-blue Aug 13, 2026
37e1969
reflection: remove fields from TypeKind
yara-blue Aug 13, 2026
a123594
reflection: resolve false positive in unrelated ui-test
yara-blue Aug 14, 2026
6e0fdfb
reflection: resolve false positives in field-projection ui tests
yara-blue Aug 14, 2026
f6c1ef2
reflection: add FIXME about error messages for methods
yara-blue Aug 14, 2026
f3381d2
Allow `Subcommand::Fix` to have fields
Zalathar Aug 17, 2026
e9963a8
Allow `./x fix --allow-dirty`
Zalathar Aug 17, 2026
5898a39
Initial implementation of `FnPtr` trait
carbotaniuman Aug 18, 2026
8e8661e
std: use UNIX's `Instant` and `SystemTime` on Hermit
joboet Aug 18, 2026
0c0be1f
remove unused import on Hermit
joboet Aug 18, 2026
00d7802
remove rustc_error_messages dependency
mejrs Aug 18, 2026
951f07a
Rename test so it matches the issue
aerooneqq Aug 18, 2026
3bf4003
Require windowed (and exception) for Xtensa ABI
MabezDev Aug 6, 2026
8a446b5
Add Xtensa to the ABI flag consistency match
MabezDev Aug 17, 2026
d586e24
`allow(non_camel_case_types)` in `minicore.rs`
folkertdev Aug 18, 2026
fcc49d2
suppress projection errors already covered by a trait error
Albab-Hasan Aug 14, 2026
c67d6df
only suppress a projection error when its own trait goal fails
Albab-Hasan Aug 18, 2026
8408993
Enable overflow checks in `rustc_thread_pool`
aerooneqq Aug 18, 2026
9268e12
reflection: add a variant of TypeId::of without the static bound
yara-blue Aug 17, 2026
30a47c4
Relax codgen test variable regex
TimNN Aug 18, 2026
57d455b
Doc: clarify how `Read::bytes` handling Interrupted errors
xizheyin Aug 18, 2026
1724501
allocator: wording & grammar nitpicks
nia-e Aug 14, 2026
c132f36
okay max sure
nia-e Aug 18, 2026
2ee54ff
undo rc and arc thing
nia-e Aug 18, 2026
4f2bbfd
tighten send so bad rc can't be used
nia-e Aug 18, 2026
31d172e
this too
nia-e Aug 18, 2026
7d40fdb
there u go
nia-e Aug 18, 2026
b8f0e6a
Update books
rustbot Aug 18, 2026
5575007
Update rustbook `Cargo.lock`
traviscross Aug 18, 2026
0489275
[compiletest] Use the correct rustc lib directory for query_rustc_output
jnkel Aug 19, 2026
b1b8729
Rollup merge of #154210 - Embers-of-the-Fire:feat/if-let-no-full-capt…
jhpratt Aug 19, 2026
30bd758
Rollup merge of #156176 - carbotaniuman:fn-ptr-trait-impl, r=jackh726
jhpratt Aug 19, 2026
bab437e
Rollup merge of #160767 - Omar1H1:diagnostics/e0117-label-fix, r=petr…
jhpratt Aug 19, 2026
ab04ce1
Rollup merge of #161297 - joboet:hermit_time_reuse, r=nia-e
jhpratt Aug 19, 2026
349a828
Rollup merge of #160489 - asder8215:fs_diagnostic_items, r=mejrs
jhpratt Aug 19, 2026
67029c6
Rollup merge of #160643 - esp-rs:xtensa-abi-require-windowed, r=RalfJung
jhpratt Aug 19, 2026
85a6e9c
Rollup merge of #161088 - Albab-Hasan:suppress-duplicate-closure-outp…
jhpratt Aug 19, 2026
6ff2141
Rollup merge of #161114 - yara-blue:remove-typekind-fields, r=oli-obk
jhpratt Aug 19, 2026
63f0cfc
Rollup merge of #161115 - nia-e:allocator-nitpicks, r=clarfonthey
jhpratt Aug 19, 2026
bde51bc
Rollup merge of #161220 - Zalathar:allow-dirty, r=Kobzol
jhpratt Aug 19, 2026
9fb1320
Rollup merge of #161296 - aerooneqq:try-enable-overflow-checks, r=pet…
jhpratt Aug 19, 2026
a07b2bb
Rollup merge of #161298 - mejrs:error_messages, r=lqd
jhpratt Aug 19, 2026
ddf5816
Rollup merge of #161304 - aerooneqq:rename-test, r=lqd
jhpratt Aug 19, 2026
d388a35
Rollup merge of #161309 - folkertdev:minicore-allow-non-camel-case, r…
jhpratt Aug 19, 2026
0a5f92f
Rollup merge of #161315 - TimNN:relax-regex, r=durin42
jhpratt Aug 19, 2026
5072c02
Rollup merge of #161318 - xizheyin:161288, r=nia-e
jhpratt Aug 19, 2026
ed3c495
Rollup merge of #161321 - rustbot:docs-update, r=traviscross
jhpratt Aug 19, 2026
2f3f287
Rollup merge of #161335 - jnkel:fix-query-compiler-libs, r=jieyouxu
jhpratt Aug 19, 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
1 change: 0 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4385,7 +4385,6 @@ dependencies = [
"rustc_ast_ir",
"rustc_crate_store",
"rustc_data_structures",
"rustc_error_messages",
"rustc_errors",
"rustc_feature",
"rustc_graphviz",
Expand Down
7 changes: 0 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,6 @@ exclude = [
"obj",
]

[profile.release.package.rustc_thread_pool]
# The rustc fork of Rayon has deadlock detection code which intermittently
# causes overflows in the CI (see https://github.com/rust-lang/rust/issues/90227)
# so we turn overflow checks off for now.
# FIXME: This workaround should be removed once #90227 is fixed.
overflow-checks = false

# These are very thin wrappers around executing lld with the right binary name.
# Basically nothing within them can go wrong without having been explicitly logged anyway.
# We ship these in every rustc tarball and even after compression they add up
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_attr_ir/src/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,15 @@ language_item_table! {
Metadata, sym::metadata_type, metadata_type, Target::AssocTy, GenericRequirement::None;
DynMetadata, sym::dyn_metadata, dyn_metadata, Target::Struct, GenericRequirement::None;

NonNull, sym::non_null, non_null_trait, Target::Struct, GenericRequirement::Exact(1);

Freeze, sym::freeze, freeze_trait, Target::Trait, GenericRequirement::Exact(0);
UnsafeUnpin, sym::unsafe_unpin, unsafe_unpin_trait, Target::Trait, GenericRequirement::Exact(0);

FnPtrTrait, sym::fn_ptr_trait, fn_ptr_trait, Target::Trait, GenericRequirement::Exact(0);
FnPtrAddr, sym::fn_ptr_addr, fn_ptr_addr, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None;
FnPtrAsPtr, sym::fn_ptr_as_ptr, fn_ptr_as_ptr, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None;
FnPtrFromPtr, sym::fn_ptr_from_ptr, fn_ptr_from_ptr, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None;
Code, sym::code, code, Target::ForeignTy, GenericRequirement::None;

Drop, sym::drop, drop_trait, Target::Trait, GenericRequirement::None;
Destruct, sym::destruct, destruct_trait, Target::Trait, GenericRequirement::None;
Expand Down Expand Up @@ -245,6 +249,7 @@ language_item_table! {
Fn, kw::Fn, fn_trait, Target::Trait, GenericRequirement::Exact(1);
FnMut, sym::fn_mut, fn_mut_trait, Target::Trait, GenericRequirement::Exact(1);
FnOnce, sym::fn_once, fn_once_trait, Target::Trait, GenericRequirement::Exact(1);
FnStatic, sym::fn_static, fn_static_trait, Target::Trait, GenericRequirement::Exact(1);

AsyncFn, sym::async_fn, async_fn_trait, Target::Trait, GenericRequirement::Exact(1);
AsyncFnMut, sym::async_fn_mut, async_fn_mut_trait, Target::Trait, GenericRequirement::Exact(1);
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,9 @@ impl SingleAttributeParser for LangParser {
return None;
};

// Only weak lang items may be applied to foreign items
if [Target::ForeignFn, Target::ForeignStatic, Target::ForeignTy, Target::ForeignMod]
.contains(&cx.target)
// Only weak lang items may be applied to foreign items,
// except for `ForeignTy` which can be a normal lang item.
if [Target::ForeignFn, Target::ForeignStatic, Target::ForeignMod].contains(&cx.target)
&& !lang_item.is_weak()
{
cx.emit_err(UnknownExternLangItem { span: cx.attr_span, lang_item: lang_item.name() });
Expand Down
45 changes: 45 additions & 0 deletions compiler/rustc_const_eval/src/const_eval/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,51 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
ecx.write_scalar(Scalar::from_target_usize(variants_num as u64, ecx), dest)?;
}

sym::variant_name => {
let base = ecx.read_type_id(&args[0])?;

let field_name = if let ty::Adt(def, _) = base.kind() {
let variant_idx = ecx.read_target_usize(&args[1])? as usize;
if variant_idx >= def.variants().len() {
throw_ub!(BoundsCheckFailed {
len: def.variants().len() as u64,
index: variant_idx as u64
});
}
let variant_idx = VariantIdx::from_usize(variant_idx);
def.variant(variant_idx).name
} else {
span_bug!(ecx.cur_span(), "expected enum type, got {base}")
};
let ptr = ecx.allocate_bytes_dedup(field_name.as_str().as_bytes())?;
ecx.write_immediate(
Immediate::ScalarPair(
Scalar::from_pointer(ptr, ecx),
Scalar::from_target_usize(field_name.as_str().len() as u64, ecx),
),
dest,
)?;
}

sym::variant_non_exhaustive => {
let base = ecx.read_type_id(&args[0])?;

let non_exhaustive = if let ty::Adt(def, _) = base.kind() {
let variant_idx = ecx.read_target_usize(&args[1])? as usize;
if variant_idx >= def.variants().len() {
throw_ub!(BoundsCheckFailed {
len: def.variants().len() as u64,
index: variant_idx as u64
});
}
let variant_idx = VariantIdx::from_usize(variant_idx);
def.variant(variant_idx).is_field_list_non_exhaustive()
} else {
span_bug!(ecx.cur_span(), "expected enum type, got {base}")
};
ecx.write_scalar(Scalar::from_bool(non_exhaustive), dest)?;
}

sym::field_offset => {
let frt_ty = instance.args.type_at(0);
ensure_monomorphic_enough(frt_ty)?;
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_const_eval/src/interpret/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
| ty::InstanceKind::Shim(ty::ShimKind::FnPtr(..))
| ty::InstanceKind::Shim(ty::ShimKind::DropGlue(..))
| ty::InstanceKind::Shim(ty::ShimKind::Clone(..))
| ty::InstanceKind::Shim(ty::ShimKind::FnPtrAddr(..))
| ty::InstanceKind::Shim(ty::ShimKind::FnPtrAsPtr(..))
| ty::InstanceKind::Shim(ty::ShimKind::FnPtrFromPtr(..))
| ty::InstanceKind::Shim(ty::ShimKind::ThreadLocal(..))
| ty::InstanceKind::Shim(ty::ShimKind::AsyncDropGlueCtor(..))
| ty::InstanceKind::Shim(ty::ShimKind::AsyncDropGlue(..))
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,8 @@ declare_features! (
(unstable, fn_align, "1.53.0", Some(82232)),
/// Support delegating implementation of functions to other already implemented functions.
(incomplete, fn_delegation, "1.76.0", Some(118212)),
/// Traits for function pointers and items
(unstable, fn_static, "CURRENT_RUSTC_VERSION", Some(148768)),
/// Allows impls for the Freeze trait.
(internal, freeze_impls, "1.78.0", Some(121675)),
/// Frontmatter `---` blocks for use by external tools.
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_hir_analysis/src/check/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -> hi
| sym::ub_checks
| sym::va_copy
| sym::variant_count
| sym::variant_name
| sym::variant_non_exhaustive
| sym::wrapping_add
| sym::wrapping_mul
| sym::wrapping_sub
Expand Down Expand Up @@ -335,6 +337,8 @@ pub(crate) fn check_intrinsic_type(
sym::type_id_fields => (0, 0, vec![type_id_ty(), tcx.types.usize], tcx.types.usize),
sym::type_id_is_signed => (0, 0, vec![type_id_ty()], tcx.types.bool),
sym::type_id_variants => (0, 0, vec![type_id_ty()], tcx.types.usize),
sym::variant_name => (0, 0, vec![type_id_ty(), tcx.types.usize], Ty::new_static_str(tcx)),
sym::variant_non_exhaustive => (0, 0, vec![type_id_ty(), tcx.types.usize], tcx.types.bool),
sym::type_id_vtable => {
let dyn_metadata = tcx.require_lang_item(LangItem::DynMetadata, span);
let dyn_metadata_adt_ref = tcx.adt_def(dyn_metadata);
Expand Down
24 changes: 16 additions & 8 deletions compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1800,14 +1800,22 @@ fn check_method_receiver<'tcx>(
{
match receiver_validity_err {
ReceiverValidityError::DoesNotDeref if arbitrary_self_types_level.is_some() => {
let hint = match receiver_ty
.builtin_deref(false)
.unwrap_or(receiver_ty)
.ty_adt_def()
.and_then(|adt_def| tcx.get_diagnostic_name(adt_def.did()))
{
Some(sym::RcWeak | sym::ArcWeak) => Some(InvalidReceiverTyHint::Weak),
Some(sym::NonNull) => Some(InvalidReceiverTyHint::NonNull),
let adt_def =
receiver_ty.builtin_deref(false).unwrap_or(receiver_ty).ty_adt_def();

let hint = match adt_def {
Some(adt) => {
if tcx.is_lang_item(adt.did(), LangItem::NonNull) {
Some(InvalidReceiverTyHint::NonNull)
} else {
match tcx.get_diagnostic_name(adt.did()) {
Some(sym::RcWeak | sym::ArcWeak) => {
Some(InvalidReceiverTyHint::Weak)
}
_ => None,
}
}
}
_ => None,
};

Expand Down
18 changes: 13 additions & 5 deletions compiler/rustc_hir_analysis/src/coherence/orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,21 @@ fn emit_orphan_check_error<'tcx>(
});
}
ty::Adt(adt_def, _) => {
diag.subdiagnostic(diagnostics::OnlyCurrentTraitsAdt {
span,
name: tcx.def_path_str(adt_def.did()),
});
if is_foreign {
diag.subdiagnostic(diagnostics::OnlyCurrentTraitsForeign { span });
} else {
diag.subdiagnostic(diagnostics::OnlyCurrentTraitsAdt {
span,
name: tcx.def_path_str(adt_def.did()),
});
}
}
_ => {
diag.subdiagnostic(diagnostics::OnlyCurrentTraitsTy { span, ty });
if is_foreign {
diag.subdiagnostic(diagnostics::OnlyCurrentTraitsForeign { span });
} else {
diag.subdiagnostic(diagnostics::OnlyCurrentTraitsTy { span, ty });
}
}
}
}
Expand Down
13 changes: 4 additions & 9 deletions compiler/rustc_hir_typeck/src/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
}

hir::ExprKind::Let(hir::LetExpr { pat, init, .. }) => {
self.walk_local(init, pat, None, || self.borrow_expr(init, BorrowKind::Immutable))?;
self.walk_local(init, pat, None)?;
}

hir::ExprKind::Match(discr, arms, _) => {
Expand Down Expand Up @@ -577,7 +577,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
fn walk_stmt(&self, stmt: &hir::Stmt<'_>) -> Result<(), Cx::Error> {
match stmt.kind {
hir::StmtKind::Let(hir::LetStmt { pat, init: Some(expr), els, .. }) => {
self.walk_local(expr, pat, *els, || Ok(()))?;
self.walk_local(expr, pat, *els)?;
}

hir::StmtKind::Let(_) => {}
Expand Down Expand Up @@ -617,19 +617,14 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
Ok(())
}

fn walk_local<F>(
fn walk_local(
&self,
expr: &hir::Expr<'_>,
pat: &hir::Pat<'_>,
els: Option<&hir::Block<'_>>,
mut f: F,
) -> Result<(), Cx::Error>
where
F: FnMut() -> Result<(), Cx::Error>,
{
) -> Result<(), Cx::Error> {
self.walk_expr(expr)?;
let expr_place = self.cat_expr(expr)?;
f()?;
self.fake_read_scrutinee(&expr_place, els.is_some())?;
self.walk_pat(&expr_place, pat, false)?;
if let Some(els) = els {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ fn lint_wide_pointer<'tcx>(
let mut modifiers = String::new();
ty = match ty.kind() {
ty::RawPtr(ty, _) => *ty,
ty::Adt(def, args) if cx.tcx.is_diagnostic_item(sym::NonNull, def.did()) => {
ty::Adt(def, args) if cx.tcx.is_lang_item(def.did(), LangItem::NonNull) => {
modifiers.push_str(".as_ptr()");
args.type_at(0)
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_middle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ rustc_ast = { path = "../rustc_ast" }
rustc_ast_ir = { path = "../rustc_ast_ir" }
rustc_crate_store = { path = "../rustc_crate_store" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_error_messages = { path = "../rustc_error_messages" } # Used for intra-doc links
rustc_errors = { path = "../rustc_errors" }
rustc_feature = { path = "../rustc_feature" }
rustc_graphviz = { path = "../rustc_graphviz" }
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_middle/src/mir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,8 @@ macro_rules! make_mir_visitor {
ty::InstanceKind::Shim(ty::ShimKind::FnPtr(_def_id, ty))
| ty::InstanceKind::Shim(ty::ShimKind::DropGlue(_def_id, Some(ty)))
| ty::InstanceKind::Shim(ty::ShimKind::Clone(_def_id, ty))
| ty::InstanceKind::Shim(ty::ShimKind::FnPtrAddr(_def_id, ty))
| ty::InstanceKind::Shim(ty::ShimKind::FnPtrAsPtr(_def_id, ty))
| ty::InstanceKind::Shim(ty::ShimKind::FnPtrFromPtr(_def_id, ty))
| ty::InstanceKind::Shim(ty::ShimKind::AsyncDropGlue(_def_id, ty))
| ty::InstanceKind::Shim(ty::ShimKind::AsyncDropGlueCtor(_def_id, ty)) => {
// FIXME(eddyb) use a better `TyContext` here.
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_middle/src/mono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,8 @@ impl<'tcx> CodegenUnit<'tcx> {
| InstanceKind::Shim(ShimKind::DropGlue(..))
| InstanceKind::Shim(ShimKind::Clone(..))
| InstanceKind::Shim(ShimKind::ThreadLocal(..))
| InstanceKind::Shim(ShimKind::FnPtrAddr(..))
| InstanceKind::Shim(ShimKind::FnPtrAsPtr(..))
| InstanceKind::Shim(ShimKind::FnPtrFromPtr(..))
| InstanceKind::Shim(ShimKind::AsyncDropGlue(..))
| InstanceKind::Shim(ShimKind::FutureDropPoll(..))
| InstanceKind::Shim(ShimKind::AsyncDropGlueCtor(..)) => None,
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/ty/consts.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::borrow::Cow;

use rustc_data_structures::intern::Interned;
use rustc_error_messages::MultiSpan;
use rustc_macros::StableHash;
use rustc_span::Span;
use rustc_type_ir::walk::TypeWalker;
use rustc_type_ir::{self as ir, TypeFlags, WithCachedTypeInfo};

Expand Down Expand Up @@ -142,9 +142,9 @@ impl<'tcx> Const<'tcx> {

/// Like [Ty::new_error_with_message] but for constants.
#[track_caller]
pub fn new_error_with_message<S: Into<MultiSpan>>(
pub fn new_error_with_message(
tcx: TyCtxt<'tcx>,
span: S,
span: Span,
msg: impl Into<Cow<'static, str>>,
) -> Const<'tcx> {
let reported = tcx.dcx().span_delayed_bug(span, msg);
Expand Down
22 changes: 16 additions & 6 deletions compiler/rustc_middle/src/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,19 @@ pub enum ShimKind<'tcx> {
/// The `DefId` is for `Clone::clone`, the `Ty` is the type `T` with the builtin `Clone` impl.
Clone(DefId, Ty<'tcx>),

/// Compiler-generated `<T as FnPtr>::addr` implementation.
/// Compiler-generated `<T as FnPtr>::as_ptr` implementation.
///
/// Automatically generated for all potentially higher-ranked `fn(I) -> R` types.
///
/// The `DefId` is for `FnPtr::addr`, the `Ty` is the type `T`.
FnPtrAddr(DefId, Ty<'tcx>),
/// The `DefId` is for `FnPtr::as_ptr`, the `Ty` is the type `T`.
FnPtrAsPtr(DefId, Ty<'tcx>),

/// Compiler-generated `<T as FnPtr>::from_ptr` implementation.
///
/// Automatically generated for all potentially higher-ranked `fn(I) -> R` types.
///
/// The `DefId` is for `FnPtr::from_ptr`, the `Ty` is the type `T`.
FnPtrFromPtr(DefId, Ty<'tcx>),

/// `core::future::async_drop::async_drop_in_place::<'_, T>`.
///
Expand Down Expand Up @@ -344,7 +351,8 @@ impl<'tcx> ShimKind<'tcx> {
}
| ShimKind::DropGlue(def_id, _)
| ShimKind::Clone(def_id, _)
| ShimKind::FnPtrAddr(def_id, _)
| ShimKind::FnPtrAsPtr(def_id, _)
| ShimKind::FnPtrFromPtr(def_id, _)
| ShimKind::FutureDropPoll(def_id, _, _)
| ShimKind::AsyncDropGlue(def_id, _)
| ShimKind::AsyncDropGlueCtor(def_id, _) => def_id,
Expand All @@ -366,7 +374,8 @@ impl<'tcx> ShimKind<'tcx> {
| ShimKind::ConstructCoroutineInClosure { .. }
| ShimKind::DropGlue(..)
| ShimKind::Clone(..)
| ShimKind::FnPtrAddr(..) => None,
| ShimKind::FnPtrAsPtr(..)
| ShimKind::FnPtrFromPtr(..) => None,
}
}

Expand All @@ -385,8 +394,9 @@ impl<'tcx> ShimKind<'tcx> {
match *self {
ShimKind::Clone(..)
| ShimKind::ThreadLocal(..)
| ShimKind::FnPtrAddr(..)
| ShimKind::FnPtr(..)
| ShimKind::FnPtrAsPtr(..)
| ShimKind::FnPtrFromPtr(..)
| ShimKind::DropGlue(_, Some(_))
| ShimKind::FutureDropPoll(..)
| ShimKind::AsyncDropGlue(_, _) => false,
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_middle/src/ty/print/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,8 @@ impl<'tcx, P: Printer<'tcx> + std::fmt::Write> Print<P> for ty::ShimKind<'tcx> {
ty::ShimKind::DropGlue(_, None) => cx.write_str("shim(None)"),
ty::ShimKind::DropGlue(_, Some(ty)) => cx.write_str(&format!("shim(Some({ty}))")),
ty::ShimKind::Clone(_, ty) => cx.write_str(&format!("shim({ty})")),
ty::ShimKind::FnPtrAddr(_, ty) => cx.write_str(&format!("shim({ty})")),
ty::ShimKind::FnPtrAsPtr(_, ty) => cx.write_str(&format!("shim({ty})")),
ty::ShimKind::FnPtrFromPtr(_, ty) => cx.write_str(&format!("shim({ty})")),
ty::ShimKind::FutureDropPoll(_, proxy_ty, impl_ty) => {
cx.write_str(&format!("dropshim({proxy_ty}-{impl_ty})"))
}
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_mir_transform/src/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,8 @@ fn check_mir_is_available<'tcx, I: Inliner<'tcx>>(
| InstanceKind::Shim(ShimKind::DropGlue(..))
| InstanceKind::Shim(ShimKind::Clone(..))
| InstanceKind::Shim(ShimKind::ThreadLocal(..))
| InstanceKind::Shim(ShimKind::FnPtrAddr(..)) => return Ok(()),
| InstanceKind::Shim(ShimKind::FnPtrAsPtr(..))
| InstanceKind::Shim(ShimKind::FnPtrFromPtr(..)) => return Ok(()),
}

if inliner.tcx().is_constructor(callee_def_id) {
Expand Down
Loading
Loading