Skip to content

Commit

Permalink
core: rm unused lifetime.
Browse files Browse the repository at this point in the history
  • Loading branch information
huonw committed Jan 10, 2015
1 parent 20bce44 commit 719c5d7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
23 changes: 23 additions & 0 deletions src/libcore/fmt/mod.rs
Expand Up @@ -180,6 +180,7 @@ impl<'a> Arguments<'a> {
/// unsafety, but will ignore invalid .
#[doc(hidden)] #[inline]
#[unstable = "implementation detail of the `format_args!` macro"]
#[cfg(stage0)] // SNAP 9e4e524
pub fn with_placeholders(pieces: &'a [&'a str],
fmt: &'a [rt::Argument<'a>],
args: &'a [Argument<'a>]) -> Arguments<'a> {
Expand All @@ -189,6 +190,24 @@ impl<'a> Arguments<'a> {
args: args
}
}
/// This function is used to specify nonstandard formatting parameters.
/// The `pieces` array must be at least as long as `fmt` to construct
/// a valid Arguments structure. Also, any `Count` within `fmt` that is
/// `CountIsParam` or `CountIsNextParam` has to point to an argument
/// created with `argumentuint`. However, failing to do so doesn't cause
/// unsafety, but will ignore invalid .
#[doc(hidden)] #[inline]
#[unstable = "implementation detail of the `format_args!` macro"]
#[cfg(not(stage0))]
pub fn with_placeholders(pieces: &'a [&'a str],
fmt: &'a [rt::Argument],
args: &'a [Argument<'a>]) -> Arguments<'a> {
Arguments {
pieces: pieces,
fmt: Some(fmt),
args: args
}
}
}

/// This structure represents a safely precompiled version of a format string
Expand All @@ -207,7 +226,11 @@ pub struct Arguments<'a> {
pieces: &'a [&'a str],

// Placeholder specs, or `None` if all specs are default (as in "{}{}").
// SNAP 9e4e524
#[cfg(stage0)]
fmt: Option<&'a [rt::Argument<'a>]>,
#[cfg(not(stage0))]
fmt: Option<&'a [rt::Argument]>,

// Dynamic arguments for interpolation, to be interleaved with string
// pieces. (Every argument is preceded by a string piece.)
Expand Down
9 changes: 9 additions & 0 deletions src/libcore/fmt/rt.rs
Expand Up @@ -21,8 +21,17 @@ pub use self::Count::*;
pub use self::Position::*;
pub use self::Flag::*;

// SNAP 9e4e524
#[doc(hidden)]
#[derive(Copy)]
#[cfg(not(stage0))]
pub struct Argument {
pub position: Position,
pub format: FormatSpec,
}
#[doc(hidden)]
#[derive(Copy)]
#[cfg(stage0)]
pub struct Argument<'a> {
pub position: Position,
pub format: FormatSpec,
Expand Down
8 changes: 2 additions & 6 deletions src/libsyntax/ext/format.rs
Expand Up @@ -579,13 +579,9 @@ impl<'a, 'b> Context<'a, 'b> {
} else {
// Build up the static array which will store our precompiled
// nonstandard placeholders, if there are any.
let piece_ty = self.ecx.ty_path(self.ecx.path_all(
let piece_ty = self.ecx.ty_path(self.ecx.path_global(
self.fmtsp,
true, Context::rtpath(self.ecx, "Argument"),
vec![static_lifetime],
vec![],
vec![]
));
Context::rtpath(self.ecx, "Argument")));
let fmt = Context::static_array(self.ecx,
"__STATIC_FMTARGS",
piece_ty,
Expand Down

7 comments on commit 719c5d7

@bors
Copy link
Contributor

@bors bors commented on 719c5d7 Jan 10, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from nikomatsakis
at huonw@719c5d7

@bors
Copy link
Contributor

@bors bors commented on 719c5d7 Jan 10, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging huonw/rust/remove-unused-lifetime = 719c5d7 into auto

@bors
Copy link
Contributor

@bors bors commented on 719c5d7 Jan 10, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

status: {"merge_sha": "3975af567a73966fce7967c19b428086234241b4"}

@bors
Copy link
Contributor

@bors bors commented on 719c5d7 Jan 10, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huonw/rust/remove-unused-lifetime = 719c5d7 merged ok, testing candidate = 3975af5

@bors
Copy link
Contributor

@bors bors commented on 719c5d7 Jan 10, 2015

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 = 3975af5

@bors
Copy link
Contributor

@bors bors commented on 719c5d7 Jan 10, 2015

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 = 3975af5

Please sign in to comment.