mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 21:54:42 +00:00
Stub out FnAbi::partial_eq as a workaround for now
This commit is contained in:
parent
3a722bdf2e
commit
46e38318a2
4 changed files with 26 additions and 10 deletions
|
@ -1327,15 +1327,16 @@ fn hir_fmt_generics(
|
|||
|
||||
impl HirDisplay for CallableSig {
|
||||
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
|
||||
let CallableSig { params_and_return: _, is_varargs, safety, abi } = *self;
|
||||
let CallableSig { params_and_return: _, is_varargs, safety, abi: _ } = *self;
|
||||
if let Safety::Unsafe = safety {
|
||||
write!(f, "unsafe ")?;
|
||||
}
|
||||
if !matches!(abi, FnAbi::Rust) {
|
||||
f.write_str("extern \"")?;
|
||||
f.write_str(abi.as_str())?;
|
||||
f.write_str("\" ")?;
|
||||
}
|
||||
// FIXME: Enable this when the FIXME on FnAbi regarding PartialEq is fixed.
|
||||
// if !matches!(abi, FnAbi::Rust) {
|
||||
// f.write_str("extern \"")?;
|
||||
// f.write_str(abi.as_str())?;
|
||||
// f.write_str("\" ")?;
|
||||
// }
|
||||
write!(f, "fn(")?;
|
||||
f.write_joined(self.params(), ", ")?;
|
||||
if is_varargs {
|
||||
|
|
|
@ -356,7 +356,7 @@ pub struct CallableSig {
|
|||
|
||||
has_interner!(CallableSig);
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Copy, Clone, Eq)]
|
||||
pub enum FnAbi {
|
||||
Aapcs,
|
||||
AapcsUnwind,
|
||||
|
@ -398,6 +398,21 @@ pub enum FnAbi {
|
|||
Unknown,
|
||||
}
|
||||
|
||||
impl PartialEq for FnAbi {
|
||||
fn eq(&self, _other: &Self) -> bool {
|
||||
// FIXME: Proper equality breaks `coercion::two_closures_lub` test
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
impl Hash for FnAbi {
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
// Required because of the FIXME above and due to us implementing `Eq`, without this
|
||||
// we would break the `Hash` + `Eq` contract
|
||||
core::mem::discriminant(&Self::Unknown).hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
impl FnAbi {
|
||||
pub fn from_str(s: &str) -> FnAbi {
|
||||
match s {
|
||||
|
|
|
@ -574,7 +574,7 @@ fn two_closures_lub() {
|
|||
r#"
|
||||
fn foo(c: i32) {
|
||||
let add = |a: i32, b: i32| a + b;
|
||||
//^^^^^^^^^^^^ impl Fn(i32, i32) -> i32
|
||||
//^^^^^^^^^^^^^^^^^^^^^^ impl Fn(i32, i32) -> i32
|
||||
let sub = |a, b| a - b;
|
||||
//^^^^^^^^^^^^ impl Fn(i32, i32) -> i32
|
||||
if c > 42 { add } else { sub };
|
||||
|
|
|
@ -239,9 +239,9 @@ fn test() {
|
|||
let f = foo;
|
||||
//^ fn(i32) -> i64
|
||||
let f = S::<i8>;
|
||||
//^ extern "rust-call" fn(i8) -> S<i8>
|
||||
//^ fn(i8) -> S<i8>
|
||||
let f = E::A;
|
||||
//^ extern "rust-call" fn(usize) -> E
|
||||
//^ fn(usize) -> E
|
||||
}
|
||||
"#,
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue