mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Do not suggest "wrapping the expression in std::num::NonZeroU64
"
This commit is contained in:
parent
c2ecd3af87
commit
37c21d6fc7
@ -19,6 +19,7 @@ use rustc_span::{BytePos, Span};
|
||||
use super::method::probe;
|
||||
|
||||
use std::iter;
|
||||
use std::ops::Bound;
|
||||
|
||||
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
pub fn emit_coerce_suggestions(
|
||||
@ -347,6 +348,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
// Avoid suggesting wrapping in `NonZeroU64` and alike
|
||||
if self.tcx.layout_scalar_valid_range(expected_adt.did())
|
||||
!= (Bound::Unbounded, Bound::Unbounded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
let compatible_variants: Vec<String> = expected_adt
|
||||
.variants()
|
||||
.iter()
|
||||
|
Loading…
Reference in New Issue
Block a user