diff options
| author | bors <bors@rust-lang.org> | 2014-12-24 20:47:12 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-12-24 20:47:12 +0000 |
| commit | 7e11b22713aebd28ceaaa2ecef937c9b9d247c2f (patch) | |
| tree | 10885e6c690c4786c1eddab369ba92090732ddf8 /src/libsyntax | |
| parent | 14597f980a19aad66cd72e9ac4b6cd43b24ea5f4 (diff) | |
| parent | 85c1a4b1ba09dae786b3554e0ab596814efabe0e (diff) | |
| download | rust-7e11b22713aebd28ceaaa2ecef937c9b9d247c2f.tar.gz rust-7e11b22713aebd28ceaaa2ecef937c9b9d247c2f.zip | |
auto merge of #20117 : lfairy/rust/rename-include-bin, r=alexcrichton
According to [RFC 344][], methods that return `&[u8]` should have names ending in `bytes`. Though `include_bin!` is a macro not a method, it seems reasonable to follow the convention anyway. We keep the old name around for now, but trigger a deprecation warning when it is used. [RFC 344]: https://github.com/rust-lang/rfcs/blob/master/text/0344-conventions-galore.md [breaking-change]
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/base.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/ext/source_util.rs | 8 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index d45871708dc..8e69076a2c5 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -442,6 +442,9 @@ fn initial_syntax_expander_table(ecfg: &expand::ExpansionConfig) -> SyntaxEnv { syntax_expanders.insert(intern("include_bin"), builtin_normal_expander( ext::source_util::expand_include_bin)); + syntax_expanders.insert(intern("include_bytes"), + builtin_normal_expander( + ext::source_util::expand_include_bytes)); syntax_expanders.insert(intern("module_path"), builtin_normal_expander( ext::source_util::expand_mod)); diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 7c2c5c1530c..a49df457cb3 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -163,7 +163,13 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) pub fn expand_include_bin(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> Box<base::MacResult+'static> { - let file = match get_single_str_from_tts(cx, sp, tts, "include_bin!") { + cx.span_warn(sp, "include_bin! is deprecated; use include_bytes! instead"); + expand_include_bytes(cx, sp, tts) +} + +pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) + -> Box<base::MacResult+'static> { + let file = match get_single_str_from_tts(cx, sp, tts, "include_bytes!") { Some(f) => f, None => return DummyResult::expr(sp) }; |
