Skip to content

Commit 891b852

Browse files
committed
Auto merge of #140726 - jhpratt:rollup-b6oxopx, r=jhpratt
Rollup of 9 pull requests Successful merges: - #134273 (de-stabilize bench attribute) - #139534 (Added support for `apxf` target feature) - #140419 (Move `in_external_macro` to `SyntaxContext`) - #140483 (Comment on `Rc` abort-guard strategy without naming unrelated fn) - #140607 (support duplicate entries in the opaque_type_storage) - #140656 (collect all Fuchsia bindings into the `fuchsia` module) - #140668 (Implement `VecDeque::truncate_front()`) - #140709 (rustdoc: remove unportable markdown lint and old parser) - #140713 (Structurally resolve in `check_ref_cast` in new solver) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 669c1ab + 3d8ef7a commit 891b852

File tree

46 files changed

+602
-770
lines changed

Some content is hidden

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

46 files changed

+602
-770
lines changed

Cargo.lock

+2-15
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ dependencies = [
558558
"if_chain",
559559
"itertools",
560560
"parking_lot",
561-
"pulldown-cmark 0.11.3",
561+
"pulldown-cmark",
562562
"quote",
563563
"regex",
564564
"rustc_tools_util 0.4.2",
@@ -2849,17 +2849,6 @@ dependencies = [
28492849
"cc",
28502850
]
28512851

2852-
[[package]]
2853-
name = "pulldown-cmark"
2854-
version = "0.9.6"
2855-
source = "registry+https://github.com/rust-lang/crates.io-index"
2856-
checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b"
2857-
dependencies = [
2858-
"bitflags",
2859-
"memchr",
2860-
"unicase",
2861-
]
2862-
28632852
[[package]]
28642853
name = "pulldown-cmark"
28652854
version = "0.11.3"
@@ -4337,7 +4326,7 @@ version = "0.0.0"
43374326
dependencies = [
43384327
"bitflags",
43394328
"itertools",
4340-
"pulldown-cmark 0.11.3",
4329+
"pulldown-cmark",
43414330
"rustc_arena",
43424331
"rustc_ast",
43434332
"rustc_ast_pretty",
@@ -4516,7 +4505,6 @@ dependencies = [
45164505
"rustc_session",
45174506
"rustc_span",
45184507
"rustc_transmute",
4519-
"rustc_type_ir",
45204508
"smallvec",
45214509
"thin-vec",
45224510
"tracing",
@@ -4622,7 +4610,6 @@ dependencies = [
46224610
"indexmap",
46234611
"itertools",
46244612
"minifier",
4625-
"pulldown-cmark 0.9.6",
46264613
"pulldown-cmark-escape",
46274614
"regex",
46284615
"rustdoc-json-types",

compiler/rustc_codegen_llvm/src/llvm_util.rs

+32-17
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use rustc_session::config::{PrintKind, PrintRequest};
1919
use rustc_span::Symbol;
2020
use rustc_target::spec::{MergeFunctions, PanicStrategy, SmallDataThresholdSupport};
2121
use rustc_target::target_features::{RUSTC_SPECIAL_FEATURES, RUSTC_SPECIFIC_FEATURES};
22+
use smallvec::{SmallVec, smallvec};
2223

2324
use crate::back::write::create_informational_target_machine;
2425
use crate::errors::{
@@ -180,27 +181,27 @@ impl<'a> TargetFeatureFoldStrength<'a> {
180181

181182
pub(crate) struct LLVMFeature<'a> {
182183
llvm_feature_name: &'a str,
183-
dependency: Option<TargetFeatureFoldStrength<'a>>,
184+
dependencies: SmallVec<[TargetFeatureFoldStrength<'a>; 1]>,
184185
}
185186

186187
impl<'a> LLVMFeature<'a> {
187188
fn new(llvm_feature_name: &'a str) -> Self {
188-
Self { llvm_feature_name, dependency: None }
189+
Self { llvm_feature_name, dependencies: SmallVec::new() }
189190
}
190191

191-
fn with_dependency(
192+
fn with_dependencies(
192193
llvm_feature_name: &'a str,
193-
dependency: TargetFeatureFoldStrength<'a>,
194+
dependencies: SmallVec<[TargetFeatureFoldStrength<'a>; 1]>,
194195
) -> Self {
195-
Self { llvm_feature_name, dependency: Some(dependency) }
196+
Self { llvm_feature_name, dependencies }
196197
}
197198

198-
fn contains(&self, feat: &str) -> bool {
199+
fn contains(&'a self, feat: &str) -> bool {
199200
self.iter().any(|dep| dep == feat)
200201
}
201202

202203
fn iter(&'a self) -> impl Iterator<Item = &'a str> {
203-
let dependencies = self.dependency.iter().map(|feat| feat.as_str());
204+
let dependencies = self.dependencies.iter().map(|feat| feat.as_str());
204205
std::iter::once(self.llvm_feature_name).chain(dependencies)
205206
}
206207
}
@@ -210,7 +211,7 @@ impl<'a> IntoIterator for LLVMFeature<'a> {
210211
type IntoIter = impl Iterator<Item = &'a str>;
211212

212213
fn into_iter(self) -> Self::IntoIter {
213-
let dependencies = self.dependency.into_iter().map(|feat| feat.as_str());
214+
let dependencies = self.dependencies.into_iter().map(|feat| feat.as_str());
214215
std::iter::once(self.llvm_feature_name).chain(dependencies)
215216
}
216217
}
@@ -240,9 +241,9 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
240241
&*sess.target.arch
241242
};
242243
match (arch, s) {
243-
("x86", "sse4.2") => Some(LLVMFeature::with_dependency(
244+
("x86", "sse4.2") => Some(LLVMFeature::with_dependencies(
244245
"sse4.2",
245-
TargetFeatureFoldStrength::EnableOnly("crc32"),
246+
smallvec![TargetFeatureFoldStrength::EnableOnly("crc32")],
246247
)),
247248
("x86", "pclmulqdq") => Some(LLVMFeature::new("pclmul")),
248249
("x86", "rdrand") => Some(LLVMFeature::new("rdrnd")),
@@ -262,9 +263,10 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
262263
("aarch64", "sme-b16b16") if get_version().0 < 20 => Some(LLVMFeature::new("b16b16")),
263264
("aarch64", "flagm2") => Some(LLVMFeature::new("altnzcv")),
264265
// Rust ties fp and neon together.
265-
("aarch64", "neon") => {
266-
Some(LLVMFeature::with_dependency("neon", TargetFeatureFoldStrength::Both("fp-armv8")))
267-
}
266+
("aarch64", "neon") => Some(LLVMFeature::with_dependencies(
267+
"neon",
268+
smallvec![TargetFeatureFoldStrength::Both("fp-armv8")],
269+
)),
268270
// In LLVM neon implicitly enables fp, but we manually enable
269271
// neon when a feature only implicitly enables fp
270272
("aarch64", "fhm") => Some(LLVMFeature::new("fp16fml")),
@@ -281,9 +283,10 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
281283
// Filter out features that are not supported by the current LLVM version
282284
("riscv32" | "riscv64", "zacas") if get_version().0 < 20 => None,
283285
// Enable the evex512 target feature if an avx512 target feature is enabled.
284-
("x86", s) if s.starts_with("avx512") => {
285-
Some(LLVMFeature::with_dependency(s, TargetFeatureFoldStrength::EnableOnly("evex512")))
286-
}
286+
("x86", s) if s.starts_with("avx512") => Some(LLVMFeature::with_dependencies(
287+
s,
288+
smallvec![TargetFeatureFoldStrength::EnableOnly("evex512")],
289+
)),
287290
// Support for `wide-arithmetic` will first land in LLVM 20 as part of
288291
// llvm/llvm-project#111598
289292
("wasm32" | "wasm64", "wide-arithmetic") if get_version() < (20, 0, 0) => None,
@@ -304,6 +307,18 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
304307
("x86", "avx10.1") => Some(LLVMFeature::new("avx10.1-512")),
305308
("x86", "avx10.2") if get_version().0 < 20 => None,
306309
("x86", "avx10.2") if get_version().0 >= 20 => Some(LLVMFeature::new("avx10.2-512")),
310+
("x86", "apxf") => Some(LLVMFeature::with_dependencies(
311+
"egpr",
312+
smallvec![
313+
TargetFeatureFoldStrength::Both("push2pop2"),
314+
TargetFeatureFoldStrength::Both("ppx"),
315+
TargetFeatureFoldStrength::Both("ndd"),
316+
TargetFeatureFoldStrength::Both("ccmp"),
317+
TargetFeatureFoldStrength::Both("cf"),
318+
TargetFeatureFoldStrength::Both("nf"),
319+
TargetFeatureFoldStrength::Both("zu"),
320+
],
321+
)),
307322
(_, s) => Some(LLVMFeature::new(s)),
308323
}
309324
}
@@ -853,7 +868,7 @@ pub(crate) fn global_llvm_features(
853868
"{}{}",
854869
enable_disable, llvm_feature.llvm_feature_name
855870
))
856-
.chain(llvm_feature.dependency.into_iter().filter_map(
871+
.chain(llvm_feature.dependencies.into_iter().filter_map(
857872
move |feat| match (enable, feat) {
858873
(_, TargetFeatureFoldStrength::Both(f))
859874
| (true, TargetFeatureFoldStrength::EnableOnly(f)) => {

compiler/rustc_feature/src/unstable.rs

+1
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ declare_features! (
316316
// Unstable `#[target_feature]` directives.
317317
(unstable, aarch64_unstable_target_feature, "1.82.0", Some(44839)),
318318
(unstable, aarch64_ver_target_feature, "1.27.0", Some(44839)),
319+
(unstable, apx_target_feature, "CURRENT_RUSTC_VERSION", Some(139284)),
319320
(unstable, arm_target_feature, "1.27.0", Some(44839)),
320321
(unstable, avx512_target_feature, "1.27.0", Some(44839)),
321322
(unstable, bpf_target_feature, "1.54.0", Some(44839)),

compiler/rustc_hir_typeck/src/_match.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
603603
// FIXME(-Znext-solver): Remove this branch once `replace_opaque_types_with_infer` is gone.
604604
ty::Infer(ty::TyVar(_)) => self
605605
.inner
606-
.borrow()
606+
.borrow_mut()
607+
.opaque_types()
607608
.iter_opaque_types()
608609
.find(|(_, v)| v.ty == expected_ty)
609610
.map(|(k, _)| (k.def_id, k.args))?,

compiler/rustc_hir_typeck/src/cast.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -1051,20 +1051,19 @@ impl<'a, 'tcx> CastCheck<'tcx> {
10511051
fn check_ref_cast(
10521052
&self,
10531053
fcx: &FnCtxt<'a, 'tcx>,
1054-
m_expr: ty::TypeAndMut<'tcx>,
1055-
m_cast: ty::TypeAndMut<'tcx>,
1054+
mut m_expr: ty::TypeAndMut<'tcx>,
1055+
mut m_cast: ty::TypeAndMut<'tcx>,
10561056
) -> Result<CastKind, CastError<'tcx>> {
10571057
// array-ptr-cast: allow mut-to-mut, mut-to-const, const-to-const
1058+
m_expr.ty = fcx.try_structurally_resolve_type(self.expr_span, m_expr.ty);
1059+
m_cast.ty = fcx.try_structurally_resolve_type(self.cast_span, m_cast.ty);
1060+
10581061
if m_expr.mutbl >= m_cast.mutbl
10591062
&& let ty::Array(ety, _) = m_expr.ty.kind()
10601063
&& fcx.can_eq(fcx.param_env, *ety, m_cast.ty)
10611064
{
1062-
// Due to the limitations of LLVM global constants,
1063-
// region pointers end up pointing at copies of
1064-
// vector elements instead of the original values.
1065-
// To allow raw pointers to work correctly, we
1066-
// need to special-case obtaining a raw pointer
1067-
// from a region pointer to a vector.
1065+
// Due to historical reasons we allow directly casting references of
1066+
// arrays into raw pointers of their element type.
10681067

10691068
// Coerce to a raw pointer so that we generate RawPtr in MIR.
10701069
let array_ptr_type = Ty::new_ptr(fcx.tcx, m_expr.ty, m_expr.mutbl);

compiler/rustc_infer/src/infer/canonical/query_response.rs

+7-19
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,13 @@ impl<'tcx> InferCtxt<'tcx> {
132132

133133
let certainty = if errors.is_empty() { Certainty::Proven } else { Certainty::Ambiguous };
134134

135-
let opaque_types = self.take_opaque_types_for_query_response();
135+
let opaque_types = self
136+
.inner
137+
.borrow_mut()
138+
.opaque_type_storage
139+
.take_opaque_types()
140+
.map(|(k, v)| (k, v.ty))
141+
.collect();
136142

137143
Ok(QueryResponse {
138144
var_values: inference_vars,
@@ -143,24 +149,6 @@ impl<'tcx> InferCtxt<'tcx> {
143149
})
144150
}
145151

146-
/// Used by the new solver as that one takes the opaque types at the end of a probe
147-
/// to deal with multiple candidates without having to recompute them.
148-
pub fn clone_opaque_types_for_query_response(
149-
&self,
150-
) -> Vec<(ty::OpaqueTypeKey<'tcx>, Ty<'tcx>)> {
151-
self.inner
152-
.borrow()
153-
.opaque_type_storage
154-
.opaque_types
155-
.iter()
156-
.map(|(k, v)| (*k, v.ty))
157-
.collect()
158-
}
159-
160-
fn take_opaque_types_for_query_response(&self) -> Vec<(ty::OpaqueTypeKey<'tcx>, Ty<'tcx>)> {
161-
self.take_opaque_types().into_iter().map(|(k, v)| (k, v.ty)).collect()
162-
}
163-
164152
/// Given the (canonicalized) result to a canonical query,
165153
/// instantiates the result so it can be used, plugging in the
166154
/// values from the canonical query. (Note that the result may

compiler/rustc_infer/src/infer/mod.rs

+8-17
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ use rustc_middle::traits::solve::Goal;
3131
use rustc_middle::ty::error::{ExpectedFound, TypeError};
3232
use rustc_middle::ty::{
3333
self, BoundVarReplacerDelegate, ConstVid, FloatVid, GenericArg, GenericArgKind, GenericArgs,
34-
GenericArgsRef, GenericParamDefKind, InferConst, IntVid, PseudoCanonicalInput, Term, TermKind,
35-
Ty, TyCtxt, TyVid, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitable,
36-
TypeVisitableExt, TypingEnv, TypingMode, fold_regions,
34+
GenericArgsRef, GenericParamDefKind, InferConst, IntVid, OpaqueHiddenType, OpaqueTypeKey,
35+
PseudoCanonicalInput, Term, TermKind, Ty, TyCtxt, TyVid, TypeFoldable, TypeFolder,
36+
TypeSuperFoldable, TypeVisitable, TypeVisitableExt, TypingEnv, TypingMode, fold_regions,
3737
};
3838
use rustc_span::{Span, Symbol};
3939
use snapshot::undo_log::InferCtxtUndoLogs;
@@ -198,7 +198,7 @@ impl<'tcx> InferCtxtInner<'tcx> {
198198
}
199199

200200
#[inline]
201-
fn opaque_types(&mut self) -> opaque_types::OpaqueTypeTable<'_, 'tcx> {
201+
pub fn opaque_types(&mut self) -> opaque_types::OpaqueTypeTable<'_, 'tcx> {
202202
self.opaque_type_storage.with_log(&mut self.undo_log)
203203
}
204204

@@ -224,15 +224,6 @@ impl<'tcx> InferCtxtInner<'tcx> {
224224
.expect("region constraints already solved")
225225
.with_log(&mut self.undo_log)
226226
}
227-
228-
// Iterates through the opaque type definitions without taking them; this holds the
229-
// `InferCtxtInner` lock, so make sure to not do anything with `InferCtxt` side-effects
230-
// while looping through this.
231-
pub fn iter_opaque_types(
232-
&self,
233-
) -> impl Iterator<Item = (ty::OpaqueTypeKey<'tcx>, ty::OpaqueHiddenType<'tcx>)> {
234-
self.opaque_type_storage.opaque_types.iter().map(|(&k, &v)| (k, v))
235-
}
236227
}
237228

238229
pub struct InferCtxt<'tcx> {
@@ -954,13 +945,13 @@ impl<'tcx> InferCtxt<'tcx> {
954945
}
955946

956947
#[instrument(level = "debug", skip(self), ret)]
957-
pub fn take_opaque_types(&self) -> opaque_types::OpaqueTypeMap<'tcx> {
958-
std::mem::take(&mut self.inner.borrow_mut().opaque_type_storage.opaque_types)
948+
pub fn take_opaque_types(&self) -> Vec<(OpaqueTypeKey<'tcx>, OpaqueHiddenType<'tcx>)> {
949+
self.inner.borrow_mut().opaque_type_storage.take_opaque_types().collect()
959950
}
960951

961952
#[instrument(level = "debug", skip(self), ret)]
962-
pub fn clone_opaque_types(&self) -> opaque_types::OpaqueTypeMap<'tcx> {
963-
self.inner.borrow().opaque_type_storage.opaque_types.clone()
953+
pub fn clone_opaque_types(&self) -> Vec<(OpaqueTypeKey<'tcx>, OpaqueHiddenType<'tcx>)> {
954+
self.inner.borrow_mut().opaque_type_storage.iter_opaque_types().collect()
964955
}
965956

966957
#[inline(always)]

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

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use hir::def_id::{DefId, LocalDefId};
2-
use rustc_data_structures::fx::FxIndexMap;
32
use rustc_hir as hir;
43
use rustc_middle::bug;
54
use rustc_middle::traits::ObligationCause;
@@ -19,7 +18,6 @@ use crate::traits::{self, Obligation, PredicateObligations};
1918

2019
mod table;
2120

22-
pub(crate) type OpaqueTypeMap<'tcx> = FxIndexMap<OpaqueTypeKey<'tcx>, OpaqueHiddenType<'tcx>>;
2321
pub(crate) use table::{OpaqueTypeStorage, OpaqueTypeTable};
2422

2523
impl<'tcx> InferCtxt<'tcx> {

0 commit comments

Comments
 (0)