Unused trait bound with lifetime causes compile error #53156
Labels
A-trait-system
Area: Trait system
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Summary
What happens
Into::<Arc<B>>::into()
is completely unused, but&'a B: Into<Arc<B>>
causes compile error.&a B: Into<Arc<B>>
tofor<'b> &'b B: Into<Arc<B>>
.&self
to&'a self
(orwrap: &OwnedWrap<B>
towrap: &'a OwnedWrap<B>
).Expected behavior
where B: 'a + ToOwned + ?Sized, &'a B: Into<Arc<B>>
,let b: &B = owned.borrow();
successfully compiles.let b: &B = owned.borrow();
does not requireb
to outlive lifetime of&self
nor'a
,so it should not be error.
owned.borrow().into()
might be error though, but I think it is OK becauseowned.borrow()
does not outlive'a
butInto<Arc<B>>
requires'a &B
.Meta
Code to reproduce
Simplified cases 1: in impl
Basic code: https://play.rust-lang.org/?gist=40cb0fa71f3bd32091fbc3e144db2de1&version=stable&mode=debug&edition=2015
Borrow::borrow()
causes compile error with NLL, but compiles without NLL #53151.Error for (1a-2a-3a) without NLL:
Error for (1a2a-3a) with NLL:
Simplified cases 2: toplevel fn
Basic code: https://play.rust-lang.org/?gist=649f1a00835b68d4b51ef4a78a5ac857&version=stable&mode=debug&edition=2015
Borrow::borrow()
causes compile error with NLL, but compiles without NLL #53151.FYI: What I've wanted to do
This code is more meaningful than simplified cases.
https://play.rust-lang.org/?gist=2b304fda2af1102dff60b72b5681a945&version=nightly&mode=debug&edition=2015
The text was updated successfully, but these errors were encountered: