Commit Graph

4047 Commits

Author SHA1 Message Date
Alex Crichton
d0029a47c2 rollup merge of #21910: Manishearth/missing_stability
Currently, if a `#![staged_api]` crate contains an exported item without a stability marker (or inherited stability),
the item is useless.

This change introduces a check to ensure that all exported items have a defined stability.

it also introduces the `unmarked_api` feature, which lets users import unmarked features. While this PR should in theory forbid these from existing,
in practice we can't be so sure; so this lets users bypass this check instead of having to wait for the library and/or compiler to be fixed (since otherwise this is a hard error).

r? @aturon
2015-02-03 20:11:20 -08:00
Alex Crichton
74f7e06939 rollup merge of #21899: nikomatsakis/closure-unify-anyhow
This *almost* completes the job for #16440. The idea is that even if we do not know whether some closure type `C` implements `Fn` or `FnMut` (etc), we still know its argument and return types. So if we see an obligation `C : Fn(_0)`, we can unify `_0` with those argument types while still considering the obligation ambiguous and unsatisfied. This helps to make a lot of progress with type inference even before closure kind inference is done.

As part of this PR, the explicit `:` syntax is removed from the AST and completely ignored. We still infer the closure kind based on the expected type if that is available. There are several reasons for this. First, deciding the closure kind earlier is always better, as it allows us to make more progress. Second, this retains a (admittedly obscure) way for users to manually specify the closure kind, which is useful for writing tests if nothing else. Finally, there are still some cases where inference can fail, so it may be useful to have this manual override. (The expectation is that we will eventually revisit an explicit syntax for specifying the closure kind, but it will not be `:` and may be some sort of generalization of the `||` syntax to handle other traits as well.)

This commit does not *quite* fix #16640 because a snapshot is still needed to enable the obsolete syntax errors for explicit `&mut:` and friends.

r? @eddyb as he reviewed the prior patch in this direction
2015-02-03 20:11:20 -08:00
Aaron Turon
3e39f0bc0e Rename std::path to std::old_path
As part of [RFC 474](https://github.com/rust-lang/rfcs/pull/474), this
commit renames `std::path` to `std::old_path`, leaving the existing path
API in place to ease migration to the new one. Updating should be as
simple as adjusting imports, and the prelude still maps to the old path
APIs for now.

[breaking-change]
2015-02-03 14:34:42 -08:00
Manish Goregaokar
b64572cefe Add unmarked_api feature (fixes #21884) 2015-02-04 02:30:31 +05:30
Niko Matsakis
8ddcb06b1d Update for new snapshot after rebasing. 2015-02-03 13:14:36 -05:00
Niko Matsakis
68ad6949d4 Correct one case where the inference was detecting a looser result than the
explicit annotation, leading to "extra `mut` declaration" lint errors.
2015-02-03 13:14:29 -05:00
Niko Matsakis
0431134119 Remove the explicit closure kind syntax from the parser and AST;
upgrade the inference based on expected type so that it is able to
infer the fn kind in isolation even if the full signature is not
available (and we could perhaps do better still in some cases, such as
extracting just the types of the arguments but not the return value).
2015-02-03 11:56:16 -05:00
Alex Crichton
3ef2df9e88 rollup merge of #21845: Potpourri/import-syntax
syntax like `use foo::bar::;` and `use foo:: as bar;` should be rejected, see issue #21629
2015-02-02 11:01:17 -08:00
Alex Crichton
99b2bd4bfa rollup merge of #21842: alexcrichton/issue-21839
Now that associated types are fully implemented the iterator adaptors only need
type parameters which are associated with actual storage. All other type
parameters can either be derived from these (e.g. they are an associated type)
or can be bare on the `impl` block itself.

This is a breaking change due to the removal of type parameters on these
iterator adaptors, but code can fairly easily migrate by just deleting the
relevant type parameters for each adaptor. Other behavior should not be
affected.

Closes #21839
[breaking-change]
2015-02-02 11:01:16 -08:00
Alex Crichton
7335c7dd63 rollup merge of #21830: japaric/for-cleanup
Conflicts:
	src/librustc/metadata/filesearch.rs
	src/librustc_back/target/mod.rs
	src/libstd/os.rs
	src/libstd/sys/windows/os.rs
	src/libsyntax/ext/tt/macro_parser.rs
	src/libsyntax/print/pprust.rs
	src/test/compile-fail/issue-2149.rs
2015-02-02 11:01:12 -08:00
Alex Crichton
075588a493 rollup merge of #21825: kmcallister/ttdelim-span 2015-02-02 10:58:19 -08:00
Alex Crichton
c64b73e520 rollup merge of #21817: edwardw/symmetric-binop
For "symmetric" binary operators, meaning the types of two sides must be
equal, if the type of LHS doesn't know yet but RHS does, use that as an
hint to infer LHS' type.

Closes #21634
2015-02-02 10:58:10 -08:00
Alex Crichton
902abab144 rollup merge of #21787: alexcrichton/std-env
Conflicts:
	src/libstd/sys/unix/backtrace.rs
	src/libstd/sys/unix/os.rs
2015-02-02 10:58:01 -08:00
Alex Crichton
425f2328d0 rollup merge of #21754: semarie/openbsd-rebased
Hi.

Here a commit in order to add OpenBSD support to rust.

- tests status:
run-pass: test result: ok. 1879 passed; 0 failed; 24 ignored; 0 measured
run-fail: test result: ok. 81 passed; 0 failed; 5 ignored; 0 measured
compile-fail: test result: ok. 1634 passed; 0 failed; 22 ignored; 0 measured
run-pass-fulldeps: test result: ok. 22 passed; 0 failed; 1 ignored; 0 measured
compile-fail-fulldeps: test result: ok. 13 passed; 0 failed; 0 ignored; 0 measured

- The current implementation of load_self function (src/libstd/sys/unix/os.rs) isn't optimal as under OpenBSD I haven't found a reliable method to get the filename of a running process. The current implementation is enought for bootstrapping purpose.

- I have disable `run-pass/tcp-stress.rs` test under openbsd. When run manually, the test pass, but when run under `compiletest`, it timeout and echo continuoulsy `Too many open files`.

- For building with jemalloc, a more recent version of jemalloc would be mandatory. See https://github.com/jemalloc/jemalloc/pull/188 for more details.
2015-02-02 10:56:57 -08:00
Alex Crichton
9529ab0e7e rollup merge of #21710: alfie/libsyntax
Conflicts:
	src/libsyntax/parse/parser.rs
2015-02-02 10:56:55 -08:00
Jorge Aparicio
3484706c38 remove unused mut qualifiers 2015-02-02 13:40:18 -05:00
Jorge Aparicio
fd702702ee for x in xs.into_iter() -> for x in xs
Also `for x in option.into_iter()` -> `if let Some(x) = option`
2015-02-02 13:40:18 -05:00
Jorge Aparicio
d5f61b4332 for x in xs.iter_mut() -> for x in &mut xs
Also `for x in option.iter_mut()` -> `if let Some(ref mut x) = option`
2015-02-02 13:40:18 -05:00
Jorge Aparicio
d5d7e6565a for x in xs.iter() -> for x in &xs 2015-02-02 13:40:18 -05:00
Alfie John
9683745fed Omit integer suffix when unnecessary
See PR # 21378 for context
2015-02-02 04:05:54 +00:00
P1start
597b4fa984 Tweak some ‘expected…’ error messages
Fixes #21153.
2015-02-02 15:30:35 +13:00
Alex Crichton
0e4448409e std: Remove extra type params on iter adaptors
Now that associated types are fully implemented the iterator adaptors only need
type parameters which are associated with actual storage. All other type
parameters can either be derived from these (e.g. they are an associated type)
or can be bare on the `impl` block itself.

This is a breaking change due to the removal of type parameters on these
iterator adaptors, but code can fairly easily migrate by just deleting the
relevant type parameters for each adaptor. Other behavior should not be
affected.

Closes #21839
[breaking-change]
2015-02-01 13:05:23 -08:00
Potpourri
0828efd72f Reject syntax like use foo::bar::; and use foo:: as bar; and keywords in view path idents 2015-02-01 23:31:21 +03:00
Alex Crichton
70ed3a48df std: Add a new env module
This is an implementation of [RFC 578][rfc] which adds a new `std::env` module
to replace most of the functionality in the current `std::os` module. More
details can be found in the RFC itself, but as a summary the following methods
have all been deprecated:

[rfc]: https://github.com/rust-lang/rfcs/pull/578

* `os::args_as_bytes`   => `env::args`
* `os::args`            => `env::args`
* `os::consts`          => `env::consts`
* `os::dll_filename`    => no replacement, use `env::consts` directly
* `os::page_size`       => `env::page_size`
* `os::make_absolute`   => use `env::current_dir` + `join` instead
* `os::getcwd`          => `env::current_dir`
* `os::change_dir`      => `env::set_current_dir`
* `os::homedir`         => `env::home_dir`
* `os::tmpdir`          => `env::temp_dir`
* `os::join_paths`      => `env::join_paths`
* `os::split_paths`     => `env::split_paths`
* `os::self_exe_name`   => `env::current_exe`
* `os::self_exe_path`   => use `env::current_exe` + `pop`
* `os::set_exit_status` => `env::set_exit_status`
* `os::get_exit_status` => `env::get_exit_status`
* `os::env`             => `env::vars`
* `os::env_as_bytes`    => `env::vars`
* `os::getenv`          => `env::var` or `env::var_string`
* `os::getenv_as_bytes` => `env::var`
* `os::setenv`          => `env::set_var`
* `os::unsetenv`        => `env::remove_var`

Many function signatures have also been tweaked for various purposes, but the
main changes were:

* `Vec`-returning APIs now all return iterators instead
* All APIs are now centered around `OsString` instead of `Vec<u8>` or `String`.
  There is currently on convenience API, `env::var_string`, which can be used to
  get the value of an environment variable as a unicode `String`.

All old APIs are `#[deprecated]` in-place and will remain for some time to allow
for migrations. The semantics of the APIs have been tweaked slightly with regard
to dealing with invalid unicode (panic instead of replacement).

The new `std::env` module is all contained within the `env` feature, so crates
must add the following to access the new APIs:

    #![feature(env)]

[breaking-change]
2015-02-01 11:08:15 -08:00
Sébastien Marie
fcb30a0b67 openbsd support 2015-02-01 14:41:38 +01:00
Keegan McAllister
cedc6753f2 Fix end of TtDelimited span 2015-01-31 17:41:38 -08:00
Edward Wang
1935bbd913 Make use of a binary operator's RHS type for LHS inference
For "symmetric" binary operators, meaning the types of two side must be
equal, if the type of LHS doesn't know yet but RHS does, use that as an
hint to infer LHS' type.

Closes #21634
2015-02-01 04:06:06 +08:00
Tobias Bucher
b4a43f3864 Kill more isizes 2015-01-31 17:40:40 +01:00
Alex Crichton
3a2530d611 Test fixes and rebase conflicts
Also some tidying up of a bunch of crate attributes
2015-01-30 14:53:34 -08:00
Alex Crichton
f6dd25bb38 rollup merge of #21713: alexcrichton/second-pass-fmt 2015-01-30 13:26:42 -08:00
Alex Crichton
ac1a03d742 rollup merge of #21718: alexcrichton/stabilize-from-str
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 12:03:20 -08:00
Alex Crichton
692a3661fb rollup merge of #21704: FlaPer87/macro-reexport
Conflicts:
	src/libstd/lib.rs
2015-01-30 12:03:16 -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
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
76362f0a0e custom message for refutable patterns in for loops 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
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
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
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
788181d405 s/Show/Debug/g 2015-01-29 07:49:02 -05:00
Jorge Aparicio
92e966e099 register snaphots 2015-01-29 07:49:02 -05:00
Jorge Aparicio
3cc191e58a remove unused imports 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