Skip to content
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7b86c98
do not use the global solver cache for proof trees
lcnr Jul 23, 2024
51338ca
expand fuzzing support
lcnr Jul 23, 2024
e87157b
simplify match + move `debug!` call
lcnr Jul 23, 2024
9308401
tracing: debug to trace
lcnr Jul 23, 2024
e83eacd
move behavior out of shared fn
lcnr Jul 23, 2024
0c75c08
merge impl blocks
lcnr Jul 23, 2024
f860873
split provisional cache and stack lookup
lcnr Jul 23, 2024
1b6df71
Explicitly specify type parameter on FromResidual impls in stdlib.
zachs18 Aug 10, 2024
0aa17a4
implement a performant and fuzzed solver cache
lcnr Jul 24, 2024
850bcbd
Test showing previous behavior
compiler-errors Aug 13, 2024
5df13af
Use the right type when coercing fn items to pointers
compiler-errors Aug 12, 2024
8419c09
stabilize `asm_const`
folkertdev Aug 10, 2024
342b374
Port `run-make/sysroot-crates-are-unstable` to rmake
Zalathar Aug 14, 2024
8557b56
Add `|` to make the html doc of `Level` rendered correctly
Jaic1 Aug 14, 2024
196d256
Rollup merge of #128570 - folkertdev:stabilize-asm-const, r=Amanieu
jieyouxu Aug 14, 2024
59ad2ae
Rollup merge of #128828 - lcnr:search-graph-11, r=compiler-errors
jieyouxu Aug 14, 2024
049b3e5
Rollup merge of #128954 - zachs18:fromresidual-no-default, r=scottmcm
jieyouxu Aug 14, 2024
2200910
Rollup merge of #129059 - compiler-errors:subtyping-correct-type, r=lcnr
jieyouxu Aug 14, 2024
7472d1b
Rollup merge of #129071 - Zalathar:sysroot-unstable, r=jieyouxu
jieyouxu Aug 14, 2024
4d8c0b3
Rollup merge of #129088 - Jaic1:fix-doc, r=GuillaumeGomez
jieyouxu Aug 14, 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
2 changes: 0 additions & 2 deletions compiler/rustc_ast_lowering/messages.ftl
Original file line number Diff line number Diff line change
@@ -175,8 +175,6 @@ ast_lowering_underscore_expr_lhs_assign =
.label = `_` not allowed here
ast_lowering_unstable_inline_assembly = inline assembly is not stable yet on this architecture
ast_lowering_unstable_inline_assembly_const_operands =
const operands for inline assembly are unstable
ast_lowering_unstable_inline_assembly_label_operands =
label operands for inline assembly are unstable
ast_lowering_unstable_may_unwind = the `may_unwind` option is unstable
17 changes: 3 additions & 14 deletions compiler/rustc_ast_lowering/src/asm.rs
Original file line number Diff line number Diff line change
@@ -183,20 +183,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
out_expr: out_expr.as_ref().map(|expr| self.lower_expr(expr)),
}
}
InlineAsmOperand::Const { anon_const } => {
if !self.tcx.features().asm_const {
feature_err(
sess,
sym::asm_const,
*op_sp,
fluent::ast_lowering_unstable_inline_assembly_const_operands,
)
.emit();
}
hir::InlineAsmOperand::Const {
anon_const: self.lower_anon_const_to_anon_const(anon_const),
}
}
InlineAsmOperand::Const { anon_const } => hir::InlineAsmOperand::Const {
anon_const: self.lower_anon_const_to_anon_const(anon_const),
},
InlineAsmOperand::Sym { sym } => {
let static_def_id = self
.resolver
8 changes: 4 additions & 4 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
@@ -1989,9 +1989,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {

let ty_fn_ptr_from = Ty::new_fn_ptr(tcx, fn_sig);

if let Err(terr) = self.eq_types(
*ty,
if let Err(terr) = self.sub_types(
ty_fn_ptr_from,
*ty,
location.to_locations(),
ConstraintCategory::Cast { unsize_to: None },
) {
@@ -2014,9 +2014,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
let ty_fn_ptr_from =
Ty::new_fn_ptr(tcx, tcx.signature_unclosure(sig, *safety));

if let Err(terr) = self.eq_types(
*ty,
if let Err(terr) = self.sub_types(
ty_fn_ptr_from,
*ty,
location.to_locations(),
ConstraintCategory::Cast { unsize_to: None },
) {
15 changes: 6 additions & 9 deletions compiler/rustc_codegen_gcc/tests/run/asm.rs
Original file line number Diff line number Diff line change
@@ -3,12 +3,10 @@
// Run-time:
// status: 0

#![feature(asm_const)]

#[cfg(target_arch="x86_64")]
#[cfg(target_arch = "x86_64")]
use std::arch::{asm, global_asm};

#[cfg(target_arch="x86_64")]
#[cfg(target_arch = "x86_64")]
global_asm!(
"
.global add_asm
@@ -22,7 +20,7 @@ extern "C" {
fn add_asm(a: i64, b: i64) -> i64;
}

#[cfg(target_arch="x86_64")]
#[cfg(target_arch = "x86_64")]
pub unsafe fn mem_cpy(dst: *mut u8, src: *const u8, len: usize) {
asm!(
"rep movsb",
@@ -33,7 +31,7 @@ pub unsafe fn mem_cpy(dst: *mut u8, src: *const u8, len: usize) {
);
}

#[cfg(target_arch="x86_64")]
#[cfg(target_arch = "x86_64")]
fn asm() {
unsafe {
asm!("nop");
@@ -178,9 +176,8 @@ fn asm() {
assert_eq!(array1, array2);
}

#[cfg(not(target_arch="x86_64"))]
fn asm() {
}
#[cfg(not(target_arch = "x86_64"))]
fn asm() {}

fn main() {
asm();
32 changes: 16 additions & 16 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1837,23 +1837,23 @@ impl DelayedDiagInner {
}
}

/// Level is_error EmissionGuarantee Top-level Sub Used in lints?
/// ----- -------- ----------------- --------- --- --------------
/// Bug yes BugAbort yes - -
/// Fatal yes FatalAbort/FatalError(*) yes - -
/// Error yes ErrorGuaranteed yes - yes
/// DelayedBug yes ErrorGuaranteed yes - -
/// ForceWarning - () yes - lint-only
/// Warning - () yes yes yes
/// Note - () rare yes -
/// OnceNote - () - yes lint-only
/// Help - () rare yes -
/// OnceHelp - () - yes lint-only
/// FailureNote - () rare - -
/// Allow - () yes - lint-only
/// Expect - () yes - lint-only
/// | Level | is_error | EmissionGuarantee | Top-level | Sub | Used in lints?
/// | ----- | -------- | ----------------- | --------- | --- | --------------
/// | Bug | yes | BugAbort | yes | - | -
/// | Fatal | yes | FatalAbort/FatalError[^star] | yes | - | -
/// | Error | yes | ErrorGuaranteed | yes | - | yes
/// | DelayedBug | yes | ErrorGuaranteed | yes | - | -
/// | ForceWarning | - | () | yes | - | lint-only
/// | Warning | - | () | yes | yes | yes
/// | Note | - | () | rare | yes | -
/// | OnceNote | - | () | - | yes | lint-only
/// | Help | - | () | rare | yes | -
/// | OnceHelp | - | () | - | yes | lint-only
/// | FailureNote | - | () | rare | - | -
/// | Allow | - | () | yes | - | lint-only
/// | Expect | - | () | yes | - | lint-only
///
/// (*) `FatalAbort` normally, `FatalError` in the non-aborting "almost fatal" case that is
/// [^star]: `FatalAbort` normally, `FatalError` in the non-aborting "almost fatal" case that is
/// occasionally used.
///
#[derive(Copy, PartialEq, Eq, Clone, Hash, Debug, Encodable, Decodable)]
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
@@ -60,6 +60,8 @@ declare_features! (
(accepted, adx_target_feature, "1.61.0", Some(44839)),
/// Allows explicit discriminants on non-unit enum variants.
(accepted, arbitrary_enum_discriminant, "1.66.0", Some(60553)),
/// Allows using `const` operands in inline assembly.
(accepted, asm_const, "CURRENT_RUSTC_VERSION", Some(93332)),
/// Allows using `sym` operands in inline assembly.
(accepted, asm_sym, "1.66.0", Some(93333)),
/// Allows the definition of associated constants in `trait` or `impl` blocks.
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
@@ -348,8 +348,6 @@ declare_features! (
(unstable, alloc_error_handler, "1.29.0", Some(51540)),
/// Allows trait methods with arbitrary self types.
(unstable, arbitrary_self_types, "1.23.0", Some(44874)),
/// Allows using `const` operands in inline assembly.
(unstable, asm_const, "1.58.0", Some(93332)),
/// Enables experimental inline assembly support for additional architectures.
(unstable, asm_experimental_arch, "1.58.0", Some(93335)),
/// Allows using `label` operands in inline assembly.
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/coercion.rs
Original file line number Diff line number Diff line change
@@ -137,7 +137,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
at.lub(DefineOpaqueTypes::Yes, b, a)
} else {
at.sup(DefineOpaqueTypes::Yes, b, a)
.map(|InferOk { value: (), obligations }| InferOk { value: a, obligations })
.map(|InferOk { value: (), obligations }| InferOk { value: b, obligations })
};

// In the new solver, lazy norm may allow us to shallowly equate
4 changes: 0 additions & 4 deletions compiler/rustc_middle/src/arena.rs
Original file line number Diff line number Diff line change
@@ -61,10 +61,6 @@ macro_rules! arena_types {
[] dtorck_constraint: rustc_middle::traits::query::DropckConstraint<'tcx>,
[] candidate_step: rustc_middle::traits::query::CandidateStep<'tcx>,
[] autoderef_bad_ty: rustc_middle::traits::query::MethodAutoderefBadTy<'tcx>,
[] canonical_goal_evaluation:
rustc_type_ir::solve::inspect::CanonicalGoalEvaluationStep<
rustc_middle::ty::TyCtxt<'tcx>
>,
[] query_region_constraints: rustc_middle::infer::canonical::QueryRegionConstraints<'tcx>,
[] type_op_subtype:
rustc_middle::infer::canonical::Canonical<'tcx,
9 changes: 0 additions & 9 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
@@ -107,8 +107,6 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
self.mk_predefined_opaques_in_body(data)
}
type DefiningOpaqueTypes = &'tcx ty::List<LocalDefId>;
type CanonicalGoalEvaluationStepRef =
&'tcx solve::inspect::CanonicalGoalEvaluationStep<TyCtxt<'tcx>>;
type CanonicalVars = CanonicalVarInfos<'tcx>;
fn mk_canonical_var_infos(self, infos: &[ty::CanonicalVarInfo<Self>]) -> Self::CanonicalVars {
self.mk_canonical_var_infos(infos)
@@ -277,13 +275,6 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
self.debug_assert_args_compatible(def_id, args);
}

fn intern_canonical_goal_evaluation_step(
self,
step: solve::inspect::CanonicalGoalEvaluationStep<TyCtxt<'tcx>>,
) -> &'tcx solve::inspect::CanonicalGoalEvaluationStep<TyCtxt<'tcx>> {
self.arena.alloc(step)
}

fn mk_type_list_from_iter<I, T>(self, args: I) -> T::Output
where
I: Iterator<Item = T>,
106 changes: 14 additions & 92 deletions compiler/rustc_next_trait_solver/src/solve/inspect/build.rs
Original file line number Diff line number Diff line change
@@ -5,11 +5,10 @@
//! see the comment on [ProofTreeBuilder].
use std::marker::PhantomData;
use std::mem;

use derive_where::derive_where;
use rustc_type_ir::inherent::*;
use rustc_type_ir::{self as ty, search_graph, Interner};
use rustc_type_ir::{self as ty, Interner};

use crate::delegate::SolverDelegate;
use crate::solve::eval_ctxt::canonical;
@@ -94,31 +93,10 @@ impl<I: Interner> WipGoalEvaluation<I> {
}
}

#[derive_where(PartialEq, Eq; I: Interner)]
pub(in crate::solve) enum WipCanonicalGoalEvaluationKind<I: Interner> {
Overflow,
CycleInStack,
ProvisionalCacheHit,
Interned { final_revision: I::CanonicalGoalEvaluationStepRef },
}

impl<I: Interner> std::fmt::Debug for WipCanonicalGoalEvaluationKind<I> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Overflow => write!(f, "Overflow"),
Self::CycleInStack => write!(f, "CycleInStack"),
Self::ProvisionalCacheHit => write!(f, "ProvisionalCacheHit"),
Self::Interned { final_revision: _ } => {
f.debug_struct("Interned").finish_non_exhaustive()
}
}
}
}

#[derive_where(PartialEq, Eq, Debug; I: Interner)]
struct WipCanonicalGoalEvaluation<I: Interner> {
goal: CanonicalInput<I>,
kind: Option<WipCanonicalGoalEvaluationKind<I>>,
encountered_overflow: bool,
/// Only used for uncached goals. After we finished evaluating
/// the goal, this is interned and moved into `kind`.
final_revision: Option<WipCanonicalGoalEvaluationStep<I>>,
@@ -127,25 +105,17 @@ struct WipCanonicalGoalEvaluation<I: Interner> {

impl<I: Interner> WipCanonicalGoalEvaluation<I> {
fn finalize(self) -> inspect::CanonicalGoalEvaluation<I> {
// We've already interned the final revision in
// `fn finalize_canonical_goal_evaluation`.
assert!(self.final_revision.is_none());
let kind = match self.kind.unwrap() {
WipCanonicalGoalEvaluationKind::Overflow => {
inspect::CanonicalGoalEvaluation {
goal: self.goal,
kind: if self.encountered_overflow {
assert!(self.final_revision.is_none());
inspect::CanonicalGoalEvaluationKind::Overflow
}
WipCanonicalGoalEvaluationKind::CycleInStack => {
inspect::CanonicalGoalEvaluationKind::CycleInStack
}
WipCanonicalGoalEvaluationKind::ProvisionalCacheHit => {
inspect::CanonicalGoalEvaluationKind::ProvisionalCacheHit
}
WipCanonicalGoalEvaluationKind::Interned { final_revision } => {
} else {
let final_revision = self.final_revision.unwrap().finalize();
inspect::CanonicalGoalEvaluationKind::Evaluation { final_revision }
}
};

inspect::CanonicalGoalEvaluation { goal: self.goal, kind, result: self.result.unwrap() }
},
result: self.result.unwrap(),
}
}
}

@@ -308,7 +278,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
) -> ProofTreeBuilder<D> {
self.nested(|| WipCanonicalGoalEvaluation {
goal,
kind: None,
encountered_overflow: false,
final_revision: None,
result: None,
})
@@ -329,11 +299,11 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
}
}

pub fn canonical_goal_evaluation_kind(&mut self, kind: WipCanonicalGoalEvaluationKind<I>) {
pub fn canonical_goal_evaluation_overflow(&mut self) {
if let Some(this) = self.as_mut() {
match this {
DebugSolver::CanonicalGoalEvaluation(canonical_goal_evaluation) => {
assert_eq!(canonical_goal_evaluation.kind.replace(kind), None);
canonical_goal_evaluation.encountered_overflow = true;
}
_ => unreachable!(),
};
@@ -547,51 +517,3 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
}
}
}

impl<D, I> search_graph::ProofTreeBuilder<I> for ProofTreeBuilder<D>
where
D: SolverDelegate<Interner = I>,
I: Interner,
{
fn try_apply_proof_tree(
&mut self,
proof_tree: Option<I::CanonicalGoalEvaluationStepRef>,
) -> bool {
if !self.is_noop() {
if let Some(final_revision) = proof_tree {
let kind = WipCanonicalGoalEvaluationKind::Interned { final_revision };
self.canonical_goal_evaluation_kind(kind);
true
} else {
false
}
} else {
true
}
}

fn on_provisional_cache_hit(&mut self) {
self.canonical_goal_evaluation_kind(WipCanonicalGoalEvaluationKind::ProvisionalCacheHit);
}

fn on_cycle_in_stack(&mut self) {
self.canonical_goal_evaluation_kind(WipCanonicalGoalEvaluationKind::CycleInStack);
}

fn finalize_canonical_goal_evaluation(
&mut self,
tcx: I,
) -> Option<I::CanonicalGoalEvaluationStepRef> {
self.as_mut().map(|this| match this {
DebugSolver::CanonicalGoalEvaluation(evaluation) => {
let final_revision = mem::take(&mut evaluation.final_revision).unwrap();
let final_revision =
tcx.intern_canonical_goal_evaluation_step(final_revision.finalize());
let kind = WipCanonicalGoalEvaluationKind::Interned { final_revision };
assert_eq!(evaluation.kind.replace(kind), None);
final_revision
}
_ => unreachable!(),
})
}
}
66 changes: 44 additions & 22 deletions compiler/rustc_next_trait_solver/src/solve/search_graph.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use std::convert::Infallible;
use std::marker::PhantomData;

use rustc_type_ir::inherent::*;
use rustc_type_ir::search_graph::{self, CycleKind, UsageKind};
use rustc_type_ir::search_graph::{self, PathKind};
use rustc_type_ir::solve::{CanonicalInput, Certainty, QueryResult};
use rustc_type_ir::Interner;

use super::inspect::{self, ProofTreeBuilder};
use super::FIXPOINT_STEP_LIMIT;
use super::inspect::ProofTreeBuilder;
use super::{has_no_inference_or_external_constraints, FIXPOINT_STEP_LIMIT};
use crate::delegate::SolverDelegate;

/// This type is never constructed. We only use it to implement `search_graph::Delegate`
@@ -22,43 +23,48 @@ where
{
type Cx = D::Interner;

const ENABLE_PROVISIONAL_CACHE: bool = true;
type ValidationScope = Infallible;
fn enter_validation_scope(
_cx: Self::Cx,
_input: CanonicalInput<I>,
) -> Option<Self::ValidationScope> {
None
}

const FIXPOINT_STEP_LIMIT: usize = FIXPOINT_STEP_LIMIT;

type ProofTreeBuilder = ProofTreeBuilder<D>;
fn inspect_is_noop(inspect: &mut Self::ProofTreeBuilder) -> bool {
inspect.is_noop()
}

const DIVIDE_AVAILABLE_DEPTH_ON_OVERFLOW: usize = 4;
fn recursion_limit(cx: I) -> usize {
cx.recursion_limit()
}

fn initial_provisional_result(
cx: I,
kind: CycleKind,
kind: PathKind,
input: CanonicalInput<I>,
) -> QueryResult<I> {
match kind {
CycleKind::Coinductive => response_no_constraints(cx, input, Certainty::Yes),
CycleKind::Inductive => response_no_constraints(cx, input, Certainty::overflow(false)),
PathKind::Coinductive => response_no_constraints(cx, input, Certainty::Yes),
PathKind::Inductive => response_no_constraints(cx, input, Certainty::overflow(false)),
}
}

fn reached_fixpoint(
cx: I,
kind: UsageKind,
fn is_initial_provisional_result(
cx: Self::Cx,
kind: PathKind,
input: CanonicalInput<I>,
provisional_result: Option<QueryResult<I>>,
result: QueryResult<I>,
) -> bool {
if let Some(r) = provisional_result {
r == result
} else {
match kind {
UsageKind::Single(CycleKind::Coinductive) => {
response_no_constraints(cx, input, Certainty::Yes) == result
}
UsageKind::Single(CycleKind::Inductive) => {
response_no_constraints(cx, input, Certainty::overflow(false)) == result
}
UsageKind::Mixed => false,
match kind {
PathKind::Coinductive => response_no_constraints(cx, input, Certainty::Yes) == result,
PathKind::Inductive => {
response_no_constraints(cx, input, Certainty::overflow(false)) == result
}
}
}
@@ -68,14 +74,30 @@ where
inspect: &mut ProofTreeBuilder<D>,
input: CanonicalInput<I>,
) -> QueryResult<I> {
inspect.canonical_goal_evaluation_kind(inspect::WipCanonicalGoalEvaluationKind::Overflow);
inspect.canonical_goal_evaluation_overflow();
response_no_constraints(cx, input, Certainty::overflow(true))
}

fn on_fixpoint_overflow(cx: I, input: CanonicalInput<I>) -> QueryResult<I> {
response_no_constraints(cx, input, Certainty::overflow(false))
}

fn is_ambiguous_result(result: QueryResult<I>) -> bool {
result.is_ok_and(|response| {
has_no_inference_or_external_constraints(response)
&& matches!(response.value.certainty, Certainty::Maybe(_))
})
}

fn propagate_ambiguity(
cx: I,
for_input: CanonicalInput<I>,
from_result: QueryResult<I>,
) -> QueryResult<I> {
let certainty = from_result.unwrap().value.certainty;
response_no_constraints(cx, for_input, certainty)
}

fn step_is_coinductive(cx: I, input: CanonicalInput<I>) -> bool {
input.value.goal.predicate.is_coinductive(cx)
}
10 changes: 3 additions & 7 deletions compiler/rustc_trait_selection/src/solve/inspect/analyse.rs
Original file line number Diff line number Diff line change
@@ -334,13 +334,9 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {

pub fn candidates(&'a self) -> Vec<InspectCandidate<'a, 'tcx>> {
let mut candidates = vec![];
let last_eval_step = match self.evaluation_kind {
inspect::CanonicalGoalEvaluationKind::Overflow
| inspect::CanonicalGoalEvaluationKind::CycleInStack
| inspect::CanonicalGoalEvaluationKind::ProvisionalCacheHit => {
warn!("unexpected root evaluation: {:?}", self.evaluation_kind);
return vec![];
}
let last_eval_step = match &self.evaluation_kind {
// An annoying edge case in case the recursion limit is 0.
inspect::CanonicalGoalEvaluationKind::Overflow => return vec![],
inspect::CanonicalGoalEvaluationKind::Evaluation { final_revision } => final_revision,
};

24 changes: 8 additions & 16 deletions compiler/rustc_type_ir/src/binder.rs
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ use derive_where::derive_where;
use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable};
#[cfg(feature = "nightly")]
use rustc_serialize::Decodable;
use tracing::debug;
use tracing::instrument;

use crate::data_structures::SsoHashSet;
use crate::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder, TypeSuperFoldable};
@@ -817,28 +817,20 @@ impl<'a, I: Interner> ArgFolder<'a, I> {
/// As indicated in the diagram, here the same type `&'a i32` is instantiated once, but in the
/// first case we do not increase the De Bruijn index and in the second case we do. The reason
/// is that only in the second case have we passed through a fn binder.
#[instrument(level = "trace", skip(self), fields(binders_passed = self.binders_passed), ret)]
fn shift_vars_through_binders<T: TypeFoldable<I>>(&self, val: T) -> T {
debug!(
"shift_vars(val={:?}, binders_passed={:?}, has_escaping_bound_vars={:?})",
val,
self.binders_passed,
val.has_escaping_bound_vars()
);

if self.binders_passed == 0 || !val.has_escaping_bound_vars() {
return val;
val
} else {
ty::fold::shift_vars(self.cx, val, self.binders_passed)
}

let result = ty::fold::shift_vars(TypeFolder::cx(self), val, self.binders_passed);
debug!("shift_vars: shifted result = {:?}", result);

result
}

fn shift_region_through_binders(&self, region: I::Region) -> I::Region {
if self.binders_passed == 0 || !region.has_escaping_bound_vars() {
return region;
region
} else {
ty::fold::shift_region(self.cx, region, self.binders_passed)
}
ty::fold::shift_region(self.cx, region, self.binders_passed)
}
}
11 changes: 5 additions & 6 deletions compiler/rustc_type_ir/src/fold.rs
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@
use std::mem;

use rustc_index::{Idx, IndexVec};
use tracing::debug;
use tracing::instrument;

use crate::data_structures::Lrc;
use crate::inherent::*;
@@ -417,15 +417,14 @@ pub fn shift_region<I: Interner>(cx: I, region: I::Region, amount: u32) -> I::Re
}
}

#[instrument(level = "trace", skip(cx), ret)]
pub fn shift_vars<I: Interner, T>(cx: I, value: T, amount: u32) -> T
where
T: TypeFoldable<I>,
{
debug!("shift_vars(value={:?}, amount={})", value, amount);

if amount == 0 || !value.has_escaping_bound_vars() {
return value;
value
} else {
value.fold_with(&mut Shifter::new(cx, amount))
}

value.fold_with(&mut Shifter::new(cx, amount))
}
12 changes: 0 additions & 12 deletions compiler/rustc_type_ir/src/interner.rs
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@ use crate::inherent::*;
use crate::ir_print::IrPrint;
use crate::lang_items::TraitSolverLangItem;
use crate::relate::Relate;
use crate::solve::inspect::CanonicalGoalEvaluationStep;
use crate::solve::{
CanonicalInput, ExternalConstraintsData, PredefinedOpaquesData, QueryResult, SolverMode,
};
@@ -65,11 +64,6 @@ pub trait Interner:
+ Eq
+ TypeVisitable<Self>
+ SliceLike<Item = Self::LocalDefId>;
type CanonicalGoalEvaluationStepRef: Copy
+ Debug
+ Hash
+ Eq
+ Deref<Target = CanonicalGoalEvaluationStep<Self>>;

type CanonicalVars: Copy
+ Debug
@@ -177,11 +171,6 @@ pub trait Interner:

fn debug_assert_args_compatible(self, def_id: Self::DefId, args: Self::GenericArgs);

fn intern_canonical_goal_evaluation_step(
self,
step: CanonicalGoalEvaluationStep<Self>,
) -> Self::CanonicalGoalEvaluationStepRef;

fn mk_type_list_from_iter<I, T>(self, args: I) -> T::Output
where
I: Iterator<Item = T>,
@@ -390,7 +379,6 @@ impl<T, R, E> CollectAndApply<T, R> for Result<T, E> {
}

impl<I: Interner> search_graph::Cx for I {
type ProofTree = Option<I::CanonicalGoalEvaluationStepRef>;
type Input = CanonicalInput<I>;
type Result = QueryResult<I>;

88 changes: 40 additions & 48 deletions compiler/rustc_type_ir/src/search_graph/global_cache.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
use derive_where::derive_where;
use rustc_index::IndexVec;

use super::{AvailableDepth, Cx, StackDepth, StackEntry};
use crate::data_structures::{HashMap, HashSet};

#[derive_where(Debug, Clone, Copy; X: Cx)]
struct QueryData<X: Cx> {
result: X::Result,
proof_tree: X::ProofTree,
}
use super::{AvailableDepth, Cx, NestedGoals};
use crate::data_structures::HashMap;

struct Success<X: Cx> {
data: X::Tracked<QueryData<X>>,
additional_depth: usize,
nested_goals: NestedGoals<X>,
result: X::Tracked<X::Result>,
}

struct WithOverflow<X: Cx> {
nested_goals: NestedGoals<X>,
result: X::Tracked<X::Result>,
}

/// The cache entry for a given input.
@@ -23,24 +22,15 @@ struct Success<X: Cx> {
#[derive_where(Default; X: Cx)]
struct CacheEntry<X: Cx> {
success: Option<Success<X>>,
/// We have to be careful when caching roots of cycles.
///
/// See the doc comment of `StackEntry::cycle_participants` for more
/// details.
nested_goals: HashSet<X::Input>,
with_overflow: HashMap<usize, X::Tracked<QueryData<X>>>,
with_overflow: HashMap<usize, WithOverflow<X>>,
}

#[derive_where(Debug; X: Cx)]
pub(super) struct CacheData<'a, X: Cx> {
pub(super) result: X::Result,
pub(super) proof_tree: X::ProofTree,
pub(super) additional_depth: usize,
pub(super) encountered_overflow: bool,
// FIXME: This is currently unused, but impacts the design
// by requiring a closure for `Cx::with_global_cache`.
#[allow(dead_code)]
pub(super) nested_goals: &'a HashSet<X::Input>,
pub(super) nested_goals: &'a NestedGoals<X>,
}
#[derive_where(Default; X: Cx)]
pub struct GlobalCache<X: Cx> {
@@ -55,20 +45,21 @@ impl<X: Cx> GlobalCache<X> {
input: X::Input,

result: X::Result,
proof_tree: X::ProofTree,
dep_node: X::DepNodeIndex,

additional_depth: usize,
encountered_overflow: bool,
nested_goals: &HashSet<X::Input>,
nested_goals: NestedGoals<X>,
) {
let data = cx.mk_tracked(QueryData { result, proof_tree }, dep_node);
let result = cx.mk_tracked(result, dep_node);
let entry = self.map.entry(input).or_default();
entry.nested_goals.extend(nested_goals);
if encountered_overflow {
entry.with_overflow.insert(additional_depth, data);
let with_overflow = WithOverflow { nested_goals, result };
let prev = entry.with_overflow.insert(additional_depth, with_overflow);
assert!(prev.is_none());
} else {
entry.success = Some(Success { data, additional_depth });
let prev = entry.success.replace(Success { additional_depth, nested_goals, result });
assert!(prev.is_none());
}
}

@@ -80,36 +71,37 @@ impl<X: Cx> GlobalCache<X> {
&'a self,
cx: X,
input: X::Input,
stack: &IndexVec<StackDepth, StackEntry<X>>,
available_depth: AvailableDepth,
mut candidate_is_applicable: impl FnMut(&NestedGoals<X>) -> bool,
) -> Option<CacheData<'a, X>> {
let entry = self.map.get(&input)?;
if stack.iter().any(|e| entry.nested_goals.contains(&e.input)) {
return None;
}

if let Some(ref success) = entry.success {
if available_depth.cache_entry_is_applicable(success.additional_depth) {
let QueryData { result, proof_tree } = cx.get_tracked(&success.data);
if let Some(Success { additional_depth, ref nested_goals, ref result }) = entry.success {
if available_depth.cache_entry_is_applicable(additional_depth)
&& candidate_is_applicable(nested_goals)
{
return Some(CacheData {
result,
proof_tree,
additional_depth: success.additional_depth,
result: cx.get_tracked(&result),
additional_depth,
encountered_overflow: false,
nested_goals: &entry.nested_goals,
nested_goals,
});
}
}

entry.with_overflow.get(&available_depth.0).map(|e| {
let QueryData { result, proof_tree } = cx.get_tracked(e);
CacheData {
result,
proof_tree,
additional_depth: available_depth.0,
encountered_overflow: true,
nested_goals: &entry.nested_goals,
let additional_depth = available_depth.0;
if let Some(WithOverflow { nested_goals, result }) =
entry.with_overflow.get(&additional_depth)
{
if candidate_is_applicable(nested_goals) {
return Some(CacheData {
result: cx.get_tracked(result),
additional_depth,
encountered_overflow: true,
nested_goals,
});
}
})
}

None
}
}
1,106 changes: 777 additions & 329 deletions compiler/rustc_type_ir/src/search_graph/mod.rs

Large diffs are not rendered by default.

75 changes: 0 additions & 75 deletions compiler/rustc_type_ir/src/search_graph/validate.rs

This file was deleted.

4 changes: 1 addition & 3 deletions compiler/rustc_type_ir/src/solve/inspect.rs
Original file line number Diff line number Diff line change
@@ -69,9 +69,7 @@ pub struct CanonicalGoalEvaluation<I: Interner> {
#[derive_where(PartialEq, Eq, Hash, Debug; I: Interner)]
pub enum CanonicalGoalEvaluationKind<I: Interner> {
Overflow,
CycleInStack,
ProvisionalCacheHit,
Evaluation { final_revision: I::CanonicalGoalEvaluationStepRef },
Evaluation { final_revision: CanonicalGoalEvaluationStep<I> },
}

#[derive_where(PartialEq, Eq, Hash, Debug; I: Interner)]
8 changes: 0 additions & 8 deletions compiler/rustc_type_ir/src/solve/mod.rs
Original file line number Diff line number Diff line change
@@ -340,11 +340,3 @@ impl MaybeCause {
}
}
}

#[derive_where(PartialEq, Eq, Debug; I: Interner)]
pub struct CacheData<I: Interner> {
pub result: QueryResult<I>,
pub proof_tree: Option<I::CanonicalGoalEvaluationStepRef>,
pub additional_depth: usize,
pub encountered_overflow: bool,
}
2 changes: 1 addition & 1 deletion library/core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -193,12 +193,12 @@
//
// Language features:
// tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(asm_const))]
#![cfg_attr(bootstrap, feature(min_exhaustive_patterns))]
#![feature(abi_unadjusted)]
#![feature(adt_const_params)]
#![feature(allow_internal_unsafe)]
#![feature(allow_internal_unstable)]
#![feature(asm_const)]
#![feature(auto_traits)]
#![feature(cfg_sanitize)]
#![feature(cfg_target_has_atomic)]
4 changes: 3 additions & 1 deletion library/core/src/ops/control_flow.rs
Original file line number Diff line number Diff line change
@@ -116,7 +116,9 @@ impl<B, C> ops::Try for ControlFlow<B, C> {
}

#[unstable(feature = "try_trait_v2", issue = "84277")]
impl<B, C> ops::FromResidual for ControlFlow<B, C> {
// Note: manually specifying the residual type instead of using the default to work around
// https://github.com/rust-lang/rust/issues/99940
impl<B, C> ops::FromResidual<ControlFlow<B, convert::Infallible>> for ControlFlow<B, C> {
#[inline]
fn from_residual(residual: ControlFlow<B, convert::Infallible>) -> Self {
match residual {
4 changes: 3 additions & 1 deletion library/core/src/option.rs
Original file line number Diff line number Diff line change
@@ -2495,7 +2495,9 @@ impl<T> ops::Try for Option<T> {
}

#[unstable(feature = "try_trait_v2", issue = "84277")]
impl<T> ops::FromResidual for Option<T> {
// Note: manually specifying the residual type instead of using the default to work around
// https://github.com/rust-lang/rust/issues/99940
impl<T> ops::FromResidual<Option<convert::Infallible>> for Option<T> {
#[inline]
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
1 change: 1 addition & 0 deletions library/core/tests/ops.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod control_flow;
mod from_residual;

use core::ops::{
Bound, Deref, DerefMut, Range, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive,
26 changes: 26 additions & 0 deletions library/core/tests/ops/from_residual.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//! Regression test that Option and ControlFlow can have downstream FromResidual impls.
//! cc https://github.com/rust-lang/rust/issues/99940,
//! This does NOT test that issue in general; Option and ControlFlow's FromResidual
//! impls in core were changed to not be affected by that issue.
use core::ops::{ControlFlow, FromResidual};

struct Local;

impl<T> FromResidual<Local> for Option<T> {
fn from_residual(_: Local) -> Option<T> {
unimplemented!()
}
}

impl<B, C> FromResidual<Local> for ControlFlow<B, C> {
fn from_residual(_: Local) -> ControlFlow<B, C> {
unimplemented!()
}
}

impl<T, E> FromResidual<Local> for Result<T, E> {
fn from_residual(_: Local) -> Result<T, E> {
unimplemented!()
}
}
11 changes: 0 additions & 11 deletions src/doc/unstable-book/src/language-features/asm-const.md

This file was deleted.

1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
@@ -20,6 +20,5 @@ run-make/reproducible-build/Makefile
run-make/rlib-format-packed-bundled-libs/Makefile
run-make/split-debuginfo/Makefile
run-make/symbol-mangling-hashed/Makefile
run-make/sysroot-crates-are-unstable/Makefile
run-make/translation/Makefile
run-make/x86_64-fortanix-unknown-sgx-lvi/Makefile
1 change: 0 additions & 1 deletion tests/assembly/asm/global_asm.rs
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
//@ compile-flags: -C llvm-args=--x86-asm-syntax=intel
//@ compile-flags: -C symbol-mangling-version=v0

#![feature(asm_const)]
#![crate_type = "rlib"]

use std::arch::global_asm;
2 changes: 1 addition & 1 deletion tests/assembly/asm/msp430-types.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
//@ compile-flags: --target msp430-none-elf
//@ needs-llvm-components: msp430

#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch, asm_const)]
#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(non_camel_case_types)]
18 changes: 18 additions & 0 deletions tests/mir-opt/build_correct_coerce.main.built.after.mir
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// MIR for `main` after built

fn main() -> () {
let mut _0: ();
let _1: for<'a> fn(&'a (), &'a ());
scope 1 {
debug x => _1;
}

bb0: {
StorageLive(_1);
_1 = foo as for<'a> fn(&'a (), &'a ()) (PointerCoercion(ReifyFnPointer));
FakeRead(ForLet(None), _1);
_0 = const ();
StorageDead(_1);
return;
}
}
12 changes: 12 additions & 0 deletions tests/mir-opt/build_correct_coerce.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// skip-filecheck

// Validate that we record the target for the `as` coercion as `for<'a> fn(&'a (), &'a ())`,
// and not `for<'a, 'b>(&'a (), &'b ())`. We previously did the latter due to a bug in
// the code that records adjustments in HIR typeck.

fn foo<'a, 'b>(_: &'a (), _: &'b ()) {}

// EMIT_MIR build_correct_coerce.main.built.after.mir
fn main() {
let x = foo as for<'a> fn(&'a (), &'a ());
}
2 changes: 0 additions & 2 deletions tests/run-make/sysroot-crates-are-unstable/Makefile

This file was deleted.

5 changes: 5 additions & 0 deletions tests/run-make/sysroot-crates-are-unstable/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use run_make_support::python_command;

fn main() {
python_command().arg("test.py").run();
}
2 changes: 0 additions & 2 deletions tests/ui/asm/aarch64/bad-reg.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//@ only-aarch64
//@ compile-flags: -C target-feature=+neon

#![feature(asm_const)]

use std::arch::asm;

fn main() {
44 changes: 22 additions & 22 deletions tests/ui/asm/aarch64/bad-reg.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error: invalid register class `foo`: unknown register class
--> $DIR/bad-reg.rs:14:20
--> $DIR/bad-reg.rs:12:20
|
LL | asm!("{}", in(foo) foo);
| ^^^^^^^^^^^

error: invalid register `foo`: unknown register
--> $DIR/bad-reg.rs:16:18
--> $DIR/bad-reg.rs:14:18
|
LL | asm!("", in("foo") foo);
| ^^^^^^^^^^^^^

error: invalid asm template modifier for this register class
--> $DIR/bad-reg.rs:18:15
--> $DIR/bad-reg.rs:16:15
|
LL | asm!("{:z}", in(reg) foo);
| ^^^^ ----------- argument
@@ -21,7 +21,7 @@ LL | asm!("{:z}", in(reg) foo);
= note: the `reg` register class supports the following template modifiers: `w`, `x`

error: invalid asm template modifier for this register class
--> $DIR/bad-reg.rs:20:15
--> $DIR/bad-reg.rs:18:15
|
LL | asm!("{:r}", in(vreg) foo);
| ^^^^ ------------ argument
@@ -31,7 +31,7 @@ LL | asm!("{:r}", in(vreg) foo);
= note: the `vreg` register class supports the following template modifiers: `b`, `h`, `s`, `d`, `q`, `v`

error: invalid asm template modifier for this register class
--> $DIR/bad-reg.rs:22:15
--> $DIR/bad-reg.rs:20:15
|
LL | asm!("{:r}", in(vreg_low16) foo);
| ^^^^ ------------------ argument
@@ -41,117 +41,117 @@ LL | asm!("{:r}", in(vreg_low16) foo);
= note: the `vreg_low16` register class supports the following template modifiers: `b`, `h`, `s`, `d`, `q`, `v`

error: asm template modifiers are not allowed for `const` arguments
--> $DIR/bad-reg.rs:24:15
--> $DIR/bad-reg.rs:22:15
|
LL | asm!("{:a}", const 0);
| ^^^^ ------- argument
| |
| template modifier

error: asm template modifiers are not allowed for `sym` arguments
--> $DIR/bad-reg.rs:26:15
--> $DIR/bad-reg.rs:24:15
|
LL | asm!("{:a}", sym main);
| ^^^^ -------- argument
| |
| template modifier

error: invalid register `x29`: the frame pointer cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:28:18
--> $DIR/bad-reg.rs:26:18
|
LL | asm!("", in("x29") foo);
| ^^^^^^^^^^^^^

error: invalid register `sp`: the stack pointer cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:30:18
--> $DIR/bad-reg.rs:28:18
|
LL | asm!("", in("sp") foo);
| ^^^^^^^^^^^^

error: invalid register `xzr`: the zero register cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:32:18
--> $DIR/bad-reg.rs:30:18
|
LL | asm!("", in("xzr") foo);
| ^^^^^^^^^^^^^

error: invalid register `x19`: x19 is used internally by LLVM and cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:34:18
--> $DIR/bad-reg.rs:32:18
|
LL | asm!("", in("x19") foo);
| ^^^^^^^^^^^^^

error: register class `preg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:37:18
--> $DIR/bad-reg.rs:35:18
|
LL | asm!("", in("p0") foo);
| ^^^^^^^^^^^^

error: register class `preg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:41:20
--> $DIR/bad-reg.rs:39:20
|
LL | asm!("{}", in(preg) foo);
| ^^^^^^^^^^^^

error: register class `preg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:44:20
--> $DIR/bad-reg.rs:42:20
|
LL | asm!("{}", out(preg) _);
| ^^^^^^^^^^^

error: register `w0` conflicts with register `x0`
--> $DIR/bad-reg.rs:50:32
--> $DIR/bad-reg.rs:48:32
|
LL | asm!("", in("x0") foo, in("w0") bar);
| ------------ ^^^^^^^^^^^^ register `w0`
| |
| register `x0`

error: register `x0` conflicts with register `x0`
--> $DIR/bad-reg.rs:52:32
--> $DIR/bad-reg.rs:50:32
|
LL | asm!("", in("x0") foo, out("x0") bar);
| ------------ ^^^^^^^^^^^^^ register `x0`
| |
| register `x0`
|
help: use `lateout` instead of `out` to avoid conflict
--> $DIR/bad-reg.rs:52:18
--> $DIR/bad-reg.rs:50:18
|
LL | asm!("", in("x0") foo, out("x0") bar);
| ^^^^^^^^^^^^

error: register `q0` conflicts with register `v0`
--> $DIR/bad-reg.rs:55:32
--> $DIR/bad-reg.rs:53:32
|
LL | asm!("", in("v0") foo, in("q0") bar);
| ------------ ^^^^^^^^^^^^ register `q0`
| |
| register `v0`

error: register `q0` conflicts with register `v0`
--> $DIR/bad-reg.rs:57:32
--> $DIR/bad-reg.rs:55:32
|
LL | asm!("", in("v0") foo, out("q0") bar);
| ------------ ^^^^^^^^^^^^^ register `q0`
| |
| register `v0`
|
help: use `lateout` instead of `out` to avoid conflict
--> $DIR/bad-reg.rs:57:18
--> $DIR/bad-reg.rs:55:18
|
LL | asm!("", in("v0") foo, out("q0") bar);
| ^^^^^^^^^^^^

error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:37:27
--> $DIR/bad-reg.rs:35:27
|
LL | asm!("", in("p0") foo);
| ^^^
|
= note: register class `preg` supports these types:

error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:41:29
--> $DIR/bad-reg.rs:39:29
|
LL | asm!("{}", in(preg) foo);
| ^^^
2 changes: 0 additions & 2 deletions tests/ui/asm/aarch64/const.rs
Original file line number Diff line number Diff line change
@@ -2,8 +2,6 @@
//@ run-pass
//@ needs-asm-support

#![feature(asm_const)]

use std::arch::{asm, global_asm};

fn const_generic<const X: usize>() -> usize {
2 changes: 0 additions & 2 deletions tests/ui/asm/aarch64/parse-error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//@ only-aarch64

#![feature(asm_const)]

use std::arch::{asm, global_asm};

fn main() {
118 changes: 59 additions & 59 deletions tests/ui/asm/aarch64/parse-error.stderr

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/ui/asm/aarch64/type-check-3.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@ only-aarch64
//@ compile-flags: -C target-feature=+neon

#![feature(repr_simd, asm_const)]
#![feature(repr_simd)]

use std::arch::aarch64::float64x2_t;
use std::arch::{asm, global_asm};
5 changes: 2 additions & 3 deletions tests/ui/asm/aarch64/type-check-4.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@ only-aarch64
//@ compile-flags: -C target-feature=+neon

#![feature(repr_simd, asm_const)]
#![feature(repr_simd)]

use std::arch::aarch64::float64x2_t;
use std::arch::{asm, global_asm};
@@ -10,8 +10,7 @@ use std::arch::{asm, global_asm};
#[derive(Copy, Clone)]
struct Simd256bit(f64, f64, f64, f64);

fn main() {
}
fn main() {}

// Constants must be... constant

6 changes: 3 additions & 3 deletions tests/ui/asm/aarch64/type-check-4.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: referencing statics in constants is unstable
--> $DIR/type-check-4.rs:25:25
--> $DIR/type-check-4.rs:24:25
|
LL | global_asm!("{}", const S);
| ^
@@ -11,7 +11,7 @@ LL | global_asm!("{}", const S);
= help: to fix this, the value can be extracted to a `const` and then used.

error[E0658]: referencing statics in constants is unstable
--> $DIR/type-check-4.rs:28:35
--> $DIR/type-check-4.rs:27:35
|
LL | global_asm!("{}", const const_foo(S));
| ^
@@ -23,7 +23,7 @@ LL | global_asm!("{}", const const_foo(S));
= help: to fix this, the value can be extracted to a `const` and then used.

error[E0658]: referencing statics in constants is unstable
--> $DIR/type-check-4.rs:31:35
--> $DIR/type-check-4.rs:30:35
|
LL | global_asm!("{}", const const_bar(S));
| ^
2 changes: 1 addition & 1 deletion tests/ui/asm/bad-template.rs
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
//@ [x86_64] needs-llvm-components: x86
//@ [aarch64] needs-llvm-components: aarch64

#![feature(no_core, lang_items, rustc_attrs, asm_const)]
#![feature(no_core, lang_items, rustc_attrs)]
#![no_core]

#[rustc_builtin_macro]
8 changes: 4 additions & 4 deletions tests/ui/asm/const-error.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//@ only-x86_64
//@ needs-asm-support

#![feature(asm_const)]

// Test to make sure that we emit const errors eagerly for inline asm

use std::arch::asm;

fn test<T>() {
unsafe { asm!("/* {} */", const 1 / 0); }
//~^ ERROR evaluation of
unsafe {
asm!("/* {} */", const 1 / 0);
//~^ ERROR evaluation of
}
}

fn main() {}
6 changes: 3 additions & 3 deletions tests/ui/asm/const-error.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0080]: evaluation of `test::<T>::{constant#0}` failed
--> $DIR/const-error.rs:11:37
--> $DIR/const-error.rs:10:32
|
LL | unsafe { asm!("/* {} */", const 1 / 0); }
| ^^^^^ attempt to divide `1_i32` by zero
LL | asm!("/* {} */", const 1 / 0);
| ^^^^^ attempt to divide `1_i32` by zero

error: aborting due to 1 previous error

1 change: 0 additions & 1 deletion tests/ui/asm/fail-const-eval-issue-121099.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@ build-fail
//@ needs-asm-support
#![feature(asm_const)]

use std::arch::global_asm;

4 changes: 2 additions & 2 deletions tests/ui/asm/fail-const-eval-issue-121099.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0080]: evaluation of constant value failed
--> $DIR/fail-const-eval-issue-121099.rs:9:31
--> $DIR/fail-const-eval-issue-121099.rs:8:31
|
LL | global_asm!("/* {} */", const 1 << 500);
| ^^^^^^^^ attempt to shift left by `500_i32`, which would overflow

error[E0080]: evaluation of constant value failed
--> $DIR/fail-const-eval-issue-121099.rs:11:31
--> $DIR/fail-const-eval-issue-121099.rs:10:31
|
LL | global_asm!("/* {} */", const 1 / 0);
| ^^^^^ attempt to divide `1_i32` by zero
2 changes: 0 additions & 2 deletions tests/ui/asm/generic-const.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//@ needs-asm-support
//@ build-pass

#![feature(asm_const)]

use std::arch::asm;

fn foofoo<const N: usize>() {}
2 changes: 0 additions & 2 deletions tests/ui/asm/invalid-const-operand.rs
Original file line number Diff line number Diff line change
@@ -2,8 +2,6 @@
//@ ignore-nvptx64
//@ ignore-spirv

#![feature(asm_const)]

use std::arch::{asm, global_asm};

// Const operands must be integers and must be constants.
16 changes: 8 additions & 8 deletions tests/ui/asm/invalid-const-operand.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/invalid-const-operand.rs:42:26
--> $DIR/invalid-const-operand.rs:40:26
|
LL | asm!("{}", const x);
| ^ non-constant value
@@ -10,7 +10,7 @@ LL | const x: /* Type */ = 0;
| ~~~~~ ++++++++++++

error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/invalid-const-operand.rs:45:36
--> $DIR/invalid-const-operand.rs:43:36
|
LL | asm!("{}", const const_foo(x));
| ^ non-constant value
@@ -21,7 +21,7 @@ LL | const x: /* Type */ = 0;
| ~~~~~ ++++++++++++

error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/invalid-const-operand.rs:48:36
--> $DIR/invalid-const-operand.rs:46:36
|
LL | asm!("{}", const const_bar(x));
| ^ non-constant value
@@ -32,7 +32,7 @@ LL | const x: /* Type */ = 0;
| ~~~~~ ++++++++++++

error: invalid type for `const` operand
--> $DIR/invalid-const-operand.rs:14:19
--> $DIR/invalid-const-operand.rs:12:19
|
LL | global_asm!("{}", const 0f32);
| ^^^^^^----
@@ -42,7 +42,7 @@ LL | global_asm!("{}", const 0f32);
= help: `const` operands must be of an integer type

error: invalid type for `const` operand
--> $DIR/invalid-const-operand.rs:16:19
--> $DIR/invalid-const-operand.rs:14:19
|
LL | global_asm!("{}", const 0 as *mut u8);
| ^^^^^^------------
@@ -52,7 +52,7 @@ LL | global_asm!("{}", const 0 as *mut u8);
= help: `const` operands must be of an integer type

error: invalid type for `const` operand
--> $DIR/invalid-const-operand.rs:26:20
--> $DIR/invalid-const-operand.rs:24:20
|
LL | asm!("{}", const 0f32);
| ^^^^^^----
@@ -62,7 +62,7 @@ LL | asm!("{}", const 0f32);
= help: `const` operands must be of an integer type

error: invalid type for `const` operand
--> $DIR/invalid-const-operand.rs:28:20
--> $DIR/invalid-const-operand.rs:26:20
|
LL | asm!("{}", const 0 as *mut u8);
| ^^^^^^------------
@@ -72,7 +72,7 @@ LL | asm!("{}", const 0 as *mut u8);
= help: `const` operands must be of an integer type

error: invalid type for `const` operand
--> $DIR/invalid-const-operand.rs:30:20
--> $DIR/invalid-const-operand.rs:28:20
|
LL | asm!("{}", const &0);
| ^^^^^^--
2 changes: 1 addition & 1 deletion tests/ui/asm/naked-functions.rs
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
//@ ignore-spirv

#![feature(naked_functions)]
#![feature(asm_const, asm_unwind, linkage)]
#![feature(asm_unwind, linkage)]
#![crate_type = "lib"]

use std::arch::asm;
6 changes: 4 additions & 2 deletions tests/ui/asm/named-asm-labels.rs
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
// which causes less readable LLVM errors and in the worst cases causes ICEs
// or segfaults based on system dependent behavior and codegen flags.

#![feature(naked_functions, asm_const)]
#![feature(naked_functions)]

use std::arch::{asm, global_asm};

@@ -128,6 +128,7 @@ fn main() {

// Tests usage of colons in non-label positions
asm!(":lo12:FOO"); // this is apparently valid aarch64

// is there an example that is valid x86 for this test?
asm!(":bbb nop");

@@ -176,7 +177,8 @@ fn main() {
// label or LTO can cause labels to break
#[naked]
pub extern "C" fn foo() -> i32 {
unsafe { asm!(".Lfoo: mov rax, {}; ret;", "nop", const 1, options(noreturn)) } //~ ERROR avoid using named labels
unsafe { asm!(".Lfoo: mov rax, {}; ret;", "nop", const 1, options(noreturn)) }
//~^ ERROR avoid using named labels
}

// Make sure that non-naked attributes *do* still let the lint happen
44 changes: 22 additions & 22 deletions tests/ui/asm/named-asm-labels.stderr
Original file line number Diff line number Diff line change
@@ -328,7 +328,7 @@ LL | ab: nop // ab: does foo
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information

error: avoid using named labels in inline assembly
--> $DIR/named-asm-labels.rs:143:19
--> $DIR/named-asm-labels.rs:144:19
|
LL | asm!("test_{}: nop", in(reg) 10);
| ^^^^^^^
@@ -338,7 +338,7 @@ LL | asm!("test_{}: nop", in(reg) 10);
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information

error: avoid using named labels in inline assembly
--> $DIR/named-asm-labels.rs:145:15
--> $DIR/named-asm-labels.rs:146:15
|
LL | asm!("test_{}: nop", const 10);
| ^^^^^^^
@@ -348,7 +348,7 @@ LL | asm!("test_{}: nop", const 10);
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information

error: avoid using named labels in inline assembly
--> $DIR/named-asm-labels.rs:146:15
--> $DIR/named-asm-labels.rs:147:15
|
LL | asm!("test_{}: nop", sym main);
| ^^^^^^^
@@ -358,7 +358,7 @@ LL | asm!("test_{}: nop", sym main);
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information

error: avoid using named labels in inline assembly
--> $DIR/named-asm-labels.rs:147:15
--> $DIR/named-asm-labels.rs:148:15
|
LL | asm!("{}_test: nop", const 10);
| ^^^^^^^
@@ -368,7 +368,7 @@ LL | asm!("{}_test: nop", const 10);
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information

error: avoid using named labels in inline assembly
--> $DIR/named-asm-labels.rs:148:15
--> $DIR/named-asm-labels.rs:149:15
|
LL | asm!("test_{}_test: nop", const 10);
| ^^^^^^^^^^^^
@@ -378,7 +378,7 @@ LL | asm!("test_{}_test: nop", const 10);
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information

error: avoid using named labels in inline assembly
--> $DIR/named-asm-labels.rs:149:15
--> $DIR/named-asm-labels.rs:150:15
|
LL | asm!("{}: nop", const 10);
| ^^
@@ -388,7 +388,7 @@ LL | asm!("{}: nop", const 10);
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information

error: avoid using named labels in inline assembly
--> $DIR/named-asm-labels.rs:151:15
--> $DIR/named-asm-labels.rs:152:15
|
LL | asm!("{uwu}: nop", uwu = const 10);
| ^^^^^
@@ -398,7 +398,7 @@ LL | asm!("{uwu}: nop", uwu = const 10);
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information

error: avoid using named labels in inline assembly
--> $DIR/named-asm-labels.rs:152:15
--> $DIR/named-asm-labels.rs:153:15
|
LL | asm!("{0}: nop", const 10);
| ^^^
@@ -408,7 +408,7 @@ LL | asm!("{0}: nop", const 10);
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information

error: avoid using named labels in inline assembly
--> $DIR/named-asm-labels.rs:153:15
--> $DIR/named-asm-labels.rs:154:15
|
LL | asm!("{1}: nop", "/* {0} */", const 10, const 20);
| ^^^
@@ -418,7 +418,7 @@ LL | asm!("{1}: nop", "/* {0} */", const 10, const 20);
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information

error: avoid using named labels in inline assembly
--> $DIR/named-asm-labels.rs:156:14
--> $DIR/named-asm-labels.rs:157:14
|
LL | asm!(include_str!("named-asm-labels.s"));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -428,7 +428,7 @@ LL | asm!(include_str!("named-asm-labels.s"));
= note: the label may be declared in the expansion of a macro

error: avoid using named labels in inline assembly
--> $DIR/named-asm-labels.rs:156:14
--> $DIR/named-asm-labels.rs:157:14
|
LL | asm!(include_str!("named-asm-labels.s"));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -439,7 +439,7 @@ LL | asm!(include_str!("named-asm-labels.s"));
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: avoid using named labels in inline assembly
--> $DIR/named-asm-labels.rs:156:14
--> $DIR/named-asm-labels.rs:157:14
|
LL | asm!(include_str!("named-asm-labels.s"));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -450,7 +450,7 @@ LL | asm!(include_str!("named-asm-labels.s"));
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: avoid using named labels in inline assembly
--> $DIR/named-asm-labels.rs:156:14
--> $DIR/named-asm-labels.rs:157:14
|
LL | asm!(include_str!("named-asm-labels.s"));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -461,21 +461,21 @@ LL | asm!(include_str!("named-asm-labels.s"));
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

warning: avoid using named labels in inline assembly
--> $DIR/named-asm-labels.rs:170:19
--> $DIR/named-asm-labels.rs:171:19
|
LL | asm!("warned: nop");
| ^^^^^^
|
= help: only local labels of the form `<number>:` should be used in inline asm
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
note: the lint level is defined here
--> $DIR/named-asm-labels.rs:168:16
--> $DIR/named-asm-labels.rs:169:16
|
LL | #[warn(named_asm_labels)]
| ^^^^^^^^^^^^^^^^

error: avoid using named labels in inline assembly
--> $DIR/named-asm-labels.rs:179:20
--> $DIR/named-asm-labels.rs:180:20
|
LL | unsafe { asm!(".Lfoo: mov rax, {}; ret;", "nop", const 1, options(noreturn)) }
| ^^^^^
@@ -484,7 +484,7 @@ LL | unsafe { asm!(".Lfoo: mov rax, {}; ret;", "nop", const 1, options(noret
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information

error: avoid using named labels in inline assembly
--> $DIR/named-asm-labels.rs:185:20
--> $DIR/named-asm-labels.rs:187:20
|
LL | unsafe { asm!(".Lbar: mov rax, {}; ret;", "nop", const 1, options(noreturn)) }
| ^^^^^
@@ -493,7 +493,7 @@ LL | unsafe { asm!(".Lbar: mov rax, {}; ret;", "nop", const 1, options(noret
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information

error: avoid using named labels in inline assembly
--> $DIR/named-asm-labels.rs:193:20
--> $DIR/named-asm-labels.rs:195:20
|
LL | unsafe { asm!(".Laaa: nop; ret;", options(noreturn)) }
| ^^^^^
@@ -502,7 +502,7 @@ LL | unsafe { asm!(".Laaa: nop; ret;", options(noreturn)) }
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information

error: avoid using named labels in inline assembly
--> $DIR/named-asm-labels.rs:203:24
--> $DIR/named-asm-labels.rs:205:24
|
LL | unsafe { asm!(".Lbbb: nop; ret;", options(noreturn)) }
| ^^^^^
@@ -511,7 +511,7 @@ LL | unsafe { asm!(".Lbbb: nop; ret;", options(noreturn)) }
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information

error: avoid using named labels in inline assembly
--> $DIR/named-asm-labels.rs:212:15
--> $DIR/named-asm-labels.rs:214:15
|
LL | asm!("closure1: nop");
| ^^^^^^^^
@@ -520,7 +520,7 @@ LL | asm!("closure1: nop");
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information

error: avoid using named labels in inline assembly
--> $DIR/named-asm-labels.rs:216:15
--> $DIR/named-asm-labels.rs:218:15
|
LL | asm!("closure2: nop");
| ^^^^^^^^
@@ -529,7 +529,7 @@ LL | asm!("closure2: nop");
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information

error: avoid using named labels in inline assembly
--> $DIR/named-asm-labels.rs:226:19
--> $DIR/named-asm-labels.rs:228:19
|
LL | asm!("closure3: nop");
| ^^^^^^^^
2 changes: 0 additions & 2 deletions tests/ui/asm/parse-error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//@ needs-asm-support

#![feature(asm_const)]

use std::arch::{asm, global_asm};

fn main() {
144 changes: 72 additions & 72 deletions tests/ui/asm/parse-error.stderr

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions tests/ui/asm/type-check-1.rs
Original file line number Diff line number Diff line change
@@ -2,8 +2,6 @@
//@ ignore-nvptx64
//@ ignore-spirv

#![feature(asm_const)]

use std::arch::{asm, global_asm};

fn main() {
16 changes: 8 additions & 8 deletions tests/ui/asm/type-check-1.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error: invalid asm output
--> $DIR/type-check-1.rs:14:29
--> $DIR/type-check-1.rs:12:29
|
LL | asm!("{}", out(reg) 1 + 2);
| ^^^^^ cannot assign to this expression

error: invalid asm output
--> $DIR/type-check-1.rs:16:31
--> $DIR/type-check-1.rs:14:31
|
LL | asm!("{}", inout(reg) 1 + 2);
| ^^^^^ cannot assign to this expression

error[E0277]: the size for values of type `[u64]` cannot be known at compilation time
--> $DIR/type-check-1.rs:22:28
--> $DIR/type-check-1.rs:20:28
|
LL | asm!("{}", in(reg) v[..]);
| ^^^^^ doesn't have a size known at compile-time
@@ -20,7 +20,7 @@ LL | asm!("{}", in(reg) v[..]);
= note: all inline asm arguments must have a statically known size

error[E0277]: the size for values of type `[u64]` cannot be known at compilation time
--> $DIR/type-check-1.rs:25:29
--> $DIR/type-check-1.rs:23:29
|
LL | asm!("{}", out(reg) v[..]);
| ^^^^^ doesn't have a size known at compile-time
@@ -29,7 +29,7 @@ LL | asm!("{}", out(reg) v[..]);
= note: all inline asm arguments must have a statically known size

error[E0277]: the size for values of type `[u64]` cannot be known at compilation time
--> $DIR/type-check-1.rs:28:31
--> $DIR/type-check-1.rs:26:31
|
LL | asm!("{}", inout(reg) v[..]);
| ^^^^^ doesn't have a size known at compile-time
@@ -38,23 +38,23 @@ LL | asm!("{}", inout(reg) v[..]);
= note: all inline asm arguments must have a statically known size

error: cannot use value of type `[u64]` for inline assembly
--> $DIR/type-check-1.rs:22:28
--> $DIR/type-check-1.rs:20:28
|
LL | asm!("{}", in(reg) v[..]);
| ^^^^^
|
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly

error: cannot use value of type `[u64]` for inline assembly
--> $DIR/type-check-1.rs:25:29
--> $DIR/type-check-1.rs:23:29
|
LL | asm!("{}", out(reg) v[..]);
| ^^^^^
|
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly

error: cannot use value of type `[u64]` for inline assembly
--> $DIR/type-check-1.rs:28:31
--> $DIR/type-check-1.rs:26:31
|
LL | asm!("{}", inout(reg) v[..]);
| ^^^^^
2 changes: 0 additions & 2 deletions tests/ui/asm/x86_64/bad-reg.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//@ only-x86_64
//@ compile-flags: -C target-feature=+avx2

#![feature(asm_const)]

use std::arch::asm;

fn main() {
60 changes: 30 additions & 30 deletions tests/ui/asm/x86_64/bad-reg.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error: invalid register class `foo`: unknown register class
--> $DIR/bad-reg.rs:14:20
--> $DIR/bad-reg.rs:12:20
|
LL | asm!("{}", in(foo) foo);
| ^^^^^^^^^^^

error: invalid register `foo`: unknown register
--> $DIR/bad-reg.rs:16:18
--> $DIR/bad-reg.rs:14:18
|
LL | asm!("", in("foo") foo);
| ^^^^^^^^^^^^^

error: invalid asm template modifier for this register class
--> $DIR/bad-reg.rs:18:15
--> $DIR/bad-reg.rs:16:15
|
LL | asm!("{:z}", in(reg) foo);
| ^^^^ ----------- argument
@@ -21,7 +21,7 @@ LL | asm!("{:z}", in(reg) foo);
= note: the `reg` register class supports the following template modifiers: `l`, `x`, `e`, `r`

error: invalid asm template modifier for this register class
--> $DIR/bad-reg.rs:20:15
--> $DIR/bad-reg.rs:18:15
|
LL | asm!("{:r}", in(xmm_reg) foo);
| ^^^^ --------------- argument
@@ -31,183 +31,183 @@ LL | asm!("{:r}", in(xmm_reg) foo);
= note: the `xmm_reg` register class supports the following template modifiers: `x`, `y`, `z`

error: asm template modifiers are not allowed for `const` arguments
--> $DIR/bad-reg.rs:22:15
--> $DIR/bad-reg.rs:20:15
|
LL | asm!("{:a}", const 0);
| ^^^^ ------- argument
| |
| template modifier

error: asm template modifiers are not allowed for `sym` arguments
--> $DIR/bad-reg.rs:24:15
--> $DIR/bad-reg.rs:22:15
|
LL | asm!("{:a}", sym main);
| ^^^^ -------- argument
| |
| template modifier

error: invalid register `ebp`: the frame pointer cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:26:18
--> $DIR/bad-reg.rs:24:18
|
LL | asm!("", in("ebp") foo);
| ^^^^^^^^^^^^^

error: invalid register `rsp`: the stack pointer cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:28:18
--> $DIR/bad-reg.rs:26:18
|
LL | asm!("", in("rsp") foo);
| ^^^^^^^^^^^^^

error: invalid register `ip`: the instruction pointer cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:30:18
--> $DIR/bad-reg.rs:28:18
|
LL | asm!("", in("ip") foo);
| ^^^^^^^^^^^^

error: register class `x87_reg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:33:18
--> $DIR/bad-reg.rs:31:18
|
LL | asm!("", in("st(2)") foo);
| ^^^^^^^^^^^^^^^

error: register class `mmx_reg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:36:18
--> $DIR/bad-reg.rs:34:18
|
LL | asm!("", in("mm0") foo);
| ^^^^^^^^^^^^^

error: register class `kreg0` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:39:18
--> $DIR/bad-reg.rs:37:18
|
LL | asm!("", in("k0") foo);
| ^^^^^^^^^^^^

error: register class `x87_reg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:44:20
--> $DIR/bad-reg.rs:42:20
|
LL | asm!("{}", in(x87_reg) foo);
| ^^^^^^^^^^^^^^^

error: register class `mmx_reg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:47:20
--> $DIR/bad-reg.rs:45:20
|
LL | asm!("{}", in(mmx_reg) foo);
| ^^^^^^^^^^^^^^^

error: register class `x87_reg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:50:20
--> $DIR/bad-reg.rs:48:20
|
LL | asm!("{}", out(x87_reg) _);
| ^^^^^^^^^^^^^^

error: register class `mmx_reg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:52:20
--> $DIR/bad-reg.rs:50:20
|
LL | asm!("{}", out(mmx_reg) _);
| ^^^^^^^^^^^^^^

error: register `al` conflicts with register `eax`
--> $DIR/bad-reg.rs:58:33
--> $DIR/bad-reg.rs:56:33
|
LL | asm!("", in("eax") foo, in("al") bar);
| ------------- ^^^^^^^^^^^^ register `al`
| |
| register `eax`

error: register `rax` conflicts with register `rax`
--> $DIR/bad-reg.rs:61:33
--> $DIR/bad-reg.rs:59:33
|
LL | asm!("", in("rax") foo, out("rax") bar);
| ------------- ^^^^^^^^^^^^^^ register `rax`
| |
| register `rax`
|
help: use `lateout` instead of `out` to avoid conflict
--> $DIR/bad-reg.rs:61:18
--> $DIR/bad-reg.rs:59:18
|
LL | asm!("", in("rax") foo, out("rax") bar);
| ^^^^^^^^^^^^^

error: register `ymm0` conflicts with register `xmm0`
--> $DIR/bad-reg.rs:66:34
--> $DIR/bad-reg.rs:64:34
|
LL | asm!("", in("xmm0") foo, in("ymm0") bar);
| -------------- ^^^^^^^^^^^^^^ register `ymm0`
| |
| register `xmm0`

error: register `ymm0` conflicts with register `xmm0`
--> $DIR/bad-reg.rs:68:34
--> $DIR/bad-reg.rs:66:34
|
LL | asm!("", in("xmm0") foo, out("ymm0") bar);
| -------------- ^^^^^^^^^^^^^^^ register `ymm0`
| |
| register `xmm0`
|
help: use `lateout` instead of `out` to avoid conflict
--> $DIR/bad-reg.rs:68:18
--> $DIR/bad-reg.rs:66:18
|
LL | asm!("", in("xmm0") foo, out("ymm0") bar);
| ^^^^^^^^^^^^^^

error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:33:30
--> $DIR/bad-reg.rs:31:30
|
LL | asm!("", in("st(2)") foo);
| ^^^
|
= note: register class `x87_reg` supports these types:

error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:36:28
--> $DIR/bad-reg.rs:34:28
|
LL | asm!("", in("mm0") foo);
| ^^^
|
= note: register class `mmx_reg` supports these types:

error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:39:27
--> $DIR/bad-reg.rs:37:27
|
LL | asm!("", in("k0") foo);
| ^^^
|
= note: register class `kreg0` supports these types:

error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:44:32
--> $DIR/bad-reg.rs:42:32
|
LL | asm!("{}", in(x87_reg) foo);
| ^^^
|
= note: register class `x87_reg` supports these types:

error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:47:32
--> $DIR/bad-reg.rs:45:32
|
LL | asm!("{}", in(mmx_reg) foo);
| ^^^
|
= note: register class `mmx_reg` supports these types:

error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:58:42
--> $DIR/bad-reg.rs:56:42
|
LL | asm!("", in("eax") foo, in("al") bar);
| ^^^
|
= note: register class `reg_byte` supports these types: i8

error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:63:27
--> $DIR/bad-reg.rs:61:27
|
LL | asm!("", in("al") foo, lateout("al") bar);
| ^^^
|
= note: register class `reg_byte` supports these types: i8

error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:63:46
--> $DIR/bad-reg.rs:61:46
|
LL | asm!("", in("al") foo, lateout("al") bar);
| ^^^
2 changes: 0 additions & 2 deletions tests/ui/asm/x86_64/const.rs
Original file line number Diff line number Diff line change
@@ -2,8 +2,6 @@
//@ run-pass
//@ needs-asm-support

#![feature(asm_const)]

use std::arch::{asm, global_asm};

fn const_generic<const X: usize>() -> usize {
2 changes: 0 additions & 2 deletions tests/ui/asm/x86_64/type-check-3.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//@ only-x86_64
//@ compile-flags: -C target-feature=+avx512f

#![feature(asm_const)]

use std::arch::{asm, global_asm};

use std::arch::x86_64::{_mm256_setzero_ps, _mm_setzero_ps};
26 changes: 13 additions & 13 deletions tests/ui/asm/x86_64/type-check-3.stderr
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
error: type `i128` cannot be used with this register class
--> $DIR/type-check-3.rs:14:28
--> $DIR/type-check-3.rs:12:28
|
LL | asm!("{}", in(reg) 0i128);
| ^^^^^
|
= note: register class `reg` supports these types: i16, i32, i64, f16, f32, f64

error: type `__m128` cannot be used with this register class
--> $DIR/type-check-3.rs:16:28
--> $DIR/type-check-3.rs:14:28
|
LL | asm!("{}", in(reg) _mm_setzero_ps());
| ^^^^^^^^^^^^^^^^
|
= note: register class `reg` supports these types: i16, i32, i64, f16, f32, f64

error: type `__m256` cannot be used with this register class
--> $DIR/type-check-3.rs:18:28
--> $DIR/type-check-3.rs:16:28
|
LL | asm!("{}", in(reg) _mm256_setzero_ps());
| ^^^^^^^^^^^^^^^^^^^
|
= note: register class `reg` supports these types: i16, i32, i64, f16, f32, f64

error: type `u8` cannot be used with this register class
--> $DIR/type-check-3.rs:20:32
--> $DIR/type-check-3.rs:18:32
|
LL | asm!("{}", in(xmm_reg) 0u8);
| ^^^
|
= note: register class `xmm_reg` supports these types: i32, i64, f16, f32, f64, f128, i8x16, i16x8, i32x4, i64x2, f16x8, f32x4, f64x2

error: `avx512bw` target feature is not enabled
--> $DIR/type-check-3.rs:29:29
--> $DIR/type-check-3.rs:27:29
|
LL | asm!("{}", in(kreg) 0u64);
| ^^^^
|
= note: this is required to use type `u64` with register class `kreg`

warning: formatting may not be suitable for sub-register argument
--> $DIR/type-check-3.rs:34:15
--> $DIR/type-check-3.rs:32:15
|
LL | asm!("{0} {0}", in(reg) 0i16);
| ^^^ ^^^ ---- for this argument
@@ -49,7 +49,7 @@ LL | asm!("{0} {0}", in(reg) 0i16);
= note: `#[warn(asm_sub_register)]` on by default

warning: formatting may not be suitable for sub-register argument
--> $DIR/type-check-3.rs:36:15
--> $DIR/type-check-3.rs:34:15
|
LL | asm!("{0} {0:x}", in(reg) 0i16);
| ^^^ ---- for this argument
@@ -58,7 +58,7 @@ LL | asm!("{0} {0:x}", in(reg) 0i16);
= help: or use `{0:r}` to keep the default formatting of `rax` (for 64-bit values)

warning: formatting may not be suitable for sub-register argument
--> $DIR/type-check-3.rs:38:15
--> $DIR/type-check-3.rs:36:15
|
LL | asm!("{}", in(reg) 0i32);
| ^^ ---- for this argument
@@ -67,7 +67,7 @@ LL | asm!("{}", in(reg) 0i32);
= help: or use `{0:r}` to keep the default formatting of `rax` (for 64-bit values)

warning: formatting may not be suitable for sub-register argument
--> $DIR/type-check-3.rs:41:15
--> $DIR/type-check-3.rs:39:15
|
LL | asm!("{}", in(ymm_reg) 0i64);
| ^^ ---- for this argument
@@ -76,7 +76,7 @@ LL | asm!("{}", in(ymm_reg) 0i64);
= help: or use `{0:y}` to keep the default formatting of `ymm0` (for 256-bit values)

error: type `i8` cannot be used with this register class
--> $DIR/type-check-3.rs:52:28
--> $DIR/type-check-3.rs:50:28
|
LL | asm!("{}", in(reg) 0i8);
| ^^^
@@ -85,7 +85,7 @@ LL | asm!("{}", in(reg) 0i8);
= help: consider using the `reg_byte` register class instead

error: incompatible types for asm inout argument
--> $DIR/type-check-3.rs:64:33
--> $DIR/type-check-3.rs:62:33
|
LL | asm!("{:r}", inout(reg) 0u32 => val_f32);
| ^^^^ ^^^^^^^ type `f32`
@@ -95,7 +95,7 @@ LL | asm!("{:r}", inout(reg) 0u32 => val_f32);
= note: asm inout arguments must have the same type, unless they are both pointers or integers of the same size

error: incompatible types for asm inout argument
--> $DIR/type-check-3.rs:66:33
--> $DIR/type-check-3.rs:64:33
|
LL | asm!("{:r}", inout(reg) 0u32 => val_ptr);
| ^^^^ ^^^^^^^ type `*mut u8`
@@ -105,7 +105,7 @@ LL | asm!("{:r}", inout(reg) 0u32 => val_ptr);
= note: asm inout arguments must have the same type, unless they are both pointers or integers of the same size

error: incompatible types for asm inout argument
--> $DIR/type-check-3.rs:68:33
--> $DIR/type-check-3.rs:66:33
|
LL | asm!("{:r}", inout(reg) main => val_u32);
| ^^^^ ^^^^^^^ type `u32`
2 changes: 0 additions & 2 deletions tests/ui/asm/x86_64/type-check-4.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//@ only-x86_64
//@ compile-flags: -C target-feature=+avx512f

#![feature(asm_const)]

use std::arch::{asm, global_asm};

use std::arch::x86_64::{_mm256_setzero_ps, _mm_setzero_ps};
6 changes: 3 additions & 3 deletions tests/ui/asm/x86_64/type-check-4.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: referencing statics in constants is unstable
--> $DIR/type-check-4.rs:21:25
--> $DIR/type-check-4.rs:19:25
|
LL | global_asm!("{}", const S);
| ^
@@ -11,7 +11,7 @@ LL | global_asm!("{}", const S);
= help: to fix this, the value can be extracted to a `const` and then used.

error[E0658]: referencing statics in constants is unstable
--> $DIR/type-check-4.rs:24:35
--> $DIR/type-check-4.rs:22:35
|
LL | global_asm!("{}", const const_foo(S));
| ^
@@ -23,7 +23,7 @@ LL | global_asm!("{}", const const_foo(S));
= help: to fix this, the value can be extracted to a `const` and then used.

error[E0658]: referencing statics in constants is unstable
--> $DIR/type-check-4.rs:27:35
--> $DIR/type-check-4.rs:25:35
|
LL | global_asm!("{}", const const_bar(S));
| ^
2 changes: 0 additions & 2 deletions tests/ui/asm/x86_64/x86_64_parse_error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//@ only-x86_64

#![feature(asm_const)]

use std::arch::asm;

fn main() {
10 changes: 5 additions & 5 deletions tests/ui/asm/x86_64/x86_64_parse_error.stderr
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
error: explicit register arguments cannot have names
--> $DIR/x86_64_parse_error.rs:11:18
--> $DIR/x86_64_parse_error.rs:9:18
|
LL | asm!("", a = in("eax") foo);
| ^^^^^^^^^^^^^^^^^

error: positional arguments cannot follow named arguments or explicit register arguments
--> $DIR/x86_64_parse_error.rs:17:36
--> $DIR/x86_64_parse_error.rs:15:36
|
LL | asm!("{1}", in("eax") foo, const bar);
| ------------- ^^^^^^^^^ positional argument
| |
| explicit register argument

error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/x86_64_parse_error.rs:13:46
--> $DIR/x86_64_parse_error.rs:11:46
|
LL | asm!("{a}", in("eax") foo, a = const bar);
| ^^^ non-constant value
@@ -24,7 +24,7 @@ LL | const bar: /* Type */ = 0;
| ~~~~~ ++++++++++++

error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/x86_64_parse_error.rs:15:46
--> $DIR/x86_64_parse_error.rs:13:46
|
LL | asm!("{a}", in("eax") foo, a = const bar);
| ^^^ non-constant value
@@ -35,7 +35,7 @@ LL | const bar: /* Type */ = 0;
| ~~~~~ ++++++++++++

error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/x86_64_parse_error.rs:17:42
--> $DIR/x86_64_parse_error.rs:15:42
|
LL | asm!("{1}", in("eax") foo, const bar);
| ^^^ non-constant value
16 changes: 0 additions & 16 deletions tests/ui/feature-gates/feature-gate-asm_const.rs

This file was deleted.

23 changes: 0 additions & 23 deletions tests/ui/feature-gates/feature-gate-asm_const.stderr

This file was deleted.

10 changes: 10 additions & 0 deletions tests/ui/higher-ranked/subtyping-fn-ptr-coercion.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//@ check-pass

// Check that we use subtyping when reifying a closure into a function pointer.

fn foo(x: &str) {}

fn main() {
let c = |_: &str| {};
let x = c as fn(&'static str);
}
4 changes: 2 additions & 2 deletions tests/ui/impl-trait/recursive-ice-101862.stderr
Original file line number Diff line number Diff line change
@@ -11,13 +11,13 @@ LL | vec![].append(&mut ice(x.as_ref()));
= note: `#[warn(unconditional_recursion)]` on by default

error[E0792]: expected generic type parameter, found `&str`
--> $DIR/recursive-ice-101862.rs:6:5
--> $DIR/recursive-ice-101862.rs:6:19
|
LL | pub fn ice(x: impl AsRef<str>) -> impl IntoIterator<Item = ()> {
| --------------- this generic parameter must be used with a generic type parameter
LL |
LL | vec![].append(&mut ice(x.as_ref()));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error; 1 warning emitted

1 change: 1 addition & 0 deletions tests/ui/traits/next-solver/alias-bound-unsound.rs
Original file line number Diff line number Diff line change
@@ -27,5 +27,6 @@ fn main() {
//~| ERROR overflow evaluating the requirement `&<() as Foo>::Item well-formed`
//~| ERROR overflow evaluating the requirement `<() as Foo>::Item == _`
//~| ERROR overflow evaluating the requirement `<() as Foo>::Item == _`
//~| ERROR overflow evaluating the requirement `<() as Foo>::Item == _`
println!("{x}");
}
8 changes: 7 additions & 1 deletion tests/ui/traits/next-solver/alias-bound-unsound.stderr
Original file line number Diff line number Diff line change
@@ -44,6 +44,12 @@ LL | drop(<() as Foo>::copy_me(&x));
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: aborting due to 6 previous errors
error[E0275]: overflow evaluating the requirement `<() as Foo>::Item == _`
--> $DIR/alias-bound-unsound.rs:24:31
|
LL | drop(<() as Foo>::copy_me(&x));
| ^^

error: aborting due to 7 previous errors

For more information about this error, try `rustc --explain E0275`.
4 changes: 2 additions & 2 deletions tests/ui/try-trait/bad-interconversion.stderr
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ LL | Some(Err("hello")?)
| ^ use `.ok()?` if you want to discard the `Result<Infallible, &str>` error information
|
= help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `Option<u16>`
= help: the trait `FromResidual` is implemented for `Option<T>`
= help: the trait `FromResidual<Option<Infallible>>` is implemented for `Option<T>`

error[E0277]: the `?` operator can only be used on `Option`s in a function that returns `Option`
--> $DIR/bad-interconversion.rs:27:33
@@ -56,7 +56,7 @@ LL | Some(ControlFlow::Break(123)?)
| ^ this `?` produces `ControlFlow<{integer}, Infallible>`, which is incompatible with `Option<u64>`
|
= help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Option<u64>`
= help: the trait `FromResidual` is implemented for `Option<T>`
= help: the trait `FromResidual<Option<Infallible>>` is implemented for `Option<T>`

error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow`
--> $DIR/bad-interconversion.rs:32:39
2 changes: 1 addition & 1 deletion tests/ui/try-trait/option-to-result.stderr
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ LL | a?;
| ^ use `.ok()?` if you want to discard the `Result<Infallible, i32>` error information
|
= help: the trait `FromResidual<Result<Infallible, i32>>` is not implemented for `Option<i32>`
= help: the trait `FromResidual` is implemented for `Option<T>`
= help: the trait `FromResidual<Option<Infallible>>` is implemented for `Option<T>`

error: aborting due to 2 previous errors