Skip to content
Merged
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
3 changes: 1 addition & 2 deletions compiler/rustc_borrowck/src/def_use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ pub(crate) fn categorize(context: PlaceContext) -> Option<DefUse> {
PlaceContext::NonMutatingUse(NonMutatingUseContext::RawBorrow) |
PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect) |
PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) |
PlaceContext::NonMutatingUse(NonMutatingUseContext::Move) |
PlaceContext::MutatingUse(MutatingUseContext::Retag) => Some(DefUse::Use),
PlaceContext::NonMutatingUse(NonMutatingUseContext::Move) => Some(DefUse::Use),

///////////////////////////////////////////////////////////////////////////
// DROP USES
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_codegen_ssa/src/mir/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'b, 'tcx>> Visitor<'tcx> for LocalAnalyzer
}

PlaceContext::NonUse(_)
| PlaceContext::NonMutatingUse(NonMutatingUseContext::PlaceMention)
| PlaceContext::MutatingUse(MutatingUseContext::Retag) => {}
| PlaceContext::NonMutatingUse(NonMutatingUseContext::PlaceMention) => {}

PlaceContext::NonMutatingUse(
NonMutatingUseContext::Copy
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_const_eval/src/const_eval/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,11 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
ecx.write_type_info(ty, dest)?;
}

sym::type_id_is_signed => {
let ty = ecx.read_type_id(&args[0])?;
ecx.write_scalar(Scalar::from_bool(ty.is_signed()), dest)?;
}

sym::size_of_type_id => {
let ty = ecx.read_type_id(&args[0])?;
let layout = ecx.layout_of(ty)?;
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_hir_analysis/src/check/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -> hi
| sym::type_id_field_representing_type
| sym::type_id_fields
| sym::type_id_generics
| sym::type_id_is_signed
| sym::type_id_variants
| sym::type_id_vtable
| sym::type_name
Expand Down Expand Up @@ -332,6 +333,7 @@ pub(crate) fn check_intrinsic_type(
(0, 0, vec![type_id_ty(), tcx.types.usize, tcx.types.usize], type_id_ty())
}
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::type_id_vtable => {
let dyn_metadata = tcx.require_lang_item(LangItem::DynMetadata, span);
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_middle/src/mir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1354,8 +1354,6 @@ pub enum MutatingUseContext {
/// f(&mut x.y);
/// ```
Projection,
/// Retagging, a "Stacked Borrows" shadow state operation
Retag,
}

#[derive(Copy, Clone, Debug, PartialEq, Eq)]
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_mir_dataflow/src/impls/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ impl DefUse {
PlaceContext::MutatingUse(
MutatingUseContext::RawBorrow
| MutatingUseContext::Borrow
| MutatingUseContext::Drop
| MutatingUseContext::Retag,
| MutatingUseContext::Drop,
)
| PlaceContext::NonMutatingUse(
NonMutatingUseContext::RawBorrow
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_mir_transform/src/deduce_param_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ impl<'tcx> Visitor<'tcx> for DeduceParamAttrs {
MutatingUseContext::Store
| MutatingUseContext::SetDiscriminant
| MutatingUseContext::AsmOutput
| MutatingUseContext::Projection
| MutatingUseContext::Retag) => {
| MutatingUseContext::Projection) => {
self.usage[i] |= UsageSummary::MUTATE;
}
| PlaceContext::NonMutatingUse(NonMutatingUseContext::RawBorrow) => {
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_mir_transform/src/known_panics_lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,6 @@ impl<'tcx> Visitor<'tcx> for CanConstProp {
// whether they'd be fine right now.
MutatingUse(MutatingUseContext::Yield)
| MutatingUse(MutatingUseContext::Drop)
| MutatingUse(MutatingUseContext::Retag)
// These can't ever be propagated under any scheme, as we can't reason about indirect
// mutation.
| NonMutatingUse(NonMutatingUseContext::SharedBorrow)
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_mir_transform/src/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1548,8 +1548,7 @@ impl DefUse {
PlaceContext::MutatingUse(
MutatingUseContext::RawBorrow
| MutatingUseContext::Borrow
| MutatingUseContext::Drop
| MutatingUseContext::Retag,
| MutatingUseContext::Drop,
)
| PlaceContext::NonMutatingUse(
NonMutatingUseContext::RawBorrow
Expand Down
15 changes: 14 additions & 1 deletion compiler/rustc_next_trait_solver/src/canonical/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,20 @@ where
let prev_universe = delegate.universe();
let universes_created_in_query = response.max_universe.index();
for _ in 0..universes_created_in_query {
delegate.create_next_universe();
let new_universe = delegate.create_next_universe();
if delegate.cx().assumptions_on_binders() {
// FIXME(-Zassumptions-on-binders): Remove this temporary workaround once
// opaque types no longer escape query responses with query-created placeholders.
// Region constraints involving query-created placeholders were handled inside
// the query. However, the placeholders can still escape in other response
// fields, such as opaque type constraints. To avoid triggering
// assertions, we explicitly insert empty assumptions for the
// recreated universes here.
delegate.insert_placeholder_assumptions(
new_universe,
Some(rustc_type_ir::region_constraint::Assumptions::empty()),
);
}
}

compute_query_response_instantiation_values_in_universe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use rustc_type_ir::inherent::*;
use rustc_type_ir::solve::{
Certainty, ComputeGoalFastPathOutcome, Goal, GoalStalledOn, GoalStalledOnOpaques,
Certainty, ComputeGoalFastPathOutcome, Goal, GoalStalledOn, GoalStalledOnOpaques, MaybeInfo,
SucceededInErased,
};
use rustc_type_ir::{InferCtxtLike, Interner};
Expand All @@ -18,7 +18,7 @@ use crate::solve::{GoalEvaluation, HasChanged};

#[derive(Debug, Clone, Copy)]
pub(super) enum RerunStalled {
WontMakeProgress(Certainty),
WontMakeProgress(MaybeInfo),
MayMakeProgress,
}

Expand All @@ -43,7 +43,7 @@ where
}

// If the goal isn't stalled, we should definitely run it.
let Some(&GoalStalledOn { ref opaques, ref stalled_vars, ref sub_roots, stalled_certainty }) =
let Some(&GoalStalledOn { ref opaques, ref stalled_vars, ref sub_roots, stalled_maybe_info }) =
stalled_on
else {
return MayMakeProgress;
Expand Down Expand Up @@ -105,7 +105,7 @@ where

// Otherwise, we can be sure that this stalled goal cannot make any progress
// and we can exit early.
WontMakeProgress(stalled_certainty)
WontMakeProgress(stalled_maybe_info)
}

/// `compute_goal_fast_path` is complicated enough that outling helps, so it gets optimized
Expand Down
28 changes: 12 additions & 16 deletions compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ pub trait SolverDelegateEvalExt: SolverDelegate {

/// Checks whether a stalled goal would remain stalled if re-evaluated, without consuming
/// `stalled_on`.
fn goal_remains_stalled(&self, stalled_on: &GoalStalledOn<Self::Interner>)
-> Option<Certainty>;
fn goal_remains_stalled(&self, stalled_on: &GoalStalledOn<Self::Interner>) -> bool;

/// Checks whether evaluating `goal` may hold while treating not-yet-defined
/// opaque types as being kind of rigid.
Expand Down Expand Up @@ -231,12 +230,12 @@ where
stalled_on: Option<GoalStalledOn<I>>,
) -> Result<GoalEvaluation<I>, NoSolution> {
// Run fast paths *before* building an `EvalCtxt`, saving a little bit of time.
if let RerunStalled::WontMakeProgress(stalled_certainty) =
if let RerunStalled::WontMakeProgress(stalled_maybe_info) =
rerunning_stalled_goal_may_make_progress(self, stalled_on.as_ref())
{
return Ok(GoalEvaluation {
goal,
certainty: stalled_certainty,
certainty: Certainty::Maybe(stalled_maybe_info),
has_changed: HasChanged::No,
stalled_on,
});
Expand Down Expand Up @@ -265,13 +264,10 @@ where
}
}

fn goal_remains_stalled(
&self,
stalled_on: &GoalStalledOn<Self::Interner>,
) -> Option<Certainty> {
fn goal_remains_stalled(&self, stalled_on: &GoalStalledOn<Self::Interner>) -> bool {
match rerunning_stalled_goal_may_make_progress(self, Some(stalled_on)) {
RerunStalled::WontMakeProgress(certainty) => Some(certainty),
RerunStalled::MayMakeProgress => None,
RerunStalled::WontMakeProgress(_) => true,
RerunStalled::MayMakeProgress => false,
}
}

Expand Down Expand Up @@ -608,12 +604,12 @@ where
goal: Goal<I, I::Predicate>,
stalled_on: Option<GoalStalledOn<I>>,
) -> Result<GoalEvaluation<I>, NoSolutionOrRerunNonErased> {
if let RerunStalled::WontMakeProgress(stalled_certainty) =
if let RerunStalled::WontMakeProgress(stalled_maybe_info) =
rerunning_stalled_goal_may_make_progress(self.delegate, stalled_on.as_ref())
{
return Ok(GoalEvaluation {
goal,
certainty: stalled_certainty,
certainty: Certainty::Maybe(stalled_maybe_info),
has_changed: HasChanged::No,
stalled_on,
});
Expand Down Expand Up @@ -814,15 +810,15 @@ where

let stalled_on = match certainty {
Certainty::Yes => None,
Certainty::Maybe { .. } => match has_changed {
Certainty::Maybe(maybe_info) => match has_changed {
// FIXME: We could recompute a *new* set of stalled variables by walking
// through the orig values, resolving, and computing the root vars of anything
// that is not resolved. Only when *these* have changed is it meaningful
// to recompute this goal.
HasChanged::Yes => None,
HasChanged::No => Some(self.build_stalled_on(
canonical_goal,
certainty,
maybe_info,
orig_values,
succeeded_in_erased,
)),
Expand All @@ -838,7 +834,7 @@ where
fn build_stalled_on(
&self,
canonical_goal: CanonicalInput<I>,
certainty: Certainty,
maybe_info: MaybeInfo,
stalled_vars: ThinVec<I::GenericArg>,
previously_succeeded_in_erased: SucceededInErased<I>,
) -> GoalStalledOn<I> {
Expand Down Expand Up @@ -872,7 +868,7 @@ where
GoalStalledOn {
stalled_vars,
sub_roots,
stalled_certainty: certainty,
stalled_maybe_info: maybe_info,
opaques: GoalStalledOnOpaques::Yes {
num_opaques_in_storage: canonical_goal
.canonical
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2179,6 +2179,7 @@ symbols! {
type_id_field_representing_type,
type_id_fields,
type_id_generics,
type_id_is_signed,
type_id_variants,
type_id_vtable,
type_info,
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_trait_selection/src/solve/delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use rustc_infer::traits::solve::{
ComputeGoalFastPathOutcome, FetchEligibleAssocItemResponse, Goal, SucceededInErased,
};
use rustc_middle::traits::query::NoSolution;
use rustc_middle::traits::solve::Certainty;
use rustc_middle::traits::solve::{Certainty, MaybeInfo};
use rustc_middle::ty::{
self, MayBeErased, Ty, TyCtxt, TypeFlags, TypeFoldable, TypeSuperVisitable, TypeVisitable,
TypeVisitableExt, TypeVisitor, TypingMode,
Expand Down Expand Up @@ -61,7 +61,7 @@ fn goal_stalled_on_args<'tcx>(
stalled_on: GoalStalledOn {
stalled_vars,
sub_roots: ThinVec::new(),
stalled_certainty: Certainty::AMBIGUOUS,
stalled_maybe_info: MaybeInfo::AMBIGUOUS,
opaques: GoalStalledOnOpaques::No,
},
}
Expand All @@ -77,7 +77,7 @@ fn goal_stalled_on_args_or_nonempty_opaques<'tcx>(
stalled_on: GoalStalledOn {
stalled_vars,
sub_roots: ThinVec::new(),
stalled_certainty: Certainty::AMBIGUOUS,
stalled_maybe_info: MaybeInfo::AMBIGUOUS,
opaques: GoalStalledOnOpaques::Yes {
num_opaques_in_storage: 0,
// This function should only be called when not in erased mode,
Expand Down
18 changes: 7 additions & 11 deletions compiler/rustc_trait_selection/src/solve/fulfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ use rustc_infer::traits::{
use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt, TypingMode};
use rustc_next_trait_solver::solve::fast_path::compute_goal_fast_path;
use rustc_next_trait_solver::solve::{
GoalEvaluation, GoalStalledOn, HasChanged, MaybeInfo, SolverDelegateEvalExt as _,
StalledOnCoroutines,
GoalEvaluation, GoalStalledOn, HasChanged, SolverDelegateEvalExt as _, StalledOnCoroutines,
};
use thin_vec::ThinVec;
use tracing::instrument;
Expand Down Expand Up @@ -208,8 +207,7 @@ where
// Common case: still stalled; keep the obligation. This path is extremely hot in
// some cases; there can be thousands of pending obligations.
if let Some(stalled_on) = opt_stalled_on
&& let Some(certainty) = delegate.goal_remains_stalled(stalled_on)
&& matches!(certainty, Certainty::Maybe(_))
&& delegate.goal_remains_stalled(stalled_on)
{
return true;
}
Expand Down Expand Up @@ -378,13 +376,11 @@ where

self.obligations
.drain_pending(|_, stalled_on| {
stalled_on.as_ref().is_some_and(|s| match s.stalled_certainty {
Certainty::Maybe(MaybeInfo {
cause: _,
opaque_types_jank: _,
stalled_on_coroutines: StalledOnCoroutines::Yes,
}) => true,
Certainty::Maybe(_) | Certainty::Yes => false,
stalled_on.as_ref().is_some_and(|s| {
match s.stalled_maybe_info.stalled_on_coroutines {
StalledOnCoroutines::Yes => true,
StalledOnCoroutines::No => false,
}
})
})
.into_iter()
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_type_ir/src/solve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -993,9 +993,9 @@ pub struct GoalStalledOn<I: Interner> {
pub stalled_vars: ThinVec<TyOrConstInferVar>,
// `ThinVec` is important for performance. See #160005.
pub sub_roots: ThinVec<TyVid>,
/// The certainty that will be returned on subsequent evaluations if this
/// The `MaybeInfo` that will be returned on subsequent evaluations if this
/// goal remains stalled.
pub stalled_certainty: Certainty,
pub stalled_maybe_info: MaybeInfo,
pub opaques: GoalStalledOnOpaques<I>,
}

Expand Down
8 changes: 8 additions & 0 deletions library/core/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3128,6 +3128,14 @@ pub const fn type_id_eq(a: crate::any::TypeId, b: crate::any::TypeId) -> bool {
unsafe { crate::mem::transmute::<_, u128>(a) == crate::mem::transmute::<_, u128>(b) }
}

/// Returns whether the type represented by this `TypeId` is a signed integer.
///
/// The more user-friendly version of this intrinsic is [`core::any::TypeId::is_signed`].
#[rustc_intrinsic]
#[unstable(feature = "core_intrinsics", issue = "none")]
#[rustc_comptime]
pub fn type_id_is_signed(_id: crate::any::TypeId) -> bool;

/// Gets the size of the type represented by this `TypeId`.
///
/// The more user-friendly version of this intrinsic is [`core::any::TypeId::size`].
Expand Down
21 changes: 21 additions & 0 deletions library/core/src/mem/type_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,27 @@ pub enum Abi {
}

impl TypeId {
/// Returns `true` if the type represented by this `TypeId` is an signed integer.
///
/// For everything else this returns false.
///
/// # Examples
///
/// ```
/// #![feature(type_info)]
/// use std::any::TypeId;
///
/// assert_eq!(const { TypeId::of::<i32>().is_signed() }, true);
/// assert_eq!(const { TypeId::of::<u8>().is_signed() }, false);
/// assert_eq!(const { TypeId::of::<bool>().is_signed() }, false);
/// ```
#[unstable(feature = "type_info", issue = "146922")]
#[rustc_const_unstable(feature = "type_info", issue = "146922")]
#[rustc_comptime]
pub fn is_signed(self) -> bool {
intrinsics::type_id_is_signed(self)
}

/// Returns the size of the type represented by this `TypeId`. `None` if it is unsized.
///
/// # Examples
Expand Down
10 changes: 7 additions & 3 deletions src/bootstrap/src/cli_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ use std::sync::Once;
use std::time::Instant;
use std::{env, process};

use crate::{
Build, CONFIG_CHANGE_HISTORY, ChangeId, Config, Flags, StepStack, Subcommand, debug,
find_recent_config_change_ids, human_readable_changes, t,
use crate::core::builder::StepStack;
use crate::core::config::flags::Flags;
use crate::core::config::{ChangeId, Config, Subcommand};
use crate::utils::change_tracker::{
CONFIG_CHANGE_HISTORY, find_recent_config_change_ids, human_readable_changes,
};
use crate::utils::helpers::t;
use crate::{Build, debug};

fn is_tracing_enabled() -> bool {
cfg!(feature = "tracing")
Expand Down
Loading
Loading