Skip to content

Rename include_bin! to include_bytes! #20117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ names, and invoked through a consistent syntax: `name!(...)`. Examples include:
* `stringify!` : pretty-print the Rust expression given as an argument
* `include!` : include the Rust expression in the given file
* `include_str!` : include the contents of the given file as a string
* `include_bin!` : include the contents of the given file as a binary blob
* `include_bytes!` : include the contents of the given file as a binary blob
* `error!`, `warn!`, `info!`, `debug!` : provide diagnostic information.

All of the above extensions are expressions with values.
Expand Down
24 changes: 12 additions & 12 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,26 +491,26 @@ fn write_shared(cx: &Context,
// Add all the static files. These may already exist, but we just
// overwrite them anyway to make sure that they're fresh and up-to-date.
try!(write(cx.dst.join("jquery.js"),
include_bin!("static/jquery-2.1.0.min.js")));
try!(write(cx.dst.join("main.js"), include_bin!("static/main.js")));
try!(write(cx.dst.join("playpen.js"), include_bin!("static/playpen.js")));
try!(write(cx.dst.join("main.css"), include_bin!("static/main.css")));
include_bytes!("static/jquery-2.1.0.min.js")));
try!(write(cx.dst.join("main.js"), include_bytes!("static/main.js")));
try!(write(cx.dst.join("playpen.js"), include_bytes!("static/playpen.js")));
try!(write(cx.dst.join("main.css"), include_bytes!("static/main.css")));
try!(write(cx.dst.join("normalize.css"),
include_bin!("static/normalize.css")));
include_bytes!("static/normalize.css")));
try!(write(cx.dst.join("FiraSans-Regular.woff"),
include_bin!("static/FiraSans-Regular.woff")));
include_bytes!("static/FiraSans-Regular.woff")));
try!(write(cx.dst.join("FiraSans-Medium.woff"),
include_bin!("static/FiraSans-Medium.woff")));
include_bytes!("static/FiraSans-Medium.woff")));
try!(write(cx.dst.join("Heuristica-Italic.woff"),
include_bin!("static/Heuristica-Italic.woff")));
include_bytes!("static/Heuristica-Italic.woff")));
try!(write(cx.dst.join("SourceSerifPro-Regular.woff"),
include_bin!("static/SourceSerifPro-Regular.woff")));
include_bytes!("static/SourceSerifPro-Regular.woff")));
try!(write(cx.dst.join("SourceSerifPro-Bold.woff"),
include_bin!("static/SourceSerifPro-Bold.woff")));
include_bytes!("static/SourceSerifPro-Bold.woff")));
try!(write(cx.dst.join("SourceCodePro-Regular.woff"),
include_bin!("static/SourceCodePro-Regular.woff")));
include_bytes!("static/SourceCodePro-Regular.woff")));
try!(write(cx.dst.join("SourceCodePro-Semibold.woff"),
include_bin!("static/SourceCodePro-Semibold.woff")));
include_bytes!("static/SourceCodePro-Semibold.woff")));

fn collect(path: &Path, krate: &str,
key: &str) -> io::IoResult<Vec<String>> {
Expand Down
8 changes: 6 additions & 2 deletions src/libstd/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,10 +621,14 @@ pub mod builtin {
/// # Example
///
/// ```rust,ignore
/// let secret_key = include_bin!("secret-key.bin");
/// let secret_key = include_bytes!("secret-key.bin");
/// ```
#[macro_export]
macro_rules! include_bin { ($file:expr) => ({ /* compiler built-in */ }) }
macro_rules! include_bytes { ($file:expr) => ({ /* compiler built-in */ }) }

/// Deprecated alias for `include_bytes!()`.
#[macro_export]
macro_rules! include_bin { ($file:expr) => ({ /* compiler built-in */}) }

/// Expands to a string that represents the current module path.
///
Expand Down
3 changes: 3 additions & 0 deletions src/libsyntax/ext/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
8 changes: 7 additions & 1 deletion src/libsyntax/ext/source_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
Expand Down
2 changes: 1 addition & 1 deletion src/test/bench/shootout-k-nucleotide-pipes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ fn main() {
use std::io::{stdio, MemReader, BufferedReader};

let rdr = if os::getenv("RUST_BENCH").is_some() {
let foo = include_bin!("shootout-k-nucleotide.data");
let foo = include_bytes!("shootout-k-nucleotide.data");
box MemReader::new(foo.to_vec()) as Box<Reader>
} else {
box stdio::stdin() as Box<Reader>
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/macros-nonfatal-errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ fn main() {

include_str!(invalid); //~ ERROR
include_str!("i'd be quite surprised if a file with this name existed"); //~ ERROR
include_bin!(invalid); //~ ERROR
include_bin!("i'd be quite surprised if a file with this name existed"); //~ ERROR
include_bytes!(invalid); //~ ERROR
include_bytes!("i'd be quite surprised if a file with this name existed"); //~ ERROR

trace_macros!(invalid); //~ ERROR
}
2 changes: 1 addition & 1 deletion src/test/run-make/symbols-are-reasonable/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// except according to those terms.

pub static X: &'static str = "foobarbaz";
pub static Y: &'static [u8] = include_bin!("lib.rs");
pub static Y: &'static [u8] = include_bytes!("lib.rs");

trait Foo {}
impl Foo for uint {}
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/syntax-extension-source-utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn main() {
.as_slice()
.starts_with("/* this is for "));
assert!(
include_bin!("syntax-extension-source-utils-files/includeme.fragment")
include_bytes!("syntax-extension-source-utils-files/includeme.fragment")
[1] == (42 as u8)); // '*'
// The Windows tests are wrapped in an extra module for some reason
assert!((m1::m2::where_am_i().as_slice().ends_with("m1::m2")));
Expand Down