From 0c8cc8f3b43891c9a8c95878d196aa6e8a92136b Mon Sep 17 00:00:00 2001 From: Mark Schifflin Date: Tue, 3 Mar 2015 21:20:37 -0800 Subject: [PATCH 1/2] Add Question to quasi-quoteable tokens to allow ?Sized to be parsed --- src/libsyntax/ext/quote.rs | 3 ++- src/test/run-pass-fulldeps/issue-22957.rs | 26 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/test/run-pass-fulldeps/issue-22957.rs diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 544fb15dcde7b..00bd6f69e184e 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -635,9 +635,10 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P { token::FatArrow => "FatArrow", token::Pound => "Pound", token::Dollar => "Dollar", + token::Question => "Question", token::Underscore => "Underscore", token::Eof => "Eof", - _ => panic!(), + _ => panic!("Expected valid token, found {:?}", *tok), }; mk_token_path(cx, sp, name) } diff --git a/src/test/run-pass-fulldeps/issue-22957.rs b/src/test/run-pass-fulldeps/issue-22957.rs new file mode 100644 index 0000000000000..db132db8f0531 --- /dev/null +++ b/src/test/run-pass-fulldeps/issue-22957.rs @@ -0,0 +1,26 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test quasiquoting `?Sized` trait bound. + +#![feature(quote)] + +extern crate syntax; + +use syntax::ext::base::ExtCtxt; + +#[allow(dead_code)] +fn create_item(context: &mut ExtCtxt) { + quote_item!(context, + fn foo() { } + ); +} + +fn main() { } From f44708a3dad5f09eaabeac745fb32e54dc6ca23f Mon Sep 17 00:00:00 2001 From: Mark Schifflin Date: Tue, 3 Mar 2015 21:33:34 -0800 Subject: [PATCH 2/2] proper indentation --- src/test/run-pass-fulldeps/issue-22957.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/run-pass-fulldeps/issue-22957.rs b/src/test/run-pass-fulldeps/issue-22957.rs index db132db8f0531..858fe1f385fc1 100644 --- a/src/test/run-pass-fulldeps/issue-22957.rs +++ b/src/test/run-pass-fulldeps/issue-22957.rs @@ -19,7 +19,7 @@ use syntax::ext::base::ExtCtxt; #[allow(dead_code)] fn create_item(context: &mut ExtCtxt) { quote_item!(context, - fn foo() { } + fn foo() { } ); }