Skip to content

Commit a45dc87

Browse files
committed
Auto merge of rust-lang#140674 - GuillaumeGomez:rollup-x9tjva8, r=GuillaumeGomez
Rollup of 11 pull requests Successful merges: - rust-lang#139764 (Consistent trait bounds for ExtractIf Debug impls) - rust-lang#140035 (Implement RFC 3503: frontmatters) - rust-lang#140080 (mir-opt: Use one MirPatch in MatchBranchSimplification) - rust-lang#140115 (mir-opt: execute MatchBranchSimplification after GVN) - rust-lang#140357 (bypass linker configuration and cross target check on `x check`) - rust-lang#140374 (Resolve instance for SymFn in global/naked asm) - rust-lang#140393 (std: get rid of `sys_common::process`) - rust-lang#140532 (Fix RustAnalyzer discovery of rustc's `stable_mir` crate) - rust-lang#140559 (Removing rustc_type_ir in the rustc_infer codebase) - rust-lang#140636 (implement `PanicTracker` to track `t` panics) - rust-lang#140661 (Make `-Zfixed-x18` into a target modifier) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0f73f0f + 5b2887b commit a45dc87

File tree

139 files changed

+1526
-378
lines changed

Some content is hidden

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

139 files changed

+1526
-378
lines changed

Cargo.lock

+2-1
Original file line numberDiff line numberDiff line change
@@ -3604,13 +3604,13 @@ dependencies = [
36043604
"rustc_query_system",
36053605
"rustc_resolve",
36063606
"rustc_session",
3607-
"rustc_smir",
36083607
"rustc_span",
36093608
"rustc_target",
36103609
"rustc_trait_selection",
36113610
"rustc_ty_utils",
36123611
"serde_json",
36133612
"shlex",
3613+
"stable_mir",
36143614
"tracing",
36153615
"windows 0.59.0",
36163616
]
@@ -4515,6 +4515,7 @@ dependencies = [
45154515
"rustc_session",
45164516
"rustc_span",
45174517
"rustc_transmute",
4518+
"rustc_type_ir",
45184519
"smallvec",
45194520
"thin-vec",
45204521
"tracing",

compiler/rustc_ast_passes/src/feature_gate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
514514
gate_all!(contracts_internals, "contract internal machinery is for internal use only");
515515
gate_all!(where_clause_attrs, "attributes in `where` clause are unstable");
516516
gate_all!(super_let, "`super let` is experimental");
517+
gate_all!(frontmatter, "frontmatters are experimental");
517518

518519
if !visitor.features.never_patterns() {
519520
if let Some(spans) = spans.get(&sym::never_patterns) {

compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
12821282
intrinsic.name,
12831283
);
12841284
}
1285-
return Err(Instance::new(instance.def_id(), instance.args));
1285+
return Err(Instance::new_raw(instance.def_id(), instance.args));
12861286
}
12871287
}
12881288

compiler/rustc_codegen_gcc/src/intrinsic/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
399399
}
400400

401401
// Fall back to default body
402-
_ => return Err(Instance::new(instance.def_id(), instance.args)),
402+
_ => return Err(Instance::new_raw(instance.def_id(), instance.args)),
403403
};
404404

405405
if !fn_abi.ret.is_ignore() {

compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/unused.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ fn make_dummy_instance<'tcx>(tcx: TyCtxt<'tcx>, local_def_id: LocalDefId) -> ty:
157157
let def_id = local_def_id.to_def_id();
158158

159159
// Make a dummy instance that fills in all generics with placeholders.
160-
ty::Instance::new(
160+
ty::Instance::new_raw(
161161
def_id,
162162
ty::GenericArgs::for_item(tcx, def_id, |param, _| {
163163
if let ty::GenericParamDefKind::Lifetime = param.kind {

compiler/rustc_codegen_llvm/src/intrinsic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
613613
_ => {
614614
debug!("unknown intrinsic '{}' -- falling back to default body", name);
615615
// Call the fallback body instead of generating the intrinsic code
616-
return Err(ty::Instance::new(instance.def_id(), instance.args));
616+
return Err(ty::Instance::new_raw(instance.def_id(), instance.args));
617617
}
618618
};
619619

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ pub(crate) fn symbol_name_for_instance_in_crate<'tcx>(
612612
ExportedSymbol::Generic(def_id, args) => {
613613
rustc_symbol_mangling::symbol_name_for_instance_in_crate(
614614
tcx,
615-
Instance::new(def_id, args),
615+
Instance::new_raw(def_id, args),
616616
instantiating_crate,
617617
)
618618
}
@@ -660,7 +660,7 @@ fn calling_convention_for_symbol<'tcx>(
660660
None
661661
}
662662
ExportedSymbol::NonGeneric(def_id) => Some(Instance::mono(tcx, def_id)),
663-
ExportedSymbol::Generic(def_id, args) => Some(Instance::new(def_id, args)),
663+
ExportedSymbol::Generic(def_id, args) => Some(Instance::new_raw(def_id, args)),
664664
// DropGlue always use the Rust calling convention and thus follow the target's default
665665
// symbol decoration scheme.
666666
ExportedSymbol::DropGlue(..) => None,

compiler/rustc_codegen_ssa/src/base.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,13 @@ where
457457
rustc_hir::InlineAsmOperand::SymFn { expr } => {
458458
let ty = cx.tcx().typeck(item_id.owner_id).expr_ty(expr);
459459
let instance = match ty.kind() {
460-
&ty::FnDef(def_id, args) => Instance::new(def_id, args),
460+
&ty::FnDef(def_id, args) => Instance::expect_resolve(
461+
cx.tcx(),
462+
ty::TypingEnv::fully_monomorphized(),
463+
def_id,
464+
args,
465+
expr.span,
466+
),
461467
_ => span_bug!(*op_sp, "asm sym is not a function"),
462468
};
463469

compiler/rustc_codegen_ssa/src/mir/naked_asm.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ fn inline_to_global_operand<'a, 'tcx, Cx: LayoutOf<'tcx, LayoutOfResult = TyAndL
9595
);
9696

9797
let instance = match mono_type.kind() {
98-
&ty::FnDef(def_id, args) => Instance::new(def_id, args),
98+
&ty::FnDef(def_id, args) => {
99+
Instance::expect_resolve(cx.tcx(), cx.typing_env(), def_id, args, value.span)
100+
}
99101
_ => bug!("asm sym is not a function"),
100102
};
101103

compiler/rustc_driver_impl/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ rustc_privacy = { path = "../rustc_privacy" }
4444
rustc_query_system = { path = "../rustc_query_system" }
4545
rustc_resolve = { path = "../rustc_resolve" }
4646
rustc_session = { path = "../rustc_session" }
47-
rustc_smir = { path = "../rustc_smir" }
4847
rustc_span = { path = "../rustc_span" }
4948
rustc_target = { path = "../rustc_target" }
5049
rustc_trait_selection = { path = "../rustc_trait_selection" }
5150
rustc_ty_utils = { path = "../rustc_ty_utils" }
5251
serde_json = "1.0.59"
5352
shlex = "1.0"
53+
stable_mir = { path = "../stable_mir", features = ["rustc_internal"] }
5454
tracing = { version = "0.1.35" }
5555
# tidy-alphabetical-end
5656

compiler/rustc_driver_impl/src/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use rustc_middle::ty::{self, TyCtxt};
1010
use rustc_mir_build::thir::print::{thir_flat, thir_tree};
1111
use rustc_session::Session;
1212
use rustc_session::config::{OutFileName, PpHirMode, PpMode, PpSourceMode};
13-
use rustc_smir::rustc_internal::pretty::write_smir_pretty;
1413
use rustc_span::{FileName, Ident};
14+
use stable_mir::rustc_internal::pretty::write_smir_pretty;
1515
use tracing::debug;
1616
use {rustc_ast as ast, rustc_hir_pretty as pprust_hir};
1717

compiler/rustc_feature/src/unstable.rs

+2
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,8 @@ declare_features! (
510510
(incomplete, fn_delegation, "1.76.0", Some(118212)),
511511
/// Allows impls for the Freeze trait.
512512
(internal, freeze_impls, "1.78.0", Some(121675)),
513+
/// Frontmatter `---` blocks for use by external tools.
514+
(unstable, frontmatter, "CURRENT_RUSTC_VERSION", Some(136889)),
513515
/// Allows defining gen blocks and `gen fn`.
514516
(unstable, gen_blocks, "1.75.0", Some(117078)),
515517
/// Infer generic args for both consts and types.

compiler/rustc_hir_analysis/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
216216
check::maybe_check_static_with_link_section(tcx, item_def_id);
217217
}
218218
DefKind::Const if tcx.generics_of(item_def_id).is_empty() => {
219-
let instance = ty::Instance::new(item_def_id.into(), ty::GenericArgs::empty());
219+
let instance = ty::Instance::new_raw(item_def_id.into(), ty::GenericArgs::empty());
220220
let cid = GlobalId { instance, promoted: None };
221221
let typing_env = ty::TypingEnv::fully_monomorphized();
222222
tcx.ensure_ok().eval_to_const_value_raw(typing_env.as_query_input(cid));

compiler/rustc_infer/src/infer/context.rs

+9-17
Original file line numberDiff line numberDiff line change
@@ -121,28 +121,28 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
121121
self.enter_forall(value, f)
122122
}
123123

124-
fn equate_ty_vids_raw(&self, a: rustc_type_ir::TyVid, b: rustc_type_ir::TyVid) {
124+
fn equate_ty_vids_raw(&self, a: ty::TyVid, b: ty::TyVid) {
125125
self.inner.borrow_mut().type_variables().equate(a, b);
126126
}
127127

128-
fn equate_int_vids_raw(&self, a: rustc_type_ir::IntVid, b: rustc_type_ir::IntVid) {
128+
fn equate_int_vids_raw(&self, a: ty::IntVid, b: ty::IntVid) {
129129
self.inner.borrow_mut().int_unification_table().union(a, b);
130130
}
131131

132-
fn equate_float_vids_raw(&self, a: rustc_type_ir::FloatVid, b: rustc_type_ir::FloatVid) {
132+
fn equate_float_vids_raw(&self, a: ty::FloatVid, b: ty::FloatVid) {
133133
self.inner.borrow_mut().float_unification_table().union(a, b);
134134
}
135135

136-
fn equate_const_vids_raw(&self, a: rustc_type_ir::ConstVid, b: rustc_type_ir::ConstVid) {
136+
fn equate_const_vids_raw(&self, a: ty::ConstVid, b: ty::ConstVid) {
137137
self.inner.borrow_mut().const_unification_table().union(a, b);
138138
}
139139

140140
fn instantiate_ty_var_raw<R: PredicateEmittingRelation<Self>>(
141141
&self,
142142
relation: &mut R,
143143
target_is_expected: bool,
144-
target_vid: rustc_type_ir::TyVid,
145-
instantiation_variance: rustc_type_ir::Variance,
144+
target_vid: ty::TyVid,
145+
instantiation_variance: ty::Variance,
146146
source_ty: Ty<'tcx>,
147147
) -> RelateResult<'tcx, ()> {
148148
self.instantiate_ty_var(
@@ -154,27 +154,19 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
154154
)
155155
}
156156

157-
fn instantiate_int_var_raw(
158-
&self,
159-
vid: rustc_type_ir::IntVid,
160-
value: rustc_type_ir::IntVarValue,
161-
) {
157+
fn instantiate_int_var_raw(&self, vid: ty::IntVid, value: ty::IntVarValue) {
162158
self.inner.borrow_mut().int_unification_table().union_value(vid, value);
163159
}
164160

165-
fn instantiate_float_var_raw(
166-
&self,
167-
vid: rustc_type_ir::FloatVid,
168-
value: rustc_type_ir::FloatVarValue,
169-
) {
161+
fn instantiate_float_var_raw(&self, vid: ty::FloatVid, value: ty::FloatVarValue) {
170162
self.inner.borrow_mut().float_unification_table().union_value(vid, value);
171163
}
172164

173165
fn instantiate_const_var_raw<R: PredicateEmittingRelation<Self>>(
174166
&self,
175167
relation: &mut R,
176168
target_is_expected: bool,
177-
target_vid: rustc_type_ir::ConstVid,
169+
target_vid: ty::ConstVid,
178170
source_ct: ty::Const<'tcx>,
179171
) -> RelateResult<'tcx, ()> {
180172
self.instantiate_const_var(relation, target_is_expected, target_vid, source_ct)

compiler/rustc_infer/src/infer/outlives/obligations.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ use rustc_data_structures::undo_log::UndoLogs;
6363
use rustc_middle::bug;
6464
use rustc_middle::mir::ConstraintCategory;
6565
use rustc_middle::traits::query::NoSolution;
66+
use rustc_middle::ty::outlives::{Component, push_outlives_components};
6667
use rustc_middle::ty::{
6768
self, GenericArgKind, GenericArgsRef, PolyTypeOutlivesPredicate, Region, Ty, TyCtxt,
6869
TypeFoldable as _, TypeVisitableExt,
6970
};
70-
use rustc_type_ir::outlives::{Component, push_outlives_components};
7171
use smallvec::smallvec;
7272
use tracing::{debug, instrument};
7373

compiler/rustc_infer/src/infer/outlives/verify.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::assert_matches::assert_matches;
22

3+
use rustc_middle::ty::outlives::{Component, compute_alias_components_recursive};
34
use rustc_middle::ty::{self, OutlivesPredicate, Ty, TyCtxt};
4-
use rustc_type_ir::outlives::{Component, compute_alias_components_recursive};
55
use smallvec::smallvec;
66
use tracing::{debug, instrument, trace};
77

compiler/rustc_infer/src/infer/relate/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
//! (except for some relations used for diagnostics and heuristics in the compiler).
33
//! As well as the implementation of `Relate` for interned things (`Ty`/`Const`/etc).
44
5-
pub use rustc_middle::ty::relate::RelateResult;
6-
pub use rustc_type_ir::relate::combine::PredicateEmittingRelation;
7-
pub use rustc_type_ir::relate::*;
5+
pub use rustc_middle::ty::relate::combine::PredicateEmittingRelation;
6+
pub use rustc_middle::ty::relate::{RelateResult, *};
87

98
mod generalize;
109
mod higher_ranked;

compiler/rustc_infer/src/infer/relate/type_relating.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ use rustc_middle::ty::relate::combine::{super_combine_consts, super_combine_tys}
33
use rustc_middle::ty::relate::{
44
Relate, RelateResult, TypeRelation, relate_args_invariantly, relate_args_with_variances,
55
};
6-
use rustc_middle::ty::{self, Ty, TyCtxt, TyVar};
6+
use rustc_middle::ty::{self, DelayedSet, Ty, TyCtxt, TyVar};
77
use rustc_span::Span;
8-
use rustc_type_ir::data_structures::DelayedSet;
98
use tracing::{debug, instrument};
109

1110
use crate::infer::BoundRegionConversionTime::HigherRankedType;

compiler/rustc_infer/src/infer/resolve.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use rustc_middle::bug;
22
use rustc_middle::ty::{
3-
self, Const, FallibleTypeFolder, InferConst, Ty, TyCtxt, TypeFoldable, TypeFolder,
3+
self, Const, DelayedMap, FallibleTypeFolder, InferConst, Ty, TyCtxt, TypeFoldable, TypeFolder,
44
TypeSuperFoldable, TypeVisitableExt,
55
};
6-
use rustc_type_ir::data_structures::DelayedMap;
76

87
use super::{FixupError, FixupResult, InferCtxt};
98

compiler/rustc_infer/src/infer/snapshot/fudge.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ use std::ops::Range;
33
use rustc_data_structures::{snapshot_vec as sv, unify as ut};
44
use rustc_middle::ty::{
55
self, ConstVid, FloatVid, IntVid, RegionVid, Ty, TyCtxt, TyVid, TypeFoldable, TypeFolder,
6-
TypeSuperFoldable,
6+
TypeSuperFoldable, TypeVisitableExt,
77
};
8-
use rustc_type_ir::TypeVisitableExt;
98
use tracing::instrument;
109
use ut::UnifyKey;
1110

compiler/rustc_infer/src/traits/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_data_structures::fx::FxHashSet;
2+
pub use rustc_middle::ty::elaborate::*;
23
use rustc_middle::ty::{self, TyCtxt};
34
use rustc_span::{Ident, Span};
4-
pub use rustc_type_ir::elaborate::*;
55

66
use crate::traits::{self, Obligation, ObligationCauseCode, PredicateObligation};
77

compiler/rustc_lexer/src/cursor.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
use std::str::Chars;
22

3+
pub enum FrontmatterAllowed {
4+
Yes,
5+
No,
6+
}
7+
38
/// Peekable iterator over a char sequence.
49
///
510
/// Next characters can be peeked via `first` method,
@@ -8,17 +13,19 @@ pub struct Cursor<'a> {
813
len_remaining: usize,
914
/// Iterator over chars. Slightly faster than a &str.
1015
chars: Chars<'a>,
16+
pub(crate) frontmatter_allowed: FrontmatterAllowed,
1117
#[cfg(debug_assertions)]
1218
prev: char,
1319
}
1420

1521
pub(crate) const EOF_CHAR: char = '\0';
1622

1723
impl<'a> Cursor<'a> {
18-
pub fn new(input: &'a str) -> Cursor<'a> {
24+
pub fn new(input: &'a str, frontmatter_allowed: FrontmatterAllowed) -> Cursor<'a> {
1925
Cursor {
2026
len_remaining: input.len(),
2127
chars: input.chars(),
28+
frontmatter_allowed,
2229
#[cfg(debug_assertions)]
2330
prev: EOF_CHAR,
2431
}
@@ -95,6 +102,11 @@ impl<'a> Cursor<'a> {
95102
Some(c)
96103
}
97104

105+
/// Moves to a substring by a number of bytes.
106+
pub(crate) fn bump_bytes(&mut self, n: usize) {
107+
self.chars = self.as_str()[n..].chars();
108+
}
109+
98110
/// Eats symbols while predicate returns true or until the end of file is reached.
99111
pub(crate) fn eat_while(&mut self, mut predicate: impl FnMut(char) -> bool) {
100112
// It was tried making optimized version of this for eg. line comments, but

0 commit comments

Comments
 (0)