Commit Graph

38161 Commits

Author SHA1 Message Date
Alex Crichton
cf535a3b8f rustc: Use --extern to always override
Previously if --extern was specified it would not override crates in the
standard distribution, leading to issues like #21771. This commit alters the
behavior such that if --extern is passed then it will always override any other
choice of crates and no previous match will be used (unless it is the same path
as --extern).

Closes #21771
2015-01-30 09:48:23 -08:00
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
Alex Crichton
0cdde6e5e0 std: Stabilize FromStr and parse
This commits adds an associated type to the `FromStr` trait representing an
error payload for parses which do not succeed. The previous return value,
`Option<Self>` did not allow for this form of payload. After the associated type
was added, the following attributes were applied:

* `FromStr` is now stable
* `FromStr::Err` is now stable
* `FromStr::from_str` is now stable
* `StrExt::parse` is now stable
* `FromStr for bool` is now stable
* `FromStr for $float` is now stable
* `FromStr for $integral` is now stable
* Errors returned from stable `FromStr` implementations are stable
* Errors implement `Display` and `Error` (both impl blocks being `#[stable]`)

Closes #15138
2015-01-30 08:52:44 -08:00
Steve Klabnik
19a1f7ed06 Don't use as_slice() in docs
Use deref coercions instead.
2015-01-30 11:22:45 -05:00
Jorge Aparicio
b9a9030ed6 fix some cfail tests 2015-01-30 10:56:02 -05:00
Jorge Aparicio
60abb3bef2 fixes after rebase 2015-01-30 10:37:45 -05:00
Jorge Aparicio
2d76c94dd0 s/while let/for/g now that #21245 has been fixed 2015-01-30 10:37:45 -05:00
Jorge Aparicio
c013a018b8 add test for #21655
closes #21655
2015-01-30 10:37:44 -05:00
Jorge Aparicio
3a62590be2 add test for #20605
closes #20605
closes #20989 (duplicate)
closes #21379 (duplicate)
2015-01-30 10:37:44 -05:00
Jorge Aparicio
cb896a6e5f fix recursive call 2015-01-30 10:37:44 -05:00
Jorge Aparicio
d4b3e7f09c remove the Iterator lang item 2015-01-30 10:37:44 -05:00
Jorge Aparicio
bfaf4227b8 smoke out remaining bugs 2015-01-30 10:37:44 -05:00
Jorge Aparicio
ed82b5a70e remove Copy impls from iterators 2015-01-30 10:37:44 -05:00
Jorge Aparicio
9070345c0e add tests 2015-01-30 10:37:44 -05:00
Jorge Aparicio
a873316277 remove dead code 2015-01-30 10:37:44 -05:00
Jorge Aparicio
acb8c1aaa6 remove more ExprForLoops 2015-01-30 10:37:44 -05:00
Jorge Aparicio
76362f0a0e custom message for refutable patterns in for loops 2015-01-30 10:37:44 -05:00
Jorge Aparicio
5e1820f346 fix tests 2015-01-30 10:37:44 -05:00
Jorge Aparicio
f9865eac18 fix fallout 2015-01-30 10:37:44 -05:00
Jorge Aparicio
9fdc0effd2 implement for loop desugaring 2015-01-30 10:36:31 -05:00
Jorge Aparicio
a65d3f5b98 core: add the IntoIterator trait 2015-01-30 10:36:31 -05:00
bors
3fbfad3519 Auto merge of #21604 - nikomatsakis:closure-move-indiv-vars, r=eddyb
r? @eddyb
2015-01-30 15:32:27 +00:00
bors
1a51eb9cca Auto merge of #21717 - nick29581:prelude-fullrange, r=acrichto
r? @alexcrichton
2015-01-30 12:43:41 +00:00
Niko Matsakis
ced10626de Address @eddyb nit by simplifying ClosureEnv. 2015-01-30 05:57:57 -05:00
Niko Matsakis
a962bdb3da Use #[rustc_paren_sugar] as a more extensible way of deciding when
paren sugar is legal.
2015-01-30 05:57:57 -05:00
Richo Healey
ff25fd660a lint: Add test for no_mangle 2015-01-30 02:57:45 -08:00
Niko Matsakis
80c793c1d3 Allow individual upvars to be inferred to move semantics. Fixes #21603. 2015-01-30 05:56:39 -05:00
Niko Matsakis
2f29cdeb4b Remove the capture mode map and just store the capture mode for individual variables.
Also add test. Fixes #16749.
2015-01-30 05:56:39 -05:00
bors
e0f5980ead Auto merge of #21351 - eddyb:x-coerce--a-new-hope, r=nikomatsakis
Coercions will now attempt to autoderef as needed before reborrowing.
This includes overloaded `Deref`, e.g. `&Rc<T>` coerces to `&T`, and
`DerefMut`, e.g. `&mut Vec<T>` coerces to `&mut [T]` (in addition to `&[T]`).
Closes #21432.
2015-01-30 07:57:14 +00:00
Richo Healey
d2ab7d3ea8 rt: allow unexported functions
rust_panic is unexported, however the metadata exported will usually
include it for attaching breakpoints.
2015-01-29 21:32:01 -08:00
Richo Healey
44ff72195e lint: warn about #[no_mangle] fns that aren't exported
The usecase is that functions made visible to systems outside of the
rust ecosystem require the symbol to be visible.
2015-01-29 21:32:00 -08:00
Chris Morgan
9836742d6a Add a few missing stability markers. 2015-01-30 15:22:19 +11:00
Tobias Bucher
7f64fe4e27 Remove all i suffixes 2015-01-30 04:38:54 +01:00
P1start
39a8c23c0b Make the naming lints only warn on names with upper/lowercase equivalents
Closes #21735.
2015-01-30 14:18:04 +13:00
Brian Anderson
5716ede92c doc: Add links to users.rust-lang.org 2015-01-29 15:49:00 -08:00
Brian Anderson
03b9995be9 Register snaps 2015-01-29 15:02:00 -08:00
Nick Cameron
023d49e347 Change from core::ops::RangeFull to std::ops 2015-01-30 12:01:08 +13:00
Nick Cameron
bf2b473816 Rename FullRange to RangeFull 2015-01-30 12:01:08 +13:00
Nick Cameron
c64a96d385 Remove FullRange from the prelude etc. 2015-01-30 12:00:20 +13:00
Nick Cameron
a9d465fec9 Use absolute path to FullRange, rather than assuming it is in the prelude
Closes #21263

[breaking-change]

If you are using `core::ops::FullRange` you should change to using `core::ops::RangeFull`
2015-01-30 12:00:20 +13:00
Nick Cameron
9ba99666f3 Review changes 2015-01-30 11:58:10 +13:00
Nick Cameron
b159d9cde5 Make the save-analysis smoke test more thorough 2015-01-30 11:58:10 +13:00
Nick Cameron
78f617800f save-anlaysis: misc bug fixes
In particular, handling of struct literals where the struct name is a type alias, and tuple indexing.

Plus some other stuff.
2015-01-30 11:58:10 +13:00
Nick Cameron
dcbd418b1c save-analysis: handle absolute paths properly 2015-01-30 11:57:33 +13:00
Nick Cameron
1174550191 save-analysis: Use the correct span for extern crate 2015-01-30 11:57:33 +13:00
Nick Cameron
127c253d40 save-analysis: don't include the crate name in fully qualified paths 2015-01-30 11:57:33 +13: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
Eduard Burtescu
ae076e1e3b Implement deref coercions (rust-lang/rfcs#241). 2015-01-30 00:30:12 +02:00
Eduard Burtescu
b48c4c8cf4 rustc_typeck: cleanup coercion logic that has been obsolete/unused for a while now. 2015-01-30 00:27:12 +02:00
Eduard Burtescu
6a478bdfd2 rustc_typeck: use FnCtxt in coercion, instead of mimicking a combiner. 2015-01-30 00:27:12 +02:00