summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_middle/src/traits/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_middle/src/traits/mod.rs')
-rw-r--r--compiler/rustc_middle/src/traits/mod.rs38
1 files changed, 31 insertions, 7 deletions
diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs
index 6231dd9b6..91f07389f 100644
--- a/compiler/rustc_middle/src/traits/mod.rs
+++ b/compiler/rustc_middle/src/traits/mod.rs
@@ -305,8 +305,6 @@ pub enum ObligationCauseCode<'tcx> {
SizedReturnType,
/// Yield type must be `Sized`.
SizedYieldType,
- /// Box expression result type must be `Sized`.
- SizedBoxType,
/// Inline asm operand type must be `Sized`.
InlineAsmSized,
/// `[expr; N]` requires `type_of(expr): Copy`.
@@ -699,9 +697,9 @@ impl<'tcx, N> ImplSource<'tcx, N> {
}
pub fn borrow_nested_obligations(&self) -> &[N] {
- match &self {
- ImplSource::UserDefined(i) => &i.nested[..],
- ImplSource::Param(n, _) => &n,
+ match self {
+ ImplSource::UserDefined(i) => &i.nested,
+ ImplSource::Param(n, _) => n,
ImplSource::Builtin(i) => &i.nested,
ImplSource::AutoImpl(d) => &d.nested,
ImplSource::Closure(c) => &c.nested,
@@ -715,6 +713,23 @@ impl<'tcx, N> ImplSource<'tcx, N> {
}
}
+ pub fn borrow_nested_obligations_mut(&mut self) -> &mut [N] {
+ match self {
+ ImplSource::UserDefined(i) => &mut i.nested,
+ ImplSource::Param(n, _) => n,
+ ImplSource::Builtin(i) => &mut i.nested,
+ ImplSource::AutoImpl(d) => &mut d.nested,
+ ImplSource::Closure(c) => &mut c.nested,
+ ImplSource::Generator(c) => &mut c.nested,
+ ImplSource::Future(c) => &mut c.nested,
+ ImplSource::Object(d) => &mut d.nested,
+ ImplSource::FnPointer(d) => &mut d.nested,
+ ImplSource::TraitAlias(d) => &mut d.nested,
+ ImplSource::TraitUpcasting(d) => &mut d.nested,
+ ImplSource::ConstDestruct(i) => &mut i.nested,
+ }
+ }
+
pub fn map<M, F>(self, f: F) -> ImplSource<'tcx, M>
where
F: FnMut(N) -> M,
@@ -899,6 +914,9 @@ pub enum ObjectSafetyViolation {
/// (e.g., `trait Foo : Bar<Self>`).
SupertraitSelf(SmallVec<[Span; 1]>),
+ // Supertrait has a non-lifetime `for<T>` binder.
+ SupertraitNonLifetimeBinder(SmallVec<[Span; 1]>),
+
/// Method has something illegal.
Method(Symbol, MethodViolationCode, Span),
@@ -921,6 +939,9 @@ impl ObjectSafetyViolation {
.into()
}
}
+ ObjectSafetyViolation::SupertraitNonLifetimeBinder(_) => {
+ "where clause cannot reference non-lifetime `for<...>` variables".into()
+ }
ObjectSafetyViolation::Method(name, MethodViolationCode::StaticMethod(_), _) => {
format!("associated function `{}` has no `self` parameter", name).into()
}
@@ -971,7 +992,9 @@ impl ObjectSafetyViolation {
pub fn solution(&self, err: &mut Diagnostic) {
match self {
- ObjectSafetyViolation::SizedSelf(_) | ObjectSafetyViolation::SupertraitSelf(_) => {}
+ ObjectSafetyViolation::SizedSelf(_)
+ | ObjectSafetyViolation::SupertraitSelf(_)
+ | ObjectSafetyViolation::SupertraitNonLifetimeBinder(..) => {}
ObjectSafetyViolation::Method(
name,
MethodViolationCode::StaticMethod(Some((add_self_sugg, make_sized_sugg))),
@@ -1025,7 +1048,8 @@ impl ObjectSafetyViolation {
// diagnostics use a `note` instead of a `span_label`.
match self {
ObjectSafetyViolation::SupertraitSelf(spans)
- | ObjectSafetyViolation::SizedSelf(spans) => spans.clone(),
+ | ObjectSafetyViolation::SizedSelf(spans)
+ | ObjectSafetyViolation::SupertraitNonLifetimeBinder(spans) => spans.clone(),
ObjectSafetyViolation::AssocConst(_, span)
| ObjectSafetyViolation::GAT(_, span)
| ObjectSafetyViolation::Method(_, _, span)