diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-07-23 19:57:30 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-07-24 07:26:22 -0700 |
| commit | 3550068b531703bc492b0f97331c6a2bcafecf37 (patch) | |
| tree | 4f804314e83b3ed0f59dc56bd3e8405de3b353b2 /src/libsyntax/parse/parser.rs | |
| parent | 31ac8a90f1fbe66c3ad34ef0e5f48bc5f7026059 (diff) | |
| download | rust-3550068b531703bc492b0f97331c6a2bcafecf37.tar.gz rust-3550068b531703bc492b0f97331c6a2bcafecf37.zip | |
librustc: Make bare functions implement the `FnMut` trait.
This is done entirely in the libraries for functions up to 16 arguments. A macro is used so that more arguments can be easily added if we need. Note that I had to adjust the overloaded call algorithm to not try calling the overloaded call operator if the callee is a built-in function type, to prevent loops. Closes #15448.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index ac363163673..0116518d537 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4045,7 +4045,8 @@ impl<'a> Parser<'a> { /// Parse a method in a trait impl, starting with `attrs` attributes. pub fn parse_method(&mut self, - already_parsed_attrs: Option<Vec<Attribute>>) -> Gc<Method> { + already_parsed_attrs: Option<Vec<Attribute>>) + -> Gc<Method> { let next_attrs = self.parse_outer_attributes(); let attrs = match already_parsed_attrs { Some(mut a) => { a.push_all_move(next_attrs); a } @@ -4083,6 +4084,11 @@ impl<'a> Parser<'a> { let visa = self.parse_visibility(); let abi = if self.eat_keyword(keywords::Extern) { self.parse_opt_abi().unwrap_or(abi::C) + } else if attr::contains_name(attrs.as_slice(), + "rust_call_abi_hack") { + // FIXME(stage0, pcwalton): Remove this awful hack after a + // snapshot, and change to `extern "rust-call" fn`. + abi::RustCall } else { abi::Rust }; |
