Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change the format_args! macro expansion for temporaries
Currently, the format_args! macro and its downstream macros in turn expand to series of let statements, one for each of its arguments, and then the invocation of the macro function. If one or more of the arguments are RefCell's, the enclosing statement for the temporary of the let is the let itself, which leads to scope problem. This patch changes let's to a match expression. Closes #12239.
- Loading branch information
Showing
6 changed files
with
65 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2012-2014 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 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
use std::cell::RefCell; | ||
|
||
pub fn main() { | ||
let name = RefCell::new("rust"); | ||
let what = RefCell::new("rocks"); | ||
let msg = format!("{name:?} {:?}", what.borrow().get(), name=name.borrow().get()); | ||
assert_eq!(msg, ~"&\"rust\" &\"rocks\""); | ||
} |
111e092
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from huonw
at edwardw@111e092
111e092
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging edwardw/rust/debug-expansion = 111e092 into auto
111e092
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
edwardw/rust/debug-expansion = 111e092 merged ok, testing candidate = ace204a
111e092
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/4333
success: http://buildbot.rust-lang.org/builders/auto-mac-32-nopt-c/builds/2175
success: http://buildbot.rust-lang.org/builders/auto-mac-32-nopt-t/builds/2176
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/4331
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/3431
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/3437
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/4346
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/3434
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/3440
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/4348
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/3434
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/3439
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android/builds/3508
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/1287
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/4340
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/3441
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/3447
success: http://buildbot.rust-lang.org/builders/auto-bsd-64-opt/builds/4108
111e092
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast-forwarding master to auto = ace204a