Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 5 pull requests #130519

Merged
merged 20 commits into from
Sep 18, 2024
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
6daf40e
Use trait aliases to shorten some code.
nnethercote Sep 16, 2024
47830ed
Adjust supertrait of `ArgAbiMethods`.
nnethercote Sep 16, 2024
5f98943
Merge `HasCodegen` into `BuilderMethods`.
nnethercote Sep 16, 2024
928d8e6
Remove `Backend`.
nnethercote Sep 16, 2024
6a35b5c
Remove `BackendTypes` constraint from traits that don't need it.
nnethercote Sep 16, 2024
410a2de
Rename `{ArgAbi,IntrinsicCall}Methods`.
nnethercote Sep 16, 2024
108f8c8
Remove unneeded bounds from `CodegenMethods` and `BuilderMethods`.
nnethercote Sep 16, 2024
85a4d2a
Tweak and explain the `BuilderMethods`/`CodegenMethods` connection.
nnethercote Sep 16, 2024
540fcc6
Move some supertraits outward.
nnethercote Sep 16, 2024
a8d22eb
Rename supertraits of `CodegenMethods`.
nnethercote Sep 17, 2024
acb832d
Use associative type defaults in `{Layout,FnAbi}OfHelpers`.
nnethercote Sep 16, 2024
930db09
Add zlib to musl dist image so rust-lld will support zlib compression…
khuey Sep 17, 2024
89f04c2
Improve handling of raw-idents in check-cfg
Urgau Sep 18, 2024
3a35288
llvm-wrapper: adapt for LLVM API changes, second try
krasimirgg Sep 18, 2024
a47e9b6
doc: the source of `LetStmt` can also be `AssignDesugar`
samueltardieu Sep 18, 2024
21313d7
Rollup merge of #130457 - nnethercote:cleanup-codegen-traits, r=bjorn3
matthiaskrgr Sep 18, 2024
3443795
Rollup merge of #130471 - khuey:zlib-musl, r=Kobzol
matthiaskrgr Sep 18, 2024
00c4be3
Rollup merge of #130507 - Urgau:check-cfg-raw-keywords, r=jieyouxu
matthiaskrgr Sep 18, 2024
48b90aa
Rollup merge of #130509 - krasimirgg:llvm-20-2, r=nikic
matthiaskrgr Sep 18, 2024
c0951bb
Rollup merge of #130510 - samueltardieu:doc-letstmt-assign-desugar, r…
matthiaskrgr Sep 18, 2024
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
Prev Previous commit
Next Next commit
Move some supertraits outward.
Specifically, put them where they are genuinely required, i.e. the
outermost place they can be.
  • Loading branch information
nnethercote committed Sep 17, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
kmbcook Kevin Cook
commit 540fcc617a7d0ab408e81e5668cfa3971233353d
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/mir/operand.rs
Original file line number Diff line number Diff line change
@@ -280,7 +280,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
///
/// If you don't need the type, see [`OperandValue::pointer_parts`]
/// or [`OperandValue::deref`].
pub fn deref<Cx: LayoutTypeMethods<'tcx>>(self, cx: &Cx) -> PlaceRef<'tcx, V> {
pub fn deref<Cx: CodegenMethods<'tcx>>(self, cx: &Cx) -> PlaceRef<'tcx, V> {
if self.layout.ty.is_box() {
// Derefer should have removed all Box derefs
bug!("dereferencing {:?} in codegen", self.layout.ty);
9 changes: 8 additions & 1 deletion compiler/rustc_codegen_ssa/src/traits/mod.rs
Original file line number Diff line number Diff line change
@@ -27,6 +27,11 @@ mod write;

use std::fmt;

use rustc_middle::ty::layout::FnAbiOf;
use rustc_middle::ty::Ty;
use rustc_target::abi::call::FnAbi;
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};

pub use self::abi::AbiBuilderMethods;
pub use self::asm::{AsmBuilderMethods, AsmMethods, GlobalAsmOperandRef, InlineAsmOperandRef};
pub use self::backend::{BackendTypes, CodegenBackend, ExtraBackendMethods};
@@ -46,7 +51,9 @@ pub use self::write::{ModuleBufferMethods, ThinBufferMethods, WriteBackendMethod

pub trait CodegenObject = Copy + PartialEq + fmt::Debug;

pub trait CodegenMethods<'tcx> = TypeMethods<'tcx>
pub trait CodegenMethods<'tcx> = LayoutOf<'tcx, LayoutOfResult = TyAndLayout<'tcx>>
+ FnAbiOf<'tcx, FnAbiOfResult = &'tcx FnAbi<'tcx, Ty<'tcx>>>
+ TypeMethods<'tcx>
+ ConstMethods<'tcx>
+ StaticMethods
+ DebugInfoMethods<'tcx>
19 changes: 10 additions & 9 deletions compiler/rustc_codegen_ssa/src/traits/type_.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rustc_middle::bug;
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf, TyAndLayout};
use rustc_middle::ty::layout::{HasTyCtxt, TyAndLayout};
use rustc_middle::ty::{self, Ty};
use rustc_target::abi::call::{ArgAbi, CastTarget, FnAbi, Reg};
use rustc_target::abi::{AddressSpace, Float, Integer};
@@ -9,7 +9,7 @@ use super::BackendTypes;
use crate::common::TypeKind;
use crate::mir::place::PlaceRef;

pub trait BaseTypeMethods<'tcx>: BackendTypes + HasTyCtxt<'tcx> {
pub trait BaseTypeMethods<'tcx>: BackendTypes {
fn type_i8(&self) -> Self::Type;
fn type_i16(&self) -> Self::Type;
fn type_i32(&self) -> Self::Type;
@@ -40,7 +40,9 @@ pub trait BaseTypeMethods<'tcx>: BackendTypes + HasTyCtxt<'tcx> {
fn val_ty(&self, v: Self::Value) -> Self::Type;
}

pub trait DerivedTypeMethods<'tcx>: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {
pub trait DerivedTypeMethods<'tcx>:
BaseTypeMethods<'tcx> + MiscMethods<'tcx> + HasTyCtxt<'tcx>
{
fn type_int(&self) -> Self::Type {
match &self.sess().target.c_int_width[..] {
"16" => self.type_i16(),
@@ -98,13 +100,12 @@ pub trait DerivedTypeMethods<'tcx>: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {
}
}

impl<'tcx, T> DerivedTypeMethods<'tcx> for T where Self: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {}

pub trait LayoutTypeMethods<'tcx>:
BackendTypes
+ LayoutOf<'tcx, LayoutOfResult = TyAndLayout<'tcx>>
+ FnAbiOf<'tcx, FnAbiOfResult = &'tcx FnAbi<'tcx, Ty<'tcx>>>
impl<'tcx, T> DerivedTypeMethods<'tcx> for T where
Self: BaseTypeMethods<'tcx> + MiscMethods<'tcx> + HasTyCtxt<'tcx>
{
}

pub trait LayoutTypeMethods<'tcx>: BackendTypes {
/// The backend type used for a rust type when it's in memory,
/// such as when it's stack-allocated or when it's being loaded or stored.
fn backend_type(&self, layout: TyAndLayout<'tcx>) -> Self::Type;