diff options
| -rw-r--r-- | compiler/rustc_typeck/src/check/inherited.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/coercion/issue-101066.rs | 16 |
2 files changed, 17 insertions, 0 deletions
diff --git a/compiler/rustc_typeck/src/check/inherited.rs b/compiler/rustc_typeck/src/check/inherited.rs index cd152eb97f1..79d4ca42208 100644 --- a/compiler/rustc_typeck/src/check/inherited.rs +++ b/compiler/rustc_typeck/src/check/inherited.rs @@ -37,6 +37,7 @@ pub struct Inherited<'a, 'tcx> { // Some additional `Sized` obligations badly affect type inference. // These obligations are added in a later stage of typeck. + // Removing these may also cause additional complications, see #101066. pub(super) deferred_sized_obligations: RefCell<Vec<(Ty<'tcx>, Span, traits::ObligationCauseCode<'tcx>)>>, diff --git a/src/test/ui/coercion/issue-101066.rs b/src/test/ui/coercion/issue-101066.rs new file mode 100644 index 00000000000..b658ed1e9ab --- /dev/null +++ b/src/test/ui/coercion/issue-101066.rs @@ -0,0 +1,16 @@ +// check-pass + +use std::convert::TryFrom; + +pub trait FieldElement { + type Integer: TryFrom<usize, Error = std::num::TryFromIntError>; + + fn valid_integer_try_from<N>(i: N) -> Result<Self::Integer, ()> + where + Self::Integer: TryFrom<N>, + { + Self::Integer::try_from(i).map_err(|_| ()) + } +} + +fn main() {} |
