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 10 pull requests #121998

Merged
merged 28 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d0873c7
constify a couple thread_local statics
matthiaskrgr Feb 12, 2024
e478111
Improve assert_matches! documentation
Voultapher Feb 28, 2024
d2495fa
Drop link to matches macro and link matches macro to assert_matches.
Voultapher Feb 29, 2024
d6438f5
Apply review comments
Voultapher Mar 2, 2024
fb2b918
Small enhancement to description of From trait
jonaspleyer Mar 3, 2024
c45f0a9
Apply suggestions from code review
Voultapher Mar 3, 2024
aa38c26
Tweak `parse_asm_args`.
nnethercote Dec 20, 2023
3996447
Remove `file_path_mapping` param from `ParseSess::new`.
nnethercote Mar 4, 2024
0d4ebe1
Move `sess` function and use it more.
nnethercote Mar 4, 2024
4260f7e
Rename a misnamed `Session` parameter.
nnethercote Mar 4, 2024
4146136
Extract an arguments struct for `Builder::then_else_break`
Zalathar Feb 27, 2024
9eb927e
Don't run test_get_os_named_thread on win7
roblabla Mar 4, 2024
e463060
include feedback from workingjubilee
jonaspleyer Mar 4, 2024
ede25ad
Fix LVI tests after making frame pointers easily enableable
raoulstrackx Feb 27, 2024
05e68fa
Fix comment in Atomic{Ptr,Bool}::as_ptr.
Lee-Janggun Mar 4, 2024
1eedca8
Allow a way to add constructors for rustc_type_ir types
compiler-errors Feb 27, 2024
748da32
Update platform-support.md with supported musl version
wesleywiser Mar 4, 2024
80d2bdb
Rename all `ParseSess` variables/fields/lifetimes as `psess`.
nnethercote Mar 4, 2024
706fe0b
Rollup merge of #120976 - matthiaskrgr:constify_TL_statics, r=lcnr
matthiaskrgr Mar 4, 2024
8886c31
Rollup merge of #121683 - fortanix:raoul/lvi_fixes, r=cuviper
matthiaskrgr Mar 4, 2024
e7bb224
Rollup merge of #121703 - compiler-errors:new, r=lcnr
matthiaskrgr Mar 4, 2024
008ab33
Rollup merge of #121732 - Voultapher:improve-assert_matches-documenta…
matthiaskrgr Mar 4, 2024
58a0f64
Rollup merge of #121928 - Zalathar:then-else-args, r=Nadrieril
matthiaskrgr Mar 4, 2024
9d81d4e
Rollup merge of #121939 - jonaspleyer:patch-typo-core-From-descr, r=w…
matthiaskrgr Mar 4, 2024
4944ab4
Rollup merge of #121968 - roblabla:fix-win7, r=jhpratt
matthiaskrgr Mar 4, 2024
13b9712
Rollup merge of #121969 - nnethercote:ParseSess-cleanups, r=wesleywiser
matthiaskrgr Mar 4, 2024
c83ca5b
Rollup merge of #121977 - Lee-Janggun:master, r=WaffleLapkin
matthiaskrgr Mar 4, 2024
5e13bc4
Rollup merge of #121994 - wesleywiser:update_musl_version_docs, r=ehuss
matthiaskrgr Mar 4, 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
13 changes: 13 additions & 0 deletions compiler/rustc_middle/src/ty/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,20 @@ impl<'tcx> Const<'tcx> {
let reported = tcx.dcx().span_delayed_bug(span, msg);
Const::new_error(tcx, reported, ty)
}
}

impl<'tcx> rustc_type_ir::new::Const<TyCtxt<'tcx>> for Const<'tcx> {
fn new_anon_bound(
tcx: TyCtxt<'tcx>,
debruijn: ty::DebruijnIndex,
var: ty::BoundVar,
ty: Ty<'tcx>,
) -> Self {
Const::new_bound(tcx, debruijn, var, ty)
}
}

impl<'tcx> Const<'tcx> {
/// Literals and const generic parameters are eagerly converted to a constant, everything else
/// becomes `Unevaluated`.
#[instrument(skip(tcx), level = "debug")]
Expand Down
21 changes: 0 additions & 21 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,27 +130,6 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
fn mk_canonical_var_infos(self, infos: &[ty::CanonicalVarInfo<Self>]) -> Self::CanonicalVars {
self.mk_canonical_var_infos(infos)
}

fn mk_bound_ty(self, debruijn: ty::DebruijnIndex, var: ty::BoundVar) -> Self::Ty {
Ty::new_bound(self, debruijn, ty::BoundTy { var, kind: ty::BoundTyKind::Anon })
}

fn mk_bound_region(self, debruijn: ty::DebruijnIndex, var: ty::BoundVar) -> Self::Region {
Region::new_bound(
self,
debruijn,
ty::BoundRegion { var, kind: ty::BoundRegionKind::BrAnon },
)
}

fn mk_bound_const(
self,
debruijn: ty::DebruijnIndex,
var: ty::BoundVar,
ty: Self::Ty,
) -> Self::Const {
Const::new_bound(self, debruijn, var, ty)
}
}

type InternedSet<'tcx, T> = ShardedHashMap<InternedInSet<'tcx, T>, ()>;
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_middle/src/ty/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ impl<'tcx> Region<'tcx> {
}
}

impl<'tcx> rustc_type_ir::new::Region<TyCtxt<'tcx>> for Region<'tcx> {
fn new_anon_bound(tcx: TyCtxt<'tcx>, debruijn: ty::DebruijnIndex, var: ty::BoundVar) -> Self {
Region::new_bound(tcx, debruijn, ty::BoundRegion { var, kind: ty::BoundRegionKind::BrAnon })
}
}

/// Region utilities
impl<'tcx> Region<'tcx> {
pub fn kind(self) -> RegionKind<'tcx> {
Expand Down
9 changes: 8 additions & 1 deletion compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1426,7 +1426,8 @@ impl From<BoundVar> for BoundTy {

/// Constructors for `Ty`
impl<'tcx> Ty<'tcx> {
// Avoid this in favour of more specific `new_*` methods, where possible.
/// Avoid using this in favour of more specific `new_*` methods, where possible.
/// The more specific methods will often optimize their creation.
#[allow(rustc::usage_of_ty_tykind)]
#[inline]
pub fn new(tcx: TyCtxt<'tcx>, st: TyKind<'tcx>) -> Ty<'tcx> {
Expand Down Expand Up @@ -1813,6 +1814,12 @@ impl<'tcx> Ty<'tcx> {
}
}

impl<'tcx> rustc_type_ir::new::Ty<TyCtxt<'tcx>> for Ty<'tcx> {
fn new_anon_bound(tcx: TyCtxt<'tcx>, debruijn: ty::DebruijnIndex, var: ty::BoundVar) -> Self {
Ty::new_bound(tcx, debruijn, ty::BoundTy { var, kind: ty::BoundTyKind::Anon })
}
}

/// Type utilities
impl<'tcx> Ty<'tcx> {
#[inline(always)]
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_next_trait_solver/src/canonicalizer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::cmp::Ordering;

use rustc_type_ir::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
use rustc_type_ir::new::{Const, Region, Ty};
use rustc_type_ir::visit::TypeVisitableExt;
use rustc_type_ir::{
self as ty, Canonical, CanonicalTyVarKind, CanonicalVarInfo, CanonicalVarKind, ConstTy,
Expand Down Expand Up @@ -293,7 +294,7 @@ impl<Infcx: InferCtxtLike<Interner = I>, I: Interner> TypeFolder<I>
var
});

self.interner().mk_bound_region(self.binder_index, var)
Region::new_anon_bound(self.interner(), self.binder_index, var)
}

fn fold_ty(&mut self, t: I::Ty) -> I::Ty
Expand Down Expand Up @@ -375,7 +376,7 @@ impl<Infcx: InferCtxtLike<Interner = I>, I: Interner> TypeFolder<I>
}),
);

self.interner().mk_bound_ty(self.binder_index, var)
Ty::new_anon_bound(self.interner(), self.binder_index, var)
}

fn fold_const(&mut self, c: I::Const) -> I::Const
Expand Down Expand Up @@ -435,6 +436,6 @@ impl<Infcx: InferCtxtLike<Interner = I>, I: Interner> TypeFolder<I>
}),
);

self.interner().mk_bound_const(self.binder_index, var, c.ty())
Const::new_anon_bound(self.interner(), self.binder_index, var, c.ty())
}
}
18 changes: 8 additions & 10 deletions compiler/rustc_type_ir/src/interner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use std::hash::Hash;

use crate::visit::{Flags, TypeSuperVisitable, TypeVisitable};
use crate::{
BoundVar, BoundVars, CanonicalVarInfo, ConstKind, DebruijnIndex, DebugWithInfcx, RegionKind,
TyKind, UniverseIndex,
new, BoundVar, BoundVars, CanonicalVarInfo, ConstKind, DebugWithInfcx, RegionKind, TyKind,
UniverseIndex,
};

pub trait Interner: Sized {
Expand Down Expand Up @@ -34,7 +34,8 @@ pub trait Interner: Sized {
+ Into<Self::GenericArg>
+ IntoKind<Kind = TyKind<Self>>
+ TypeSuperVisitable<Self>
+ Flags;
+ Flags
+ new::Ty<Self>;
type Tys: Copy + Debug + Hash + Ord + IntoIterator<Item = Self::Ty>;
type AliasTy: Copy + DebugWithInfcx<Self> + Hash + Ord;
type ParamTy: Copy + Debug + Hash + Ord;
Expand All @@ -56,7 +57,8 @@ pub trait Interner: Sized {
+ IntoKind<Kind = ConstKind<Self>>
+ ConstTy<Self>
+ TypeSuperVisitable<Self>
+ Flags;
+ Flags
+ new::Const<Self>;
type AliasConst: Copy + DebugWithInfcx<Self> + Hash + Ord;
type PlaceholderConst: Copy + Debug + Hash + Ord + PlaceholderLike;
type ParamConst: Copy + Debug + Hash + Ord;
Expand All @@ -71,7 +73,8 @@ pub trait Interner: Sized {
+ Ord
+ Into<Self::GenericArg>
+ IntoKind<Kind = RegionKind<Self>>
+ Flags;
+ Flags
+ new::Region<Self>;
type EarlyParamRegion: Copy + Debug + Hash + Ord;
type LateParamRegion: Copy + Debug + Hash + Ord;
type BoundRegion: Copy + Debug + Hash + Ord;
Expand All @@ -90,11 +93,6 @@ pub trait Interner: Sized {
type ClosureKind: Copy + Debug + Hash + Eq;

fn mk_canonical_var_infos(self, infos: &[CanonicalVarInfo<Self>]) -> Self::CanonicalVars;

// FIXME: We should not have all these constructors on `Interner`, but as functions on some trait.
fn mk_bound_ty(self, debruijn: DebruijnIndex, var: BoundVar) -> Self::Ty;
fn mk_bound_region(self, debruijn: DebruijnIndex, var: BoundVar) -> Self::Region;
fn mk_bound_const(self, debruijn: DebruijnIndex, var: BoundVar, ty: Self::Ty) -> Self::Const;
}

/// Common capabilities of placeholder kinds
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_type_ir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use std::sync::Arc as Lrc;
#[cfg(feature = "nightly")]
pub mod codec;
pub mod fold;
pub mod new;
pub mod ty_info;
pub mod ty_kind;
pub mod visit;
Expand Down
13 changes: 13 additions & 0 deletions compiler/rustc_type_ir/src/new.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use crate::{BoundVar, DebruijnIndex, Interner};

pub trait Ty<I: Interner<Ty = Self>> {
fn new_anon_bound(interner: I, debruijn: DebruijnIndex, var: BoundVar) -> Self;
}

pub trait Region<I: Interner<Region = Self>> {
fn new_anon_bound(interner: I, debruijn: DebruijnIndex, var: BoundVar) -> Self;
}

pub trait Const<I: Interner<Const = Self>> {
fn new_anon_bound(interner: I, debruijn: DebruijnIndex, var: BoundVar, ty: I::Ty) -> Self;
}