diff options
| author | bors <bors@rust-lang.org> | 2022-12-13 13:09:40 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-12-13 13:09:40 +0000 |
| commit | ed620cf9690fdafed65845bf35c455db992fbba1 (patch) | |
| tree | 2207ed09adb1647b55a716a4e02e37f140560ac9 /compiler | |
| parent | 109cccbe4f345c0f0785ce860788580c3e2a29f5 (diff) | |
| parent | 30754517d1e979bd4100207f1cc7202ed25d9ff5 (diff) | |
| download | rust-ed620cf9690fdafed65845bf35c455db992fbba1.tar.gz rust-ed620cf9690fdafed65845bf35c455db992fbba1.zip | |
Auto merge of #105612 - oli-obk:bind_rustdoc, r=GuillaumeGomez
use ty::Binder in rustdoc instead of `skip_binder` r? `@GuillaumeGomez` this is a preliminary cleanup required to be able to normalize correctly/conveniently in rustdoc
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_middle/src/ty/sty.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 64033c351b1..9b9c26d6a8b 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -980,8 +980,12 @@ where /// contain any bound vars that would be bound by the /// binder. This is commonly used to 'inject' a value T into a /// different binding level. + #[track_caller] pub fn dummy(value: T) -> Binder<'tcx, T> { - assert!(!value.has_escaping_bound_vars()); + assert!( + !value.has_escaping_bound_vars(), + "`{value:?}` has escaping bound vars, so it cannot be wrapped in a dummy binder." + ); Binder(value, ty::List::empty()) } @@ -1128,6 +1132,13 @@ impl<'tcx, T> Binder<'tcx, Option<T>> { } } +impl<'tcx, T: IntoIterator> Binder<'tcx, T> { + pub fn iter(self) -> impl Iterator<Item = ty::Binder<'tcx, T::Item>> { + let bound_vars = self.1; + self.0.into_iter().map(|v| Binder(v, bound_vars)) + } +} + /// Represents the projection of an associated type. In explicit UFCS /// form this would be written `<T as Trait<..>>::N`. #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)] |
