Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
297 changes: 47 additions & 250 deletions Cargo.lock

Large diffs are not rendered by default.

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
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_gcc/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ dependencies = [

[[package]]
name = "object"
version = "0.37.1"
version = "0.39.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03fd943161069e1768b4b3d050890ba48730e590f57e56d4aa04e7e090e61b4a"
checksum = "2e5a6c098c7a3b6547378093f5cc30bc54fd361ce711e05293a5cc589562739b"
dependencies = [
"memchr",
]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ master = ["gccjit/master"]
default = ["master"]

[dependencies]
object = { version = "0.37.0", default-features = false, features = ["std", "read"] }
object = { version = "0.39.0", default-features = false, features = ["std", "read"] }
tempfile = "3.20"
gccjit = { version = "3.3.0", features = ["dlopen"] }
#gccjit = { git = "https://github.com/rust-lang/gccjit.rs", branch = "error-dlopen", features = ["dlopen"] }
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_llvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ test = false
bitflags = "2.4.1"
# To avoid duplicate dependencies, this should match the version of gimli used
# by `rustc_codegen_ssa` via its `thorin-dwp` dependency.
gimli = "0.33"
gimli = "0.34"
itertools = "0.15"
libc = "0.2"
libloading = { version = "0.9.0" }
measureme = "12.0.1"
object = { version = "0.38.1", default-features = false, features = ["std", "read"] }
object = { version = "0.39.1", default-features = false, features = ["std", "read"] }
rustc-demangle = "0.1.28"
rustc_abi = { path = "../rustc_abi" }
rustc_ast = { path = "../rustc_ast" }
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_ssa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ rustc_trait_selection = { path = "../rustc_trait_selection" }
serde_json = "1.0.59"
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
tempfile = "3.2"
thorin-dwp = "0.10"
thorin-dwp = "0.11"
tracing = "0.1"
wasm-encoder = "0.219"
wasm-encoder = "0.247"
# tidy-alphabetical-end

[target.'cfg(unix)'.dependencies]
Expand All @@ -49,7 +49,7 @@ libc = "0.2.50"
# tidy-alphabetical-end

[dependencies.object]
version = "0.38.1"
version = "0.39.1"
default-features = false
features = ["read_core", "elf", "macho", "pe", "xcoff", "unaligned", "archive", "write", "wasm"]

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,13 +477,13 @@ fn create_elf_raw_dylib_stub(sess: &Session, soname: &str, symbols: &[DllImport]
// the DT_SONAME will be used by the linker to populate DT_NEEDED
// which the loader uses to find the library.
stub.write_align_dynamic();
stub.write_dynamic_string(elf::DT_SONAME, soname);
stub.write_dynamic_string(elf::DT_SONAME, soname).unwrap();
// LSB section "2.7. Symbol Versioning" requires `DT_VERDEFNUM` to be reliable.
if verdef_count > 1 {
stub.write_dynamic(elf::DT_VERDEFNUM, verdef_count as u64);
stub.write_dynamic(elf::DT_VERDEFNUM, verdef_count as u64).unwrap();
}
// DT_NULL terminates the .dynamic table.
stub.write_dynamic(elf::DT_NULL, 0);
stub.write_dynamic(elf::DT_NULL, 0).unwrap();

stub_buf
}
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
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
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
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2024"
[dependencies]
# tidy-alphabetical-start
bitflags = "2.4.1"
libloading = "0.8.0"
libloading = "0.9.0"
odht = { version = "0.3.1", features = ["nightly"] }
rustc_abi = { path = "../rustc_abi" }
rustc_ast = { path = "../rustc_ast" }
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/src/host_dylib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn attempt_load_dylib(path: &Path) -> Result<libloading::Library, libloading::Er
.map(|lib| lib.into());
}

unsafe { libloading::Library::new(&path) }
unsafe { libloading::Library::new(path) }
}

// On Windows the compiler would sometimes intermittently fail to open the
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
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
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/inline/cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn should_recurse<'tcx>(tcx: TyCtxt<'tcx>, callee: ty::Instance<'tcx>) -> bool {
| InstanceKind::Shim(ShimKind::Clone(..)) => {}

// This shim does not call any other functions, thus there can be no recursion.
InstanceKind::Shim(ShimKind::FnPtrAddr(..)) => return false,
InstanceKind::Shim(ShimKind::FnPtrAsPtr(..) | ShimKind::FnPtrFromPtr(..)) => return false,

// FIXME: A not fully instantiated drop shim can cause ICEs if one attempts to
// have its MIR built. Likely oli-obk just screwed up the `ParamEnv`s, so this
Expand Down
Loading
Loading