clippy::let_and_return
suggestion causes error because value does not live long enough
#13735
Labels
C-bug
Category: Clippy is not doing the correct thing
I-suggestion-causes-error
Issue: The suggestions provided by this Lint cause an ICE/error when applied
Summary
title, but that is only an assumption about what happens. It seems to me that this should be able to compile, because the closure returns something that lives for
'static
.This is a stripped down bug reproducer based on real code, this explains the nested RefCell (from a graph) and &usize (replaced a non-copy struct with usize).
The only difference between the function bodies of
reproduce_bug
andno_bug
is thatreproduce_bug
has the output ofsome_function(...)
wrapped withSome(...?)
.In both functions the code fails to compile when the value of
x
is returned directly, but clippy only suggests this forreproduce_bug
Reproducer
I tried this code:
I expected to see this happen:
Instead, this happened:
Version
Additional Labels
@rustbot label +I-suggestion-causes-error
The text was updated successfully, but these errors were encountered: