Skip to content

Commit 1a6ae3d

Browse files
committed
Auto merge of rust-lang#110916 - matthiaskrgr:rollup-g3c33zc, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#105745 (docs(std): clarify remove_dir_all errors) - rust-lang#106456 (Correct `std::prelude` comment) - rust-lang#106599 (Change memory ordering in System wrapper example) - rust-lang#110838 (More `Typefoldable`/`TypeVisitable` cleanups) - rust-lang#110851 (compiletest: emit assembly-output header in error) - rust-lang#110853 (compiletest: add bpf-linker assembly support) - rust-lang#110878 (Add `known-bug` tests for 4 unsound issues) - rust-lang#110886 (`DepGraph` cleanups) - rust-lang#110905 (Remove invalid value from scraped-examples.md) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents c14882f + 790912a commit 1a6ae3d

File tree

23 files changed

+227
-158
lines changed

23 files changed

+227
-158
lines changed

Diff for: compiler/rustc_infer/src/traits/project.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub struct MismatchedProjectionTypes<'tcx> {
2020
pub err: ty::error::TypeError<'tcx>,
2121
}
2222

23-
#[derive(Clone, TypeFoldable, TypeVisitable)]
23+
#[derive(Clone)]
2424
pub struct Normalized<'tcx, T> {
2525
pub value: T,
2626
pub obligations: Vec<PredicateObligation<'tcx>>,

Diff for: compiler/rustc_middle/src/hir/place.rs

-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ pub struct Place<'tcx> {
6666
///
6767
/// This is an HIR version of [`rustc_middle::mir::Place`].
6868
#[derive(Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
69-
#[derive(TypeFoldable, TypeVisitable)]
7069
pub struct PlaceWithHirId<'tcx> {
7170
/// `HirId` of the expression or pattern producing this value.
7271
pub hir_id: HirId,

Diff for: compiler/rustc_middle/src/mir/mod.rs

+3-24
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::mir::visit::MirVisitable;
99
use crate::ty::codec::{TyDecoder, TyEncoder};
1010
use crate::ty::fold::{FallibleTypeFolder, TypeFoldable};
1111
use crate::ty::print::{FmtPrinter, Printer};
12-
use crate::ty::visit::{TypeVisitable, TypeVisitableExt, TypeVisitor};
12+
use crate::ty::visit::TypeVisitableExt;
1313
use crate::ty::{self, List, Ty, TyCtxt};
1414
use crate::ty::{AdtDef, InstanceDef, ScalarInt, UserTypeAnnotationIndex};
1515
use crate::ty::{GenericArg, InternalSubsts, SubstsRef};
@@ -36,7 +36,7 @@ use either::Either;
3636

3737
use std::borrow::Cow;
3838
use std::fmt::{self, Debug, Display, Formatter, Write};
39-
use std::ops::{ControlFlow, Index, IndexMut};
39+
use std::ops::{Index, IndexMut};
4040
use std::{iter, mem};
4141

4242
pub use self::query::*;
@@ -2722,6 +2722,7 @@ impl<'tcx> UserTypeProjections {
27222722
/// `field[0]` (aka `.0`), indicating that the type of `s` is
27232723
/// determined by finding the type of the `.0` field from `T`.
27242724
#[derive(Clone, Debug, TyEncodable, TyDecodable, Hash, HashStable, PartialEq)]
2725+
#[derive(TypeFoldable, TypeVisitable)]
27252726
pub struct UserTypeProjection {
27262727
pub base: UserTypeAnnotationIndex,
27272728
pub projs: Vec<ProjectionKind>,
@@ -2765,28 +2766,6 @@ impl UserTypeProjection {
27652766
}
27662767
}
27672768

2768-
impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for UserTypeProjection {
2769-
fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
2770-
self,
2771-
folder: &mut F,
2772-
) -> Result<Self, F::Error> {
2773-
Ok(UserTypeProjection {
2774-
base: self.base.try_fold_with(folder)?,
2775-
projs: self.projs.try_fold_with(folder)?,
2776-
})
2777-
}
2778-
}
2779-
2780-
impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for UserTypeProjection {
2781-
fn visit_with<Vs: TypeVisitor<TyCtxt<'tcx>>>(
2782-
&self,
2783-
visitor: &mut Vs,
2784-
) -> ControlFlow<Vs::BreakTy> {
2785-
self.base.visit_with(visitor)
2786-
// Note: there's nothing in `self.proj` to visit.
2787-
}
2788-
}
2789-
27902769
rustc_index::newtype_index! {
27912770
#[derive(HashStable)]
27922771
#[debug_format = "promoted[{}]"]

Diff for: compiler/rustc_middle/src/thir.rs

-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ pub enum StmtKind<'tcx> {
234234
}
235235

236236
#[derive(Clone, Debug, Copy, PartialEq, Eq, Hash, HashStable, TyEncodable, TyDecodable)]
237-
#[derive(TypeFoldable, TypeVisitable)]
238237
pub struct LocalVarId(pub hir::HirId);
239238

240239
/// A THIR expression.

Diff for: compiler/rustc_middle/src/traits/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ pub struct DerivedObligationCause<'tcx> {
569569
pub parent_code: InternedObligationCauseCode<'tcx>,
570570
}
571571

572-
#[derive(Clone, Debug, TypeFoldable, TypeVisitable, Lift)]
572+
#[derive(Clone, Debug, TypeVisitable, Lift)]
573573
pub enum SelectionError<'tcx> {
574574
/// The trait is not implemented.
575575
Unimplemented,

Diff for: compiler/rustc_middle/src/traits/select.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ pub type EvaluationCache<'tcx> = Cache<
103103
/// required for associated types to work in default impls, as the bounds
104104
/// are visible both as projection bounds and as where-clauses from the
105105
/// parameter environment.
106-
#[derive(PartialEq, Eq, Debug, Clone, TypeFoldable, TypeVisitable)]
106+
#[derive(PartialEq, Eq, Debug, Clone, TypeVisitable)]
107107
pub enum SelectionCandidate<'tcx> {
108108
/// A builtin implementation for some specific traits, used in cases
109109
/// where we cannot rely an ordinary library implementations.

Diff for: compiler/rustc_middle/src/traits/solve.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl<'tcx> std::ops::Deref for ExternalConstraints<'tcx> {
120120
}
121121

122122
/// Additional constraints returned on success.
123-
#[derive(Debug, PartialEq, Eq, Clone, Hash, Default, TypeFoldable, TypeVisitable)]
123+
#[derive(Debug, PartialEq, Eq, Clone, Hash, Default)]
124124
pub struct ExternalConstraintsData<'tcx> {
125125
// FIXME: implement this.
126126
pub region_constraints: QueryRegionConstraints<'tcx>,

Diff for: compiler/rustc_middle/src/ty/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl<T> ExpectedFound<T> {
2828
}
2929

3030
// Data structures used in type unification
31-
#[derive(Copy, Clone, Debug, TypeFoldable, TypeVisitable, Lift, PartialEq, Eq)]
31+
#[derive(Copy, Clone, Debug, TypeVisitable, Lift, PartialEq, Eq)]
3232
#[rustc_pass_by_value]
3333
pub enum TypeError<'tcx> {
3434
Mismatch,

Diff for: compiler/rustc_middle/src/ty/print/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2690,7 +2690,7 @@ impl<'tcx> ty::PolyTraitPredicate<'tcx> {
26902690
}
26912691
}
26922692

2693-
#[derive(Debug, Copy, Clone, TypeFoldable, TypeVisitable, Lift)]
2693+
#[derive(Debug, Copy, Clone, Lift)]
26942694
pub struct PrintClosureAsImpl<'tcx> {
26952695
pub closure: ty::ClosureSubsts<'tcx>,
26962696
}

Diff for: compiler/rustc_middle/src/ty/structural_impls.rs

-20
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
//! to help with the tedium.
55
66
use crate::mir::interpret;
7-
use crate::mir::ProjectionKind;
87
use crate::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeSuperFoldable};
98
use crate::ty::print::{with_no_trimmed_paths, FmtPrinter, Printer};
109
use crate::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitor};
@@ -373,16 +372,6 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ParamEnv<'a> {
373372
///////////////////////////////////////////////////////////////////////////
374373
// Traversal implementations.
375374

376-
/// AdtDefs are basically the same as a DefId.
377-
impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for ty::AdtDef<'tcx> {
378-
fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
379-
self,
380-
_folder: &mut F,
381-
) -> Result<Self, F::Error> {
382-
Ok(self)
383-
}
384-
}
385-
386375
impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for ty::AdtDef<'tcx> {
387376
fn visit_with<V: TypeVisitor<TyCtxt<'tcx>>>(
388377
&self,
@@ -445,15 +434,6 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx ty::List<ty::Const<'tcx>> {
445434
}
446435
}
447436

448-
impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx ty::List<ProjectionKind> {
449-
fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
450-
self,
451-
folder: &mut F,
452-
) -> Result<Self, F::Error> {
453-
ty::util::fold_list(self, folder, |tcx, v| tcx.mk_projs(v))
454-
}
455-
}
456-
457437
impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for Ty<'tcx> {
458438
fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
459439
self,

Diff for: compiler/rustc_middle/src/ty/sty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ impl<'tcx> UpvarSubsts<'tcx> {
631631
/// type of the constant. The reason that `R` is represented as an extra type parameter
632632
/// is the same reason that [`ClosureSubsts`] have `CS` and `U` as type parameters:
633633
/// inline const can reference lifetimes that are internal to the creating function.
634-
#[derive(Copy, Clone, Debug, TypeFoldable, TypeVisitable)]
634+
#[derive(Copy, Clone, Debug)]
635635
pub struct InlineConstSubsts<'tcx> {
636636
/// Generic parameters from the enclosing item,
637637
/// concatenated with the inferred type of the constant.

Diff for: compiler/rustc_query_system/src/dep_graph/graph.rs

+32-64
Original file line numberDiff line numberDiff line change
@@ -354,24 +354,20 @@ impl<K: DepKind> DepGraphData<K> {
354354
- dep-node: {key:?}"
355355
);
356356

357-
let task_deps = if cx.dep_context().is_eval_always(key.kind) {
358-
None
357+
let with_deps = |task_deps| K::with_deps(task_deps, || task(cx, arg));
358+
let (result, edges) = if cx.dep_context().is_eval_always(key.kind) {
359+
(with_deps(TaskDepsRef::EvalAlways), smallvec![])
359360
} else {
360-
Some(Lock::new(TaskDeps {
361+
let task_deps = Lock::new(TaskDeps {
361362
#[cfg(debug_assertions)]
362363
node: Some(key),
363364
reads: SmallVec::new(),
364365
read_set: Default::default(),
365366
phantom_data: PhantomData,
366-
}))
367+
});
368+
(with_deps(TaskDepsRef::Allow(&task_deps)), task_deps.into_inner().reads)
367369
};
368370

369-
let task_deps_ref =
370-
task_deps.as_ref().map(TaskDepsRef::Allow).unwrap_or(TaskDepsRef::EvalAlways);
371-
372-
let result = K::with_deps(task_deps_ref, || task(cx, arg));
373-
let edges = task_deps.map_or_else(|| smallvec![], |lock| lock.into_inner().reads);
374-
375371
let dcx = cx.dep_context();
376372
let hashing_timer = dcx.profiler().incr_result_hashing();
377373
let current_fingerprint =
@@ -1236,76 +1232,48 @@ impl<K: DepKind> CurrentDepGraph<K> {
12361232
self.node_intern_event_id.map(|eid| profiler.generic_activity_with_event_id(eid));
12371233

12381234
if let Some(prev_index) = prev_graph.node_to_index_opt(&key) {
1235+
let get_dep_node_index = |color, fingerprint| {
1236+
if print_status {
1237+
eprintln!("[task::{color:}] {key:?}");
1238+
}
1239+
1240+
let mut prev_index_to_index = self.prev_index_to_index.lock();
1241+
1242+
let dep_node_index = match prev_index_to_index[prev_index] {
1243+
Some(dep_node_index) => dep_node_index,
1244+
None => {
1245+
let dep_node_index =
1246+
self.encoder.borrow().send(profiler, key, fingerprint, edges);
1247+
prev_index_to_index[prev_index] = Some(dep_node_index);
1248+
dep_node_index
1249+
}
1250+
};
1251+
1252+
#[cfg(debug_assertions)]
1253+
self.record_edge(dep_node_index, key, fingerprint);
1254+
1255+
dep_node_index
1256+
};
1257+
12391258
// Determine the color and index of the new `DepNode`.
12401259
if let Some(fingerprint) = fingerprint {
12411260
if fingerprint == prev_graph.fingerprint_by_index(prev_index) {
1242-
if print_status {
1243-
eprintln!("[task::green] {key:?}");
1244-
}
1245-
12461261
// This is a green node: it existed in the previous compilation,
12471262
// its query was re-executed, and it has the same result as before.
1248-
let mut prev_index_to_index = self.prev_index_to_index.lock();
1249-
1250-
let dep_node_index = match prev_index_to_index[prev_index] {
1251-
Some(dep_node_index) => dep_node_index,
1252-
None => {
1253-
let dep_node_index =
1254-
self.encoder.borrow().send(profiler, key, fingerprint, edges);
1255-
prev_index_to_index[prev_index] = Some(dep_node_index);
1256-
dep_node_index
1257-
}
1258-
};
1259-
1260-
#[cfg(debug_assertions)]
1261-
self.record_edge(dep_node_index, key, fingerprint);
1263+
let dep_node_index = get_dep_node_index("green", fingerprint);
12621264
(dep_node_index, Some((prev_index, DepNodeColor::Green(dep_node_index))))
12631265
} else {
1264-
if print_status {
1265-
eprintln!("[task::red] {key:?}");
1266-
}
1267-
12681266
// This is a red node: it existed in the previous compilation, its query
12691267
// was re-executed, but it has a different result from before.
1270-
let mut prev_index_to_index = self.prev_index_to_index.lock();
1271-
1272-
let dep_node_index = match prev_index_to_index[prev_index] {
1273-
Some(dep_node_index) => dep_node_index,
1274-
None => {
1275-
let dep_node_index =
1276-
self.encoder.borrow().send(profiler, key, fingerprint, edges);
1277-
prev_index_to_index[prev_index] = Some(dep_node_index);
1278-
dep_node_index
1279-
}
1280-
};
1281-
1282-
#[cfg(debug_assertions)]
1283-
self.record_edge(dep_node_index, key, fingerprint);
1268+
let dep_node_index = get_dep_node_index("red", fingerprint);
12841269
(dep_node_index, Some((prev_index, DepNodeColor::Red)))
12851270
}
12861271
} else {
1287-
if print_status {
1288-
eprintln!("[task::unknown] {key:?}");
1289-
}
1290-
12911272
// This is a red node, effectively: it existed in the previous compilation
12921273
// session, its query was re-executed, but it doesn't compute a result hash
12931274
// (i.e. it represents a `no_hash` query), so we have no way of determining
12941275
// whether or not the result was the same as before.
1295-
let mut prev_index_to_index = self.prev_index_to_index.lock();
1296-
1297-
let dep_node_index = match prev_index_to_index[prev_index] {
1298-
Some(dep_node_index) => dep_node_index,
1299-
None => {
1300-
let dep_node_index =
1301-
self.encoder.borrow().send(profiler, key, Fingerprint::ZERO, edges);
1302-
prev_index_to_index[prev_index] = Some(dep_node_index);
1303-
dep_node_index
1304-
}
1305-
};
1306-
1307-
#[cfg(debug_assertions)]
1308-
self.record_edge(dep_node_index, key, Fingerprint::ZERO);
1276+
let dep_node_index = get_dep_node_index("unknown", Fingerprint::ZERO);
13091277
(dep_node_index, Some((prev_index, DepNodeColor::Red)))
13101278
}
13111279
} else {

Diff for: compiler/rustc_transmute/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ mod rustc {
6262

6363
use rustc_hir::lang_items::LangItem;
6464
use rustc_infer::infer::InferCtxt;
65-
use rustc_macros::{TypeFoldable, TypeVisitable};
65+
use rustc_macros::TypeVisitable;
6666
use rustc_middle::traits::ObligationCause;
6767
use rustc_middle::ty::Const;
6868
use rustc_middle::ty::ParamEnv;
6969
use rustc_middle::ty::Ty;
7070
use rustc_middle::ty::TyCtxt;
7171

7272
/// The source and destination types of a transmutation.
73-
#[derive(TypeFoldable, TypeVisitable, Debug, Clone, Copy)]
73+
#[derive(TypeVisitable, Debug, Clone, Copy)]
7474
pub struct Types<'tcx> {
7575
/// The source type.
7676
pub src: Ty<'tcx>,

Diff for: compiler/rustc_type_ir/src/structural_impls.rs

+7-28
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ use crate::fold::{FallibleTypeFolder, TypeFoldable};
66
use crate::visit::{TypeVisitable, TypeVisitor};
77
use crate::Interner;
88
use rustc_data_structures::functor::IdFunctor;
9+
use rustc_data_structures::sync::Lrc;
910
use rustc_index::{Idx, IndexVec};
1011

1112
use std::ops::ControlFlow;
12-
use std::rc::Rc;
13-
use std::sync::Arc;
1413

1514
///////////////////////////////////////////////////////////////////////////
1615
// Atomic structs
@@ -106,25 +105,13 @@ impl<I: Interner, T: TypeVisitable<I>, E: TypeVisitable<I>> TypeVisitable<I> for
106105
}
107106
}
108107

109-
impl<I: Interner, T: TypeFoldable<I>> TypeFoldable<I> for Rc<T> {
108+
impl<I: Interner, T: TypeFoldable<I>> TypeFoldable<I> for Lrc<T> {
110109
fn try_fold_with<F: FallibleTypeFolder<I>>(self, folder: &mut F) -> Result<Self, F::Error> {
111110
self.try_map_id(|value| value.try_fold_with(folder))
112111
}
113112
}
114113

115-
impl<I: Interner, T: TypeVisitable<I>> TypeVisitable<I> for Rc<T> {
116-
fn visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
117-
(**self).visit_with(visitor)
118-
}
119-
}
120-
121-
impl<I: Interner, T: TypeFoldable<I>> TypeFoldable<I> for Arc<T> {
122-
fn try_fold_with<F: FallibleTypeFolder<I>>(self, folder: &mut F) -> Result<Self, F::Error> {
123-
self.try_map_id(|value| value.try_fold_with(folder))
124-
}
125-
}
126-
127-
impl<I: Interner, T: TypeVisitable<I>> TypeVisitable<I> for Arc<T> {
114+
impl<I: Interner, T: TypeVisitable<I>> TypeVisitable<I> for Lrc<T> {
128115
fn visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
129116
(**self).visit_with(visitor)
130117
}
@@ -154,19 +141,11 @@ impl<I: Interner, T: TypeVisitable<I>> TypeVisitable<I> for Vec<T> {
154141
}
155142
}
156143

157-
impl<I: Interner, T: TypeVisitable<I>> TypeVisitable<I> for &[T] {
158-
fn visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
159-
self.iter().try_for_each(|t| t.visit_with(visitor))
160-
}
161-
}
162-
163-
impl<I: Interner, T: TypeFoldable<I>> TypeFoldable<I> for Box<[T]> {
164-
fn try_fold_with<F: FallibleTypeFolder<I>>(self, folder: &mut F) -> Result<Self, F::Error> {
165-
self.try_map_id(|t| t.try_fold_with(folder))
166-
}
167-
}
144+
// `TypeFoldable` isn't impl'd for `&[T]`. It doesn't make sense in the general
145+
// case, because we can't return a new slice. But note that there are a couple
146+
// of trivial impls of `TypeFoldable` for specific slice types elsewhere.
168147

169-
impl<I: Interner, T: TypeVisitable<I>> TypeVisitable<I> for Box<[T]> {
148+
impl<I: Interner, T: TypeVisitable<I>> TypeVisitable<I> for &[T] {
170149
fn visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
171150
self.iter().try_for_each(|t| t.visit_with(visitor))
172151
}

0 commit comments

Comments
 (0)