Commit Graph

37742 Commits

Author SHA1 Message Date
Alex Crichton
6227357513 std: Stabilize the std::fmt module
This commit performs a final stabilization pass over the std::fmt module,
marking all necessary APIs as stable. One of the more interesting aspects of
this module is that it exposes a good deal of its runtime representation to the
outside world in order for `format_args!` to be able to construct the format
strings. Instead of hacking the compiler to assume that these items are stable,
this commit instead lays out a story for the stabilization and evolution of
these APIs.

There are three primary details used by the `format_args!` macro:

1. `Arguments` - an opaque package of a "compiled format string". This structure
   is passed around and the `write` function is the source of truth for
   transforming a compiled format string into a string at runtime. This must be
   able to be constructed in stable code.

2. `Argument` - an opaque structure representing an argument to a format string.
   This is *almost* a trait object as it's just a pointer/function pair, but due
   to the function originating from one of many traits, it's not actually a
   trait object. Like `Arguments`, this must be constructed from stable code.

3. `fmt::rt` - this module contains the runtime type definitions primarily for
   the `rt::Argument` structure. Whenever an argument is formatted with
   nonstandard flags, a corresponding `rt::Argument` is generated describing how
   the argument is being formatted. This can be used to construct an
   `Arguments`.

The primary interface to `std::fmt` is the `Arguments` structure, and as such
this type name is stabilize as-is today. It is expected for libraries to pass
around an `Arguments` structure to represent a pending formatted computation.

The remaining portions are largely "cruft" which would rather not be stabilized,
but due to the stability checks they must be. As a result, almost all pieces
have been renamed to represent that they are "version 1" of the formatting
representation. The theory is that at a later date if we change the
representation of these types we can add new definitions called "version 2" and
corresponding constructors for `Arguments`.

One of the other remaining large questions about the fmt module were how the
pending I/O reform would affect the signatures of methods in the module. Due to
[RFC 526][rfc], however, the writers of fmt are now incompatible with the
writers of io, so this question has largely been solved. As a result the
interfaces are largely stabilized as-is today.

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0526-fmt-text-writer.md

Specifically, the following changes were made:

* The contents of `fmt::rt` were all moved under `fmt::rt::v1`
* `fmt::rt` is stable
* `fmt::rt::v1` is stable
* `Error` is stable
* `Writer` is stable
* `Writer::write_str` is stable
* `Writer::write_fmt` is stable
* `Formatter` is stable
* `Argument` has been renamed to `ArgumentV1` and is stable
* `ArgumentV1::new` is stable
* `ArgumentV1::from_uint` is stable
* `Arguments::new_v1` is stable (renamed from `new`)
* `Arguments::new_v1_formatted` is stable (renamed from `with_placeholders`)
* All formatting traits are now stable, as well as the `fmt` method.
* `fmt::write` is stable
* `fmt::format` is stable
* `Formatter::pad_integral` is stable
* `Formatter::pad` is stable
* `Formatter::write_str` is stable
* `Formatter::write_fmt` is stable
* Some assorted top level items which were only used by `format_args!` were
  removed in favor of static functions on `ArgumentV1` as well.
* The formatting-flag-accessing methods remain unstable

Within the contents of the `fmt::rt::v1` module, the following actions were
taken:

* Reexports of all enum variants were removed
* All prefixes on enum variants were removed
* A few miscellaneous enum variants were renamed
* Otherwise all structs, fields, and variants were marked stable.

In addition to these actions in the `std::fmt` module, many implementations of
`Show` and `String` were stabilized as well.

In some other modules:

* `ToString` is now stable
* `ToString::to_string` is now stable
* `Vec` no longer implements `fmt::Writer` (this has moved to `String`)

This is a breaking change due to all of the changes to the `fmt::rt` module, but
this likely will not have much impact on existing programs.

Closes #20661
[breaking-change]
2015-01-30 09:21:56 -08:00
bors
52c74e63da Auto merge of #21692 - pnkfelix:fsk-fix-coerce-match-20055, r=eddyb
trans: When coercing to `Box<Trait>` or `Box<[T]>`, leave datum in it's original L-/R-value state.

This fixes a subtle issue where temporaries were being allocated (but not necessarily initialized) to the (parent) terminating scope of a match expression; in particular, the code to zero out the temporary emitted by `datum.store_to` is only attached to the particular match-arm for that temporary, but when going down other arms of the match expression, the temporary may falsely appear to have been initialized, depending on what the stack held at that location, and thus may have its destructor erroneously run at the end of the terminating scope.

FIx #20055.

(There may be a latent bug still remaining in `fn into_fat_ptr`, but I am so annoyed by the test/run-pass/coerce_match.rs failures that I want to land this now.)
2015-01-29 22:54:19 +00:00
bors
7ea93abfb2 Auto merge of #21691 - edwardw:double-closure, r=nikomatsakis
It was considered to be impossible but actually it can
happen for nested closures. Also, because there must
be nested closures when this happens, we can use more
targeted help message.

Closes #21390
Closes #21600
2015-01-29 19:36:03 +00:00
bors
265a23320d Auto merge of #21677 - japaric:no-range, r=alexcrichton
Note: Do not merge until we get a newer snapshot that includes #21374

There was some type inference fallout (see 4th commit) because type inference with `a..b` is not as good as with `range(a, b)` (see #21672).

r? @alexcrichton
2015-01-29 16:28:52 +00:00
Jorge Aparicio
a6f9180fd6 bring back #[derive(Show)] with a deprecation warning 2015-01-29 07:49:02 -05:00
Jorge Aparicio
4b75931ce2 fix import in cfail test 2015-01-29 07:49:02 -05:00
Jorge Aparicio
788181d405 s/Show/Debug/g 2015-01-29 07:49:02 -05:00
Jorge Aparicio
09ba9f5c87 remove #[old_impl_check] now that #21363 has been fixed 2015-01-29 07:49:02 -05:00
Jorge Aparicio
92e966e099 register snaphots 2015-01-29 07:49:02 -05:00
Jorge Aparicio
16a2503a1c undo some conversions 2015-01-29 07:49:02 -05:00
Jorge Aparicio
3cc191e58a remove unused imports 2015-01-29 07:49:01 -05:00
Jorge Aparicio
94d04e684c fix inference fallout 2015-01-29 07:49:01 -05:00
Jorge Aparicio
efc97a51ff convert remaining range(a, b) to a..b 2015-01-29 07:49:01 -05:00
Jorge Aparicio
7d661af9c8 for x in range(a, b) -> for x in a..b
sed -i 's/in range(\([^,]*\), *\([^()]*\))/in \1\.\.\2/g' **/*.rs
2015-01-29 07:47:37 -05:00
Jorge Aparicio
c300d681bd range(a, b).foo() -> (a..b).foo()
sed -i 's/ range(\([^,]*\), *\([^()]*\))\./ (\1\.\.\2)\./g' **/*.rs
2015-01-29 07:46:44 -05:00
bors
3d6f5100af Auto merge of #21730 - Manishearth:rollup, r=alexcrichton
Should clear our backlog of rollups from the queue
2015-01-29 11:28:30 +00:00
bors
bedd8108dc Auto merge of #21680 - japaric:slice, r=alexcrichton
Replaces `slice_*` method calls with slicing syntax, and removes `as_slice()` calls that are redundant due to `Deref`.
2015-01-29 05:47:21 +00:00
bors
c5961ad06d Auto merge of #21522 - nikomatsakis:assoc-type-ice-hunt-take-3, r=nick29581
Do not propagate the region requirements on the projected type to the input types it is being projected from.

Fixes #21520.

r? @aturon
2015-01-28 21:49:38 +00:00
Manish Goregaokar
092330c640 Rollup merge of 21643 - semarie:break-local_stage0, r=brson 2015-01-29 03:17:16 +05:30
Manish Goregaokar
d37d2167b2 Rollup merge of 21651 - nelsonjchen:add--webkit-overflow-scrolling-touch-to-book-css, r=alexcrichton 2015-01-29 03:16:52 +05:30
Manish Goregaokar
2403176dde Rollup merge of 21654 - FlaPer87:unify-impls, r=alexcrichton 2015-01-29 03:16:25 +05:30
Manish Goregaokar
62b24c3dd5 Rollup merge of 21662 - oli-obk:hashmap_enum_json, r=alexcrichton 2015-01-29 03:15:51 +05:30
Manish Goregaokar
518ce538a9 Rollup merge of 21663 - tbu-:pr_doc_cell_static_safety, r=alexcrichton 2015-01-29 03:15:25 +05:30
Manish Goregaokar
0752c4a941 Rollup merge of 21671 - akiss77:pr-aarch64-fastisel0, r=alexcrichton 2015-01-29 03:14:58 +05:30
Manish Goregaokar
f553f58b7f Rollup merge of 21681 - japaric:no-warn, r=alexcrichton 2015-01-29 03:14:35 +05:30
Manish Goregaokar
7abbc96e66 Rollup merge of 21708 - brson:internals, r=huonw 2015-01-29 03:13:53 +05:30
Manish Goregaokar
1669f89e14 Rollup merge of 21711 - thepowersgang:patch-1, r=alexcrichton 2015-01-29 03:11:48 +05:30
Manish Goregaokar
0508d8f362 Rollup merge of 21722 - orpheuslummis:patch-1, r=Gankro 2015-01-29 03:11:12 +05:30
Manish Goregaokar
0d1a4ac269 Rollup merge of #21640 - retep998:rmdir, r=alexcrichton
`_wrmdir` is literally just a wrapper around `RemoveDirectoryW`, so let's just use `RemoveDirectoryW`.
r? @alexcrichton
2015-01-29 03:04:10 +05:30
Manish Goregaokar
be13211b0a Rollup merge of #21626 - Ms2ger:various-cleanup, r=eddyb 2015-01-29 03:04:09 +05:30
bors
ee0be3b3e7 Auto merge of #21698 - Manishearth:rollup, r=alexcrichton
This should work now.
2015-01-28 18:55:24 +00:00
Manish Goregaokar
c709ed2faf Merge remote-tracking branch 'origin/master' into rollup
Conflicts:
	src/libcollections/slice.rs
	src/libcore/nonzero.rs
	src/libcore/ops.rs
2015-01-28 23:31:03 +05:30
Orpheus Lummis
9a379d4257 Correct Orpheus Lummis's email and name
New email address, stylization of name.
2015-01-28 10:04:56 -05:00
bors
a45e117733 Auto merge of #21019 - nikomatsakis:issue-20871-ret-as-assoc-type, r=nrc
Fixes https://github.com/rust-lang/rust/issues/20871

r? @aturon (at least until we decide definitively if this is a good idea)
2015-01-28 11:01:36 +00:00
Niko Matsakis
05ffdc5824 Add regression test for #21212. Fixes #21212. 2015-01-28 05:59:50 -05:00
Niko Matsakis
aaf3df3667 Add new test for object method numbering mismatches. 2015-01-28 05:15:24 -05:00
Niko Matsakis
694432e935 Adjust comment per nrc's suggestion. 2015-01-28 05:15:24 -05:00
Niko Matsakis
aeeab35ec2 Add missing space to error message. 2015-01-28 05:15:24 -05:00
Niko Matsakis
09783d1dab Update test files; mostly the problem is that they were using the
explicit form `Fn<A,B>` and now should use `Fn(A) -> B` or
`Fn<A,Output=B>`, but in some cases we get duplicate error
reports. This is mildly annoying and arises because of the main error
and another error from the projection. Might be worth squashing those,
but seems like a separate problem.
2015-01-28 05:15:24 -05:00
Niko Matsakis
ac94ae5883 Update Rustdoc to deal with the Fn return type being an associated type. 2015-01-28 05:15:24 -05:00
Niko Matsakis
7bd19112ee Patch variance bug: appearing in a binding is an invariant position (at least right now). 2015-01-28 05:15:24 -05:00
Niko Matsakis
47c2d31038 Extract expectations from the projection obligation, which includes
all relevant information.
2015-01-28 05:15:24 -05:00
Niko Matsakis
25a27977fa Add Clone to the list of bounds for a TypeFolder. (Kill?) 2015-01-28 05:15:24 -05:00
Niko Matsakis
7d68250eb4 When pretty-printing object types, include the output associated type 2015-01-28 05:15:24 -05:00
Niko Matsakis
006f3eacae Fix a latent bug in trait dispatch where we sometimes counted associated types
when constructing the vtable-index. Not good.
2015-01-28 05:15:23 -05:00
Niko Matsakis
07cdb85331 Move return type an associated type of the Fn* traits. Mostly this involves tweaking things in
the compiler that assumed two input types to assume two ouputs; we also have to teach `project.rs`
to project `Output` from the unboxed closure and fn traits.
2015-01-28 05:15:23 -05:00
Niko Matsakis
c61d7889b4 Add the notion of normalizing a parameter environment and ensure that
all parameter environments are normalized. Correspondingly, stop
normalizing predicates we extract out of the environment. Fixes #21664.
2015-01-28 05:13:53 -05:00
Niko Matsakis
c73a1d0a2c Change list of predicates in ParameterEnvironment to a Vec. 2015-01-28 05:13:53 -05:00
Felix S. Klock II
d85520202a In unsize_unique_expr, do not convert scratch value to lvalue.
Fix the issue-20055-box-trait.rs test to actually test `Box<Trait>`.

Fix #21695.
2015-01-28 10:22:26 +01:00
Ms2ger
7aa2735393 Remove unnecessary to_string() call. 2015-01-28 09:42:16 +01:00