Skip to content

Commit 355a307

Browse files
committed
Auto merge of rust-lang#129092 - jieyouxu:rollup-z2522nm, r=jieyouxu
Rollup of 6 pull requests Successful merges: - rust-lang#128570 (Stabilize `asm_const`) - rust-lang#128828 (`-Znext-solver` caching) - rust-lang#128954 (Explicitly specify type parameter on FromResidual for Option and ControlFlow.) - rust-lang#129059 (Record the correct target type when coercing fn items/closures to pointers) - rust-lang#129071 (Port `run-make/sysroot-crates-are-unstable` to rmake) - rust-lang#129088 (Make the rendered html doc for rustc better) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0f442e2 + 4d8c0b3 commit 355a307

File tree

74 files changed

+1280
-1030
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1280
-1030
lines changed

compiler/rustc_ast_lowering/messages.ftl

-2
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,6 @@ ast_lowering_underscore_expr_lhs_assign =
175175
.label = `_` not allowed here
176176
177177
ast_lowering_unstable_inline_assembly = inline assembly is not stable yet on this architecture
178-
ast_lowering_unstable_inline_assembly_const_operands =
179-
const operands for inline assembly are unstable
180178
ast_lowering_unstable_inline_assembly_label_operands =
181179
label operands for inline assembly are unstable
182180
ast_lowering_unstable_may_unwind = the `may_unwind` option is unstable

compiler/rustc_ast_lowering/src/asm.rs

+3-14
Original file line numberDiff line numberDiff line change
@@ -183,20 +183,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
183183
out_expr: out_expr.as_ref().map(|expr| self.lower_expr(expr)),
184184
}
185185
}
186-
InlineAsmOperand::Const { anon_const } => {
187-
if !self.tcx.features().asm_const {
188-
feature_err(
189-
sess,
190-
sym::asm_const,
191-
*op_sp,
192-
fluent::ast_lowering_unstable_inline_assembly_const_operands,
193-
)
194-
.emit();
195-
}
196-
hir::InlineAsmOperand::Const {
197-
anon_const: self.lower_anon_const_to_anon_const(anon_const),
198-
}
199-
}
186+
InlineAsmOperand::Const { anon_const } => hir::InlineAsmOperand::Const {
187+
anon_const: self.lower_anon_const_to_anon_const(anon_const),
188+
},
200189
InlineAsmOperand::Sym { sym } => {
201190
let static_def_id = self
202191
.resolver

compiler/rustc_borrowck/src/type_check/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1989,9 +1989,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
19891989

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

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

2017-
if let Err(terr) = self.eq_types(
2018-
*ty,
2017+
if let Err(terr) = self.sub_types(
20192018
ty_fn_ptr_from,
2019+
*ty,
20202020
location.to_locations(),
20212021
ConstraintCategory::Cast { unsize_to: None },
20222022
) {

compiler/rustc_codegen_gcc/tests/run/asm.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
// Run-time:
44
// status: 0
55

6-
#![feature(asm_const)]
7-
8-
#[cfg(target_arch="x86_64")]
6+
#[cfg(target_arch = "x86_64")]
97
use std::arch::{asm, global_asm};
108

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

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

36-
#[cfg(target_arch="x86_64")]
34+
#[cfg(target_arch = "x86_64")]
3735
fn asm() {
3836
unsafe {
3937
asm!("nop");
@@ -178,9 +176,8 @@ fn asm() {
178176
assert_eq!(array1, array2);
179177
}
180178

181-
#[cfg(not(target_arch="x86_64"))]
182-
fn asm() {
183-
}
179+
#[cfg(not(target_arch = "x86_64"))]
180+
fn asm() {}
184181

185182
fn main() {
186183
asm();

compiler/rustc_errors/src/lib.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -1837,23 +1837,23 @@ impl DelayedDiagInner {
18371837
}
18381838
}
18391839

1840-
/// Level is_error EmissionGuarantee Top-level Sub Used in lints?
1841-
/// ----- -------- ----------------- --------- --- --------------
1842-
/// Bug yes BugAbort yes - -
1843-
/// Fatal yes FatalAbort/FatalError(*) yes - -
1844-
/// Error yes ErrorGuaranteed yes - yes
1845-
/// DelayedBug yes ErrorGuaranteed yes - -
1846-
/// ForceWarning - () yes - lint-only
1847-
/// Warning - () yes yes yes
1848-
/// Note - () rare yes -
1849-
/// OnceNote - () - yes lint-only
1850-
/// Help - () rare yes -
1851-
/// OnceHelp - () - yes lint-only
1852-
/// FailureNote - () rare - -
1853-
/// Allow - () yes - lint-only
1854-
/// Expect - () yes - lint-only
1840+
/// | Level | is_error | EmissionGuarantee | Top-level | Sub | Used in lints?
1841+
/// | ----- | -------- | ----------------- | --------- | --- | --------------
1842+
/// | Bug | yes | BugAbort | yes | - | -
1843+
/// | Fatal | yes | FatalAbort/FatalError[^star] | yes | - | -
1844+
/// | Error | yes | ErrorGuaranteed | yes | - | yes
1845+
/// | DelayedBug | yes | ErrorGuaranteed | yes | - | -
1846+
/// | ForceWarning | - | () | yes | - | lint-only
1847+
/// | Warning | - | () | yes | yes | yes
1848+
/// | Note | - | () | rare | yes | -
1849+
/// | OnceNote | - | () | - | yes | lint-only
1850+
/// | Help | - | () | rare | yes | -
1851+
/// | OnceHelp | - | () | - | yes | lint-only
1852+
/// | FailureNote | - | () | rare | - | -
1853+
/// | Allow | - | () | yes | - | lint-only
1854+
/// | Expect | - | () | yes | - | lint-only
18551855
///
1856-
/// (*) `FatalAbort` normally, `FatalError` in the non-aborting "almost fatal" case that is
1856+
/// [^star]: `FatalAbort` normally, `FatalError` in the non-aborting "almost fatal" case that is
18571857
/// occasionally used.
18581858
///
18591859
#[derive(Copy, PartialEq, Eq, Clone, Hash, Debug, Encodable, Decodable)]

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ declare_features! (
6060
(accepted, adx_target_feature, "1.61.0", Some(44839)),
6161
/// Allows explicit discriminants on non-unit enum variants.
6262
(accepted, arbitrary_enum_discriminant, "1.66.0", Some(60553)),
63+
/// Allows using `const` operands in inline assembly.
64+
(accepted, asm_const, "CURRENT_RUSTC_VERSION", Some(93332)),
6365
/// Allows using `sym` operands in inline assembly.
6466
(accepted, asm_sym, "1.66.0", Some(93333)),
6567
/// Allows the definition of associated constants in `trait` or `impl` blocks.

compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,6 @@ declare_features! (
348348
(unstable, alloc_error_handler, "1.29.0", Some(51540)),
349349
/// Allows trait methods with arbitrary self types.
350350
(unstable, arbitrary_self_types, "1.23.0", Some(44874)),
351-
/// Allows using `const` operands in inline assembly.
352-
(unstable, asm_const, "1.58.0", Some(93332)),
353351
/// Enables experimental inline assembly support for additional architectures.
354352
(unstable, asm_experimental_arch, "1.58.0", Some(93335)),
355353
/// Allows using `label` operands in inline assembly.

compiler/rustc_hir_typeck/src/coercion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
137137
at.lub(DefineOpaqueTypes::Yes, b, a)
138138
} else {
139139
at.sup(DefineOpaqueTypes::Yes, b, a)
140-
.map(|InferOk { value: (), obligations }| InferOk { value: a, obligations })
140+
.map(|InferOk { value: (), obligations }| InferOk { value: b, obligations })
141141
};
142142

143143
// In the new solver, lazy norm may allow us to shallowly equate

compiler/rustc_middle/src/arena.rs

-4
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ macro_rules! arena_types {
6161
[] dtorck_constraint: rustc_middle::traits::query::DropckConstraint<'tcx>,
6262
[] candidate_step: rustc_middle::traits::query::CandidateStep<'tcx>,
6363
[] autoderef_bad_ty: rustc_middle::traits::query::MethodAutoderefBadTy<'tcx>,
64-
[] canonical_goal_evaluation:
65-
rustc_type_ir::solve::inspect::CanonicalGoalEvaluationStep<
66-
rustc_middle::ty::TyCtxt<'tcx>
67-
>,
6864
[] query_region_constraints: rustc_middle::infer::canonical::QueryRegionConstraints<'tcx>,
6965
[] type_op_subtype:
7066
rustc_middle::infer::canonical::Canonical<'tcx,

compiler/rustc_middle/src/ty/context.rs

-9
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
107107
self.mk_predefined_opaques_in_body(data)
108108
}
109109
type DefiningOpaqueTypes = &'tcx ty::List<LocalDefId>;
110-
type CanonicalGoalEvaluationStepRef =
111-
&'tcx solve::inspect::CanonicalGoalEvaluationStep<TyCtxt<'tcx>>;
112110
type CanonicalVars = CanonicalVarInfos<'tcx>;
113111
fn mk_canonical_var_infos(self, infos: &[ty::CanonicalVarInfo<Self>]) -> Self::CanonicalVars {
114112
self.mk_canonical_var_infos(infos)
@@ -277,13 +275,6 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
277275
self.debug_assert_args_compatible(def_id, args);
278276
}
279277

280-
fn intern_canonical_goal_evaluation_step(
281-
self,
282-
step: solve::inspect::CanonicalGoalEvaluationStep<TyCtxt<'tcx>>,
283-
) -> &'tcx solve::inspect::CanonicalGoalEvaluationStep<TyCtxt<'tcx>> {
284-
self.arena.alloc(step)
285-
}
286-
287278
fn mk_type_list_from_iter<I, T>(self, args: I) -> T::Output
288279
where
289280
I: Iterator<Item = T>,

compiler/rustc_next_trait_solver/src/solve/inspect/build.rs

+14-92
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
//! see the comment on [ProofTreeBuilder].
66
77
use std::marker::PhantomData;
8-
use std::mem;
98

109
use derive_where::derive_where;
1110
use rustc_type_ir::inherent::*;
12-
use rustc_type_ir::{self as ty, search_graph, Interner};
11+
use rustc_type_ir::{self as ty, Interner};
1312

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

97-
#[derive_where(PartialEq, Eq; I: Interner)]
98-
pub(in crate::solve) enum WipCanonicalGoalEvaluationKind<I: Interner> {
99-
Overflow,
100-
CycleInStack,
101-
ProvisionalCacheHit,
102-
Interned { final_revision: I::CanonicalGoalEvaluationStepRef },
103-
}
104-
105-
impl<I: Interner> std::fmt::Debug for WipCanonicalGoalEvaluationKind<I> {
106-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
107-
match self {
108-
Self::Overflow => write!(f, "Overflow"),
109-
Self::CycleInStack => write!(f, "CycleInStack"),
110-
Self::ProvisionalCacheHit => write!(f, "ProvisionalCacheHit"),
111-
Self::Interned { final_revision: _ } => {
112-
f.debug_struct("Interned").finish_non_exhaustive()
113-
}
114-
}
115-
}
116-
}
117-
11896
#[derive_where(PartialEq, Eq, Debug; I: Interner)]
11997
struct WipCanonicalGoalEvaluation<I: Interner> {
12098
goal: CanonicalInput<I>,
121-
kind: Option<WipCanonicalGoalEvaluationKind<I>>,
99+
encountered_overflow: bool,
122100
/// Only used for uncached goals. After we finished evaluating
123101
/// the goal, this is interned and moved into `kind`.
124102
final_revision: Option<WipCanonicalGoalEvaluationStep<I>>,
@@ -127,25 +105,17 @@ struct WipCanonicalGoalEvaluation<I: Interner> {
127105

128106
impl<I: Interner> WipCanonicalGoalEvaluation<I> {
129107
fn finalize(self) -> inspect::CanonicalGoalEvaluation<I> {
130-
// We've already interned the final revision in
131-
// `fn finalize_canonical_goal_evaluation`.
132-
assert!(self.final_revision.is_none());
133-
let kind = match self.kind.unwrap() {
134-
WipCanonicalGoalEvaluationKind::Overflow => {
108+
inspect::CanonicalGoalEvaluation {
109+
goal: self.goal,
110+
kind: if self.encountered_overflow {
111+
assert!(self.final_revision.is_none());
135112
inspect::CanonicalGoalEvaluationKind::Overflow
136-
}
137-
WipCanonicalGoalEvaluationKind::CycleInStack => {
138-
inspect::CanonicalGoalEvaluationKind::CycleInStack
139-
}
140-
WipCanonicalGoalEvaluationKind::ProvisionalCacheHit => {
141-
inspect::CanonicalGoalEvaluationKind::ProvisionalCacheHit
142-
}
143-
WipCanonicalGoalEvaluationKind::Interned { final_revision } => {
113+
} else {
114+
let final_revision = self.final_revision.unwrap().finalize();
144115
inspect::CanonicalGoalEvaluationKind::Evaluation { final_revision }
145-
}
146-
};
147-
148-
inspect::CanonicalGoalEvaluation { goal: self.goal, kind, result: self.result.unwrap() }
116+
},
117+
result: self.result.unwrap(),
118+
}
149119
}
150120
}
151121

@@ -308,7 +278,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
308278
) -> ProofTreeBuilder<D> {
309279
self.nested(|| WipCanonicalGoalEvaluation {
310280
goal,
311-
kind: None,
281+
encountered_overflow: false,
312282
final_revision: None,
313283
result: None,
314284
})
@@ -329,11 +299,11 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
329299
}
330300
}
331301

332-
pub fn canonical_goal_evaluation_kind(&mut self, kind: WipCanonicalGoalEvaluationKind<I>) {
302+
pub fn canonical_goal_evaluation_overflow(&mut self) {
333303
if let Some(this) = self.as_mut() {
334304
match this {
335305
DebugSolver::CanonicalGoalEvaluation(canonical_goal_evaluation) => {
336-
assert_eq!(canonical_goal_evaluation.kind.replace(kind), None);
306+
canonical_goal_evaluation.encountered_overflow = true;
337307
}
338308
_ => unreachable!(),
339309
};
@@ -547,51 +517,3 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
547517
}
548518
}
549519
}
550-
551-
impl<D, I> search_graph::ProofTreeBuilder<I> for ProofTreeBuilder<D>
552-
where
553-
D: SolverDelegate<Interner = I>,
554-
I: Interner,
555-
{
556-
fn try_apply_proof_tree(
557-
&mut self,
558-
proof_tree: Option<I::CanonicalGoalEvaluationStepRef>,
559-
) -> bool {
560-
if !self.is_noop() {
561-
if let Some(final_revision) = proof_tree {
562-
let kind = WipCanonicalGoalEvaluationKind::Interned { final_revision };
563-
self.canonical_goal_evaluation_kind(kind);
564-
true
565-
} else {
566-
false
567-
}
568-
} else {
569-
true
570-
}
571-
}
572-
573-
fn on_provisional_cache_hit(&mut self) {
574-
self.canonical_goal_evaluation_kind(WipCanonicalGoalEvaluationKind::ProvisionalCacheHit);
575-
}
576-
577-
fn on_cycle_in_stack(&mut self) {
578-
self.canonical_goal_evaluation_kind(WipCanonicalGoalEvaluationKind::CycleInStack);
579-
}
580-
581-
fn finalize_canonical_goal_evaluation(
582-
&mut self,
583-
tcx: I,
584-
) -> Option<I::CanonicalGoalEvaluationStepRef> {
585-
self.as_mut().map(|this| match this {
586-
DebugSolver::CanonicalGoalEvaluation(evaluation) => {
587-
let final_revision = mem::take(&mut evaluation.final_revision).unwrap();
588-
let final_revision =
589-
tcx.intern_canonical_goal_evaluation_step(final_revision.finalize());
590-
let kind = WipCanonicalGoalEvaluationKind::Interned { final_revision };
591-
assert_eq!(evaluation.kind.replace(kind), None);
592-
final_revision
593-
}
594-
_ => unreachable!(),
595-
})
596-
}
597-
}

0 commit comments

Comments
 (0)