@@ -335,16 +335,17 @@ impl dyn Error {
335
335
#[ unstable( feature = "error_iter" , issue = "58520" ) ]
336
336
#[ inline]
337
337
pub fn sources ( & self ) -> Source < ' _ > {
338
- // You may think this method would be better in the Error trait, and you'd be right.
339
- // Unfortunately that doesn't work, not because of the object safety rules but because we
340
- // save a reference to self in Sources below as a trait object. If this method was
341
- // declared in Error, then self would have the type &T where T is some concrete type which
342
- // implements Error. We would need to coerce self to have type &dyn Error, but that requires
343
- // that Self has a known size (i.e., Self: Sized). We can't put that bound on Error
344
- // since that would forbid Error trait objects, and we can't put that bound on the method
345
- // because that means the method can't be called on trait objects (we'd also need the
346
- // 'static bound, but that isn't allowed because methods with bounds on Self other than
347
- // Sized are not object-safe). Requiring an Unsize bound is not backwards compatible.
338
+ // You may think this method would be better in the `Error` trait, and you'd be right.
339
+ // Unfortunately that doesn't work, not because of the dyn-incompatibility rules but
340
+ // because we save a reference to `self` in `Source`s below as a trait object.
341
+ // If this method was declared in `Error`, then `self` would have the type `&T` where
342
+ // `T` is some concrete type which implements `Error`. We would need to coerce `self`
343
+ // to have type `&dyn Error`, but that requires that `Self` has a known size
344
+ // (i.e., `Self: Sized`). We can't put that bound on `Error` since that would forbid
345
+ // `Error` trait objects, and we can't put that bound on the method because that means
346
+ // the method can't be called on trait objects (we'd also need the `'static` bound,
347
+ // but that isn't allowed because methods with bounds on `Self` other than `Sized` are
348
+ // dyn-incompatible). Requiring an `Unsize` bound is not backwards compatible.
348
349
349
350
Source { current : Some ( self ) }
350
351
}
0 commit comments