Repository: dtolnay/cxx (language: rust)

Issue:
Consider mandating `extern "C++"` for C++ things
We currently accept both `extern "C"` and `extern "C++"` and treat them the same.

However with #4 we may end up wanting to translate the two languages somewhat differently, in particular mapping Rust references to pointers in C and references in C++.

We can't make this change in the near term because until recently Rustfmt would silently rewrite `extern "C++"` into `extern "Rust"` (https://github.com/rust-lang/rustfmt/issues/4086). 🤦🤦‍♀️🤦‍♂️


Discussion / hints:
> Rustfmt would silently rewrite `extern "C++"` into `extern "Rust"`

If only it did that for more general C++ code.

Fix patch:
diff --git a/syntax/parse.rs b/syntax/parse.rs
index b55758420..d62899e6c 100644
--- a/syntax/parse.rs
+++ b/syntax/parse.rs
@@ -285,9 +285,9 @@ fn parse_lang(abi: &Abi) -> Result<Lang> {
         }
     };
     match name.value().as_str() {
-        "C" | "C++" => Ok(Lang::Cxx),
+        "C++" => Ok(Lang::Cxx),
         "Rust" => Ok(Lang::Rust),
-        _ => Err(Error::new_spanned(abi, "unrecognized ABI")),
+        _ => Err(Error::new_spanned(abi, "unrecognized ABI, requires either \"C++\" or \"Rust\"")),
     }
 }
 


Test patch:
diff --git a/tests/ui/multiple_parse_error.stderr b/tests/ui/multiple_parse_error.stderr
index 41895071f..7c89129b9 100644
--- a/tests/ui/multiple_parse_error.stderr
+++ b/tests/ui/multiple_parse_error.stderr
@@ -4,7 +4,7 @@ error: struct with generic parameters is not supported yet
 3 |     struct Monad<T>;
   |     ^^^^^^^^^^^^^^^
 
-error: unrecognized ABI
+error: unrecognized ABI, requires either "C++" or "Rust"
  --> $DIR/multiple_parse_error.rs:5:5
   |
 5 |     extern "Haskell" {}