Auto merge of #3700 - phansch:would_you_like_some_help_with_this_const_fn, r=oli-obk
Prevent incorrect cast_lossless suggestion in const_fn `::from` is not a const fn, so applying the suggestion of `cast_lossless` would fail to compile. The fix is to skip the lint if the cast is found inside a const fn. Fixes #3656
This commit is contained in:
@@ -82,6 +82,10 @@ pub fn in_constant(cx: &LateContext<'_, '_>, id: NodeId) -> bool {
|
||||
node: ItemKind::Static(..),
|
||||
..
|
||||
}) => true,
|
||||
Node::Item(&Item {
|
||||
node: ItemKind::Fn(_, header, ..),
|
||||
..
|
||||
}) => header.constness == Constness::Const,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user