mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Rollup merge of #103176 - nnethercote:fix-TyKind-is_simple_path, r=spastorino
Fix `TyKind::is_simple_path` Fixes #103157. r? `@spastorino`
This commit is contained in:
commit
e86bc89831
@ -2060,8 +2060,11 @@ impl TyKind {
|
||||
}
|
||||
|
||||
pub fn is_simple_path(&self) -> Option<Symbol> {
|
||||
if let TyKind::Path(None, Path { segments, .. }) = &self && segments.len() == 1 {
|
||||
Some(segments[0].ident.name)
|
||||
if let TyKind::Path(None, Path { segments, .. }) = &self
|
||||
&& let [segment] = &segments[..]
|
||||
&& segment.args.is_none()
|
||||
{
|
||||
Some(segment.ident.name)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ enum Mixed {
|
||||
P,
|
||||
Q,
|
||||
R(u32),
|
||||
S { d1: u32, d2: u32 },
|
||||
S { d1: Option<u32>, d2: Option<i32> },
|
||||
}
|
||||
|
||||
// An enum with no fieldless variants. Note that `Default` cannot be derived
|
||||
|
@ -809,8 +809,8 @@ enum Mixed {
|
||||
Q,
|
||||
R(u32),
|
||||
S {
|
||||
d1: u32,
|
||||
d2: u32,
|
||||
d1: Option<u32>,
|
||||
d2: Option<i32>,
|
||||
},
|
||||
}
|
||||
#[automatically_derived]
|
||||
@ -818,6 +818,8 @@ impl ::core::clone::Clone for Mixed {
|
||||
#[inline]
|
||||
fn clone(&self) -> Mixed {
|
||||
let _: ::core::clone::AssertParamIsClone<u32>;
|
||||
let _: ::core::clone::AssertParamIsClone<Option<u32>>;
|
||||
let _: ::core::clone::AssertParamIsClone<Option<i32>>;
|
||||
*self
|
||||
}
|
||||
}
|
||||
@ -886,6 +888,8 @@ impl ::core::cmp::Eq for Mixed {
|
||||
#[no_coverage]
|
||||
fn assert_receiver_is_total_eq(&self) -> () {
|
||||
let _: ::core::cmp::AssertParamIsEq<u32>;
|
||||
let _: ::core::cmp::AssertParamIsEq<Option<u32>>;
|
||||
let _: ::core::cmp::AssertParamIsEq<Option<i32>>;
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
|
12
src/test/ui/deriving/issue-103157.rs
Normal file
12
src/test/ui/deriving/issue-103157.rs
Normal file
@ -0,0 +1,12 @@
|
||||
// check-fail
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub enum Value {
|
||||
Boolean(Option<bool>),
|
||||
Float(Option<f64>), //~ ERROR the trait bound `f64: Eq` is not satisfied
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let a = Value::Float(Some(f64::NAN));
|
||||
assert!(a == a);
|
||||
}
|
30
src/test/ui/deriving/issue-103157.stderr
Normal file
30
src/test/ui/deriving/issue-103157.stderr
Normal file
@ -0,0 +1,30 @@
|
||||
error[E0277]: the trait bound `f64: Eq` is not satisfied
|
||||
--> $DIR/issue-103157.rs:6:11
|
||||
|
|
||||
LL | #[derive(PartialEq, Eq)]
|
||||
| -- in this derive macro expansion
|
||||
...
|
||||
LL | Float(Option<f64>),
|
||||
| ^^^^^^^^^^^ the trait `Eq` is not implemented for `f64`
|
||||
|
|
||||
= help: the following other types implement trait `Eq`:
|
||||
i128
|
||||
i16
|
||||
i32
|
||||
i64
|
||||
i8
|
||||
isize
|
||||
u128
|
||||
u16
|
||||
and 4 others
|
||||
= note: required for `Option<f64>` to implement `Eq`
|
||||
note: required by a bound in `AssertParamIsEq`
|
||||
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
||||
|
|
||||
LL | pub struct AssertParamIsEq<T: Eq + ?Sized> {
|
||||
| ^^ required by this bound in `AssertParamIsEq`
|
||||
= note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
Loading…
Reference in New Issue
Block a user