Commit Graph

36055 Commits

Author SHA1 Message Date
Alex Crichton
e423fcf0e0 std: Enforce Unicode in fmt::Writer
This commit is an implementation of [RFC 526][rfc] which is a change to alter
the definition of the old `fmt::FormatWriter`. The new trait, renamed to
`Writer`, now only exposes one method `write_str` in order to guarantee that all
implementations of the formatting traits can only produce valid Unicode.

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

One of the primary improvements of this patch is the performance of the
`.to_string()` method by avoiding an almost-always redundant UTF-8 check. This
is a breaking change due to the renaming of the trait as well as the loss of the
`write` method, but migration paths should be relatively easy:

* All usage of `write` should move to `write_str`. If truly binary data was
  being written in an implementation of `Show`, then it will need to use a
  different trait or an altogether different code path.

* All usage of `write!` should continue to work as-is with no modifications.

* All usage of `Show` where implementations just delegate to another should
  continue to work as-is.

[breaking-change]

Closes #20352
2015-01-01 22:04:46 -08:00
bors
cd614164e6 auto merge of #20387 : nick29581/rust/arrays-2, r=alexcrichton
Closes #19999
2015-01-02 02:31:12 +00:00
Nick Cameron
2c92ddeda7 More fallout 2015-01-02 10:28:19 +13:00
Nick Cameron
13392d19ca Add tests 2015-01-02 10:28:19 +13:00
Nick Cameron
7e2b9ea235 Fallout - change array syntax to use ; 2015-01-02 10:28:19 +13:00
Nick Cameron
57a74eda88 Accept ranges with only a maximum value: ..expr 2015-01-02 10:28:19 +13:00
Nick Cameron
d45b5d2ed9 Disallow [_, ..n] syntax for fixed length arrays and repeating array constructors
Closes #19999

[breaking-change]

Use [_; n] instead.
2015-01-02 10:28:19 +13:00
bors
39d7402666 auto merge of #20190 : cmr/rust/gate-macro-args, r=alexcrichton
Uses the same approach as https://github.com/rust-lang/rust/pull/17286 (and
subsequent changes making it more correct), where the visitor will skip any
pieces of the AST that are from "foreign code", where the spans don't line up,
indicating that that piece of code is due to a macro expansion.

If this breaks your code, read the error message to determine which feature
gate you should add to your crate.

Closes #18102

[breaking-change]
2015-01-01 15:51:08 +00:00
Corey Richardson
41da99dff4 Feature gate macro arguments
Uses the same approach as https://github.com/rust-lang/rust/pull/17286 (and
subsequent changes making it more correct), where the visitor will skip any
pieces of the AST that are from "foreign code", where the spans don't line up,
indicating that that piece of code is due to a macro expansion.

If this breaks your code, read the error message to determine which feature
gate you should add to your crate, and bask in the knowledge that your code
won't mysteriously break should you try to use the 1.0 release.

Closes #18102

[breaking-change]
2015-01-01 07:06:46 -05:00
bors
c594959cdf auto merge of #19388 : nick29581/rust/rc-show, r=alexcrichto
r? @huonw or @alexcrichton

Apparently, we have previously rejected an RFC like this. However, since then we removed `{:?}` and so without this debugging gets really difficult as soon as there is a RefCell anywhere, so I believe there is more benefit to adding these impls than there was before. By using "try_borrow" we can avoid panicing in `Show` (I think).

@ huon in response to a comment in #19254: I noticed that `drop()` checks for the ptr being null, so I checked here too. Now I am checking for both, if you're confident I can change to only checking `strong()`.
2015-01-01 06:36:24 +00:00
Nick Cameron
f0976e2cf3 Reviewer change 2015-01-01 18:00:32 +13:00
Nick Cameron
c8c0391519 Add some impls of Show (RefCell, Weak, some resolve types) 2015-01-01 17:54:15 +13:00
bors
47b8479e73 auto merge of #20363 : japaric/rust/moar-uc, r=nmatsakis
The the last argument of the `ItemDecorator::expand` method has changed to `Box<FnMut>`. Syntax extensions will break.

[breaking-change]

---

This PR removes pretty much all the remaining uses of boxed closures from the libraries. There are still boxed closures under the `test` directory, but I think those should be removed or replaced with unboxed closures at the same time we remove boxed closures from the language.

In a few places I had to do some contortions (see the first commit for an example) to work around issue #19596. I have marked those workarounds with FIXMEs. In the future when `&mut F where F: FnMut` implements the `FnMut` trait, we should be able to remove those workarounds. I've take care to avoid placing the workaround functions in the public API.

Since `let f = || {}` always gets type checked as a boxed closure, I have explictly annotated those closures (with e.g. `|&:| {}`) to force the compiler to type check them as unboxed closures.

Instead of removing the type aliases (like `GetCrateDataCb`), I could have replaced them with newtypes. But this seemed like overcomplicating things for little to no gain.

I think we should be able to remove the boxed closures from the languge after this PR lands. (I'm being optimistic here)

r? @alexcrichton or @aturon 
cc @nikomatsakis
2015-01-01 04:01:02 +00:00
Jorge Aparicio
10bbf69488 rustc_trans: replace EnterPatterns alias with an unboxed closure 2014-12-31 22:50:27 -05:00
Jorge Aparicio
c8cf3a307b rustc: replace pick alias with an unboxed closure 2014-12-31 22:50:27 -05:00
Jorge Aparicio
1d21dad1d2 rustc: replace GetCrateDataCb alias with an unboxed closure 2014-12-31 22:50:27 -05:00
Jorge Aparicio
63af3e6cd2 time: unbox closures used in let bindings 2014-12-31 22:50:27 -05:00
Jorge Aparicio
ab402c0744 syntax: unbox closures used in let bindings 2014-12-31 22:50:27 -05:00
Jorge Aparicio
12dd7781d6 std: unbox closures used in let bindings 2014-12-31 22:50:27 -05:00
Jorge Aparicio
fb14dad4d6 rustdoc: unbox closures used in let bindings 2014-12-31 22:50:27 -05:00
Jorge Aparicio
e9ddd825ba rustc_typeck: unbox closures used in let bindings 2014-12-31 22:50:27 -05:00
Jorge Aparicio
e47035b9a5 rustc_trans: unbox closures used in let bindings 2014-12-31 22:50:27 -05:00
Jorge Aparicio
1e4bbefae1 rustc_resolve: unbox closures used in let bindings 2014-12-31 22:50:27 -05:00
Jorge Aparicio
a49cdb8c36 rustc_driver: unbox closures used in let bindings 2014-12-31 22:50:27 -05:00
Jorge Aparicio
28ea99eaa6 rustc_borrowck: unbox closures used in let bindings 2014-12-31 22:50:26 -05:00
Jorge Aparicio
a6f3053208 rustc_back: unbox closures used in let bindings 2014-12-31 22:50:26 -05:00
Jorge Aparicio
06408b4dd3 rustc: unbox closures used in let bindings 2014-12-31 22:50:26 -05:00
Jorge Aparicio
16a4ba8fa5 getopts: unbox closures used in let bindings 2014-12-31 22:50:26 -05:00
Jorge Aparicio
ddb4e43fa5 core: unbox closures used in let bindings 2014-12-31 22:50:26 -05:00
Jorge Aparicio
bcc2120c21 rustc_borrowck: unbox closures used in function arguments 2014-12-31 22:50:26 -05:00
Jorge Aparicio
24b49228f0 rustc_trans: unbox closures used in function arguments 2014-12-31 22:50:26 -05:00
Jorge Aparicio
5de9f47e49 rustc: unbox closures used in function arguments 2014-12-31 22:50:26 -05:00
Jorge Aparicio
70ce68eed4 syntax: unbox closures used in function arguments 2014-12-31 22:50:26 -05:00
Jorge Aparicio
371f04d433 std: unbox closures used in function arguments 2014-12-31 22:50:25 -05:00
bors
7d4f4876d6 auto merge of #20374 : nikomatsakis/rust/assoc-types, r=nikomatsakis
These mostly derive from problems that @japaric encountered.

r? @pcwalton
2015-01-01 01:20:56 +00:00
Jorge Aparicio
a17c2b60e1 collections: fix fallout 2014-12-31 19:14:44 -05:00
Jorge Aparicio
ea94a90488 unicode: unbox closures used in function arguments 2014-12-31 19:14:44 -05:00
Niko Matsakis
004a567de3 Convert TODO to FIXME for now 2014-12-31 16:23:49 -05:00
Niko Matsakis
7ae1c6bc26 Remove a TODO now that we handle normalization-derived bounds properly. 2014-12-31 16:02:58 -05:00
bors
10d99a9734 auto merge of #20360 : alexcrichton/rust/rollup, r=alexcrichton 2014-12-31 21:01:42 +00:00
Niko Matsakis
cadd4335b4 Fix whitespace. 2014-12-31 15:05:46 -05:00
Niko Matsakis
0a2d531b94 Teach trans to drain fulfillment context. japaric encountered problems
due to this but we were not able to isolate a smaller test case.
2014-12-31 14:42:06 -05:00
Niko Matsakis
67dab2af81 Include projection bounds in superpredicates.
Fixes #19451.
Fixes #20345.
2014-12-31 14:41:39 -05:00
Alex Crichton
139f44bae8 rollup merge of #20375: brson/windistfix 2014-12-31 11:13:37 -08:00
Alex Crichton
aec67c2ee0 Revert "std: Re-enable at_exit()"
This reverts commit 9e224c2bf1.

Conflicts:
	src/libstd/sys/windows/os.rs
2014-12-31 10:20:31 -08:00
Brian Anderson
7608dbad65 mk: Fix the location of a temp dir when building installer on win 2014-12-31 10:06:21 -08:00
Niko Matsakis
9675488ef9 Add tests for two random issues that seem to be fixed on this branch.
Fixes #20346.
Fixes #20371.
2014-12-31 12:52:16 -05:00
Niko Matsakis
6cb425d964 Rework normalization so that it works recursively, since the types extracted from an impl are potentially in need of normalization. This also lays groundwork for further cleanup in other areas by disconnecting normalization from the fulfillment context. 2014-12-31 12:50:30 -05:00
Alex Crichton
582cba183f Test fixes and rebase conflicts 2014-12-31 08:33:13 -08:00
Niko Matsakis
0aa7ba9f5e Normalize bounds also in the UFCS cases (and get more systematic about it) 2014-12-31 11:16:28 -05:00