mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 11:59:49 +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 {
|
impl HirDisplay for CallableSig {
|
||||||
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
|
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 {
|
if let Safety::Unsafe = safety {
|
||||||
write!(f, "unsafe ")?;
|
write!(f, "unsafe ")?;
|
||||||
}
|
}
|
||||||
if !matches!(abi, FnAbi::Rust) {
|
// FIXME: Enable this when the FIXME on FnAbi regarding PartialEq is fixed.
|
||||||
f.write_str("extern \"")?;
|
// if !matches!(abi, FnAbi::Rust) {
|
||||||
f.write_str(abi.as_str())?;
|
// f.write_str("extern \"")?;
|
||||||
f.write_str("\" ")?;
|
// f.write_str(abi.as_str())?;
|
||||||
}
|
// f.write_str("\" ")?;
|
||||||
|
// }
|
||||||
write!(f, "fn(")?;
|
write!(f, "fn(")?;
|
||||||
f.write_joined(self.params(), ", ")?;
|
f.write_joined(self.params(), ", ")?;
|
||||||
if is_varargs {
|
if is_varargs {
|
||||||
|
|
|
@ -356,7 +356,7 @@ pub struct CallableSig {
|
||||||
|
|
||||||
has_interner!(CallableSig);
|
has_interner!(CallableSig);
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Copy, Clone, Eq)]
|
||||||
pub enum FnAbi {
|
pub enum FnAbi {
|
||||||
Aapcs,
|
Aapcs,
|
||||||
AapcsUnwind,
|
AapcsUnwind,
|
||||||
|
@ -398,6 +398,21 @@ pub enum FnAbi {
|
||||||
Unknown,
|
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 {
|
impl FnAbi {
|
||||||
pub fn from_str(s: &str) -> FnAbi {
|
pub fn from_str(s: &str) -> FnAbi {
|
||||||
match s {
|
match s {
|
||||||
|
|
|
@ -574,7 +574,7 @@ fn two_closures_lub() {
|
||||||
r#"
|
r#"
|
||||||
fn foo(c: i32) {
|
fn foo(c: i32) {
|
||||||
let add = |a: i32, b: i32| a + b;
|
let add = |a: i32, b: i32| a + b;
|
||||||
//^^^^^^^^^^^^ impl Fn(i32, i32) -> i32
|
//^^^^^^^^^^^^^^^^^^^^^^ impl Fn(i32, i32) -> i32
|
||||||
let sub = |a, b| a - b;
|
let sub = |a, b| a - b;
|
||||||
//^^^^^^^^^^^^ impl Fn(i32, i32) -> i32
|
//^^^^^^^^^^^^ impl Fn(i32, i32) -> i32
|
||||||
if c > 42 { add } else { sub };
|
if c > 42 { add } else { sub };
|
||||||
|
|
|
@ -239,9 +239,9 @@ fn test() {
|
||||||
let f = foo;
|
let f = foo;
|
||||||
//^ fn(i32) -> i64
|
//^ fn(i32) -> i64
|
||||||
let f = S::<i8>;
|
let f = S::<i8>;
|
||||||
//^ extern "rust-call" fn(i8) -> S<i8>
|
//^ fn(i8) -> S<i8>
|
||||||
let f = E::A;
|
let f = E::A;
|
||||||
//^ extern "rust-call" fn(usize) -> E
|
//^ fn(usize) -> E
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue