Commit Graph

34636 Commits

Author SHA1 Message Date
Huon Wilson
a11078f8c3 Update documentation for literal suffixes.
This changes the stated grammar of literals to move all suffixes into
the generic literal production.
2014-11-20 00:03:21 +11:00
Huon Wilson
7586abf01b Adjust Antlr4 lexer to include suffixes.
This makes the formal lexical grammar (more closely) reflect the one
implemented by the compiler.
2014-11-20 00:02:42 +11:00
Huon Wilson
606a309d4a Switch numeric suffix parsing to use the new system.
This moves errors and all handling of numeric suffixes into the parser
rather than the lexer.
2014-11-20 00:02:42 +11:00
Huon Wilson
6679595853 Parse and store suffixes on literals.
This adds an optional suffix at the end of a literal token:
`"foo"bar`. An actual use of a suffix in a expression (or other literal
that the compiler reads) is rejected in the parser.

This doesn't switch the handling of numbers to this system, and doesn't
outlaw illegal suffixes for them yet.
2014-11-20 00:02:42 +11:00
Alfie John
e0b0c83138 doc: clarifying unsafe code vs undefined behavior 2014-11-19 12:43:13 +00:00
Niko Matsakis
2477bc4451 Update libcollections tests to pass the new type rules. They used to return a pointer to the value they were modifying, but this should not have been legal, since that pointer would have to outlive the closure, and the closure continues to modify the value during the execution. This return value was just passed to black_box so as to convince llvm that the value was live, so rather than returning a pointer, modify to just call black_box directly inside the fn. 2014-11-19 06:20:20 -05:00
Niko Matsakis
0b6ec70197 Ensure that the type parameters passed to methods outlive the call expression. Fixes #18899. 2014-11-19 06:20:20 -05:00
Niko Matsakis
b64c7b83dd Refactor QPath to take an ast::TraitRef 2014-11-19 05:53:40 -05:00
Niko Matsakis
8e44688889 Deduce the argument types based on the expected type, trawling through the fulfillment contect if necessary. 2014-11-19 05:52:59 -05:00
Niko Matsakis
fe2fcb39f4 Move closure checking into its own file. Shrink check/mod.rs! 2014-11-19 05:31:16 -05:00
Daniel Micay
210e059750 clearly define int and uint to fix unsoundness
This fixes the gap in the language definition causing #18726 by defining
a clear bound on the maximum size for libraries to enforce.

Closes #18069
2014-11-19 05:17:56 -05:00
juxiliary
62a2a1d5cf Adding switch in vim plugin to toggle format opts 2014-11-19 18:06:53 +10:00
Valerii Hiora
38b14258a3 iOS: fixed broken build after disallowed coercions 2014-11-19 09:43:15 +02:00
bors
cf7df1e638 auto merge of #18483 : eddyb/rust/safe-ty, r=nikomatsakis
After more than a month of sitting on this patch, rebasing and tracking down some nasty bugs (there's might be still one out there, but it only manifested in `middle::trans::reflect` which is now gone), I'd like to merge it as it is.

This changeset makes middle::ty safe, linking the lifetime of a type to the type context it was created in.
It's a prerequisite for introducing function-local type contexts to localize types with inference variables, in order to (potentially) free hundreds of MBs from rustc's memory usage peak.
2014-11-19 07:21:42 +00:00
Alex Crichton
4af3494bb0 std: Stabilize std::fmt
This commit applies the stabilization of std::fmt as outlined in [RFC 380][rfc].
There are a number of breaking changes as a part of this commit which will need
to be handled to migrated old code:

* A number of formatting traits have been removed: String, Bool, Char, Unsigned,
  Signed, and Float. It is recommended to instead use Show wherever possible or
  to use adaptor structs to implement other methods of formatting.

* The format specifier for Boolean has changed from `t` to `b`.

* The enum `FormatError` has been renamed to `Error` as well as becoming a unit
  struct instead of an enum. The `WriteError` variant no longer exists.

* The `format_args_method!` macro has been removed with no replacement. Alter
  code to use the `format_args!` macro instead.

* The public fields of a `Formatter` have become read-only with no replacement.
  Use a new formatting string to alter the formatting flags in combination with
  the `write!` macro. The fields can be accessed through accessor methods on the
  `Formatter` structure.

Other than these breaking changes, the contents of std::fmt should now also all
contain stability markers. Most of them are still #[unstable] or #[experimental]

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0380-stabilize-std-fmt.md
[breaking-change]

Closes #18904
2014-11-18 21:16:22 -08:00
Eduard Burtescu
bf0766ada1 rustdoc: fix fallout of ty::t -> Ty<'tcx>. 2014-11-19 06:24:35 +02:00
Eduard Burtescu
8accc7c386 rustc: middle: simplify primitive type declaration in ty. 2014-11-19 06:24:35 +02:00
Eduard Burtescu
9f7aa7fa76 rustc: middle: remove obsolete ty::get. 2014-11-19 06:24:35 +02:00
Eduard Burtescu
01105ffde3 rustc: middle: avoid clones in ty_fn_{sig,args}. 2014-11-19 06:24:35 +02:00
Eduard Burtescu
4c3ad48c45 rustc: fix fallout of making Ty an alias for &TyS instead of a wrapper. 2014-11-19 06:24:35 +02:00
Eduard Burtescu
5bc98954d5 rustc: fix fallout of adding the 'tcx lifetime to Ty. 2014-11-19 06:24:34 +02:00
Eduard Burtescu
92ae0c6c25 rustc: middle: ty: replace unsafe pointers with references in Ty. 2014-11-19 06:24:34 +02:00
Eduard Burtescu
9706d8f602 rustc: middle: rename ty::t to Ty and use it unqualified everywhere. 2014-11-19 06:24:34 +02:00
Eduard Burtescu
21da750663 rustc: avoid use-ing syntax::ast::*. 2014-11-19 06:24:34 +02:00
Aaron Turon
e7fab22bbf Fallout from deprecation 2014-11-18 20:22:13 -08:00
Aaron Turon
bdbc09ad48 libs: stabilize most numerics after RFC changes
This commit adds stability markers for the APIs that have recently been
aligned with [numerics
reform](https://github.com/rust-lang/rfcs/pull/369). For APIs that were
changed as part of that reform, `#[unstable]` is used to reflect the
recency, but the APIs will become `#[stable]` in a follow-up pass.

In addition, a few aspects of the APIs not explicitly covered by the RFC
are marked here -- in particular, constants for floats.

This commit does not mark the `uint` or `int` modules as `#[stable]`,
given the ongoing debate out the names and roles of these types.

Due to some deprecation (see the RFC for details), this is a:

[breaking-change]
2014-11-18 20:07:58 -08:00
Huon Wilson
ff0278bc15 Update makefiles to ensure src/grammar/verify.rs is built.
It's not run, but this ensures that the code at least doesn't go out of
date.
2014-11-19 13:12:05 +11:00
Huon Wilson
9d20a46799 Update src/grammar for language changes. 2014-11-19 13:10:43 +11:00
Huon Wilson
5b5638f686 Switch to an independent enum for Lit* subtokens. 2014-11-19 12:52:31 +11:00
Steve Klabnik
16b9f67bf3 Error handling guide 2014-11-18 19:30:05 -05:00
bors
e09d98603e auto merge of #19044 : murarth/rust/libsyntax-view-item, r=alexcrichton
Allows parsing view items (`use` and `extern crate`) individually. Does not change behavior of any existing functions.

Closes #19024
2014-11-18 23:51:43 +00:00
Keegan McAllister
ad61ff4b81 deriving: error out when used on a non-type
Besides being more helpful, this gives us the flexibility to later define
a meaning for something like

    #[deriving(...)]
    mod bar { ... }
2014-11-18 14:43:20 -08:00
Jakub Bukaj
bde225e2fa Feature gate non-ASCII lifetime identifiers
Fixes #19069.
2014-11-18 23:07:14 +01:00
bors
1628b98183 auto merge of #18870 : barosl/rust/os-ioresult, r=alexcrichton
Make old-fashioned functions in the `std::os` module utilize `IoResult`.

I'm still investigating the possibility to include more functions in this pull request. Currently, it covers `getcwd()`, `make_absolute()`, and `change_dir()`. The issues covered by this PR are #16946 and #16315.

A few concerns:

- Should we provide `OsError` in distinction from `IoError`? I'm saying this because in Python, those two are distinguished. One advantage that we keep using `IoError` is that we can make the error cascade down other functions whose return type also includes `IoError`. An example of such functions is `std::io::TempDir::new_in()`, which uses `os::make_absolute()` as well as returns `IoResult<TempDir>`.
- `os::getcwd()` uses an internal buffer whose size is 2048 bytes, which is passed to `getcwd(3)`. There is no upper limitation of file paths in the POSIX standard, but typically it is set to 4096 bytes such as in Linux. Should we increase the buffer size? One thing that makes me nervous is that the size of 2048 bytes already seems a bit excessive, thinking that in normal cases, there would be no filenames that even exceeds 512 bytes.

Fixes #16946.
Fixes #16315.

Any ideas are welcomed. Thanks!
2014-11-18 21:56:58 +00:00
Barosl Lee
b5286af703 Make os::setenv() and os::unsetenv() panic if an error occurs
These functions can fail if:

- EINVAL: The name is empty, or contains an '=' character
- ENOMEM: Insufficient memory
2014-11-19 05:31:45 +09:00
Barosl Lee
5de56b3ca1 Make os::change_dir() return IoResult<()>
os::change_dir() returns bool, without a meaningful error message.
Change it to return IoResult<()> to indicate what IoError caused the
failure.

Fixes #16315.

[breaking-change]
2014-11-19 05:31:45 +09:00
Barosl Lee
6f422c4c05 Make os::getcwd() return IoResult<Path>
os::getcwd() panics if the current directory is not available. According
to getcwd(3), there are three cases:

- EACCES: Permission denied.
- ENOENT: The current working directory has been removed.
- ERANGE: The buffer size is less than the actual absolute path.

This commit makes os::getcwd() return IoResult<Path>, not just Path,
preventing it from panicking.

As os::make_absolute() depends on os::getcwd(), it is also modified to
return IoResult<Path>.

Fixes #16946.

[breaking-change]
2014-11-19 05:31:45 +09:00
Alex Crichton
e3c658f649 Register new snapshots 2014-11-18 11:35:22 -08:00
bors
c8d6e3b2c2 auto merge of #18993 : nikomatsakis/rust/hrtb-5, r=pcwalton
Enough said.

Fixes #18639.

r? @pcwalton (or someone else?)

This is a [breaking-change]. In particular, several feature gates related to unboxed closures were consolidated into one (`overloaded_calls`, `unboxed_closure_sugar` => `unboxed_closures`). Otherwise, I think everything that worked before should still work. File a bug and cc @nikomatsakis if you find otherwise. :)
2014-11-18 19:11:43 +00:00
Niko Matsakis
6866bf3234 Fix merge conflict about [] coercions in new tests 2014-11-18 13:20:59 -05:00
Steve Klabnik
0e6d97aab2 New guide: error handling 2014-11-18 12:56:55 -05:00
Niko Matsakis
56ba260749 Update test for equivalency to include region binders in object types, add new tests relating to HRTB, consolidate the unboxed_closures and overloaded_calls feature gates. 2014-11-18 12:32:38 -05:00
Niko Matsakis
7a846b86a8 Update tests for () notation to use traits not structs 2014-11-18 12:32:38 -05:00
Niko Matsakis
5a28d178af Allow impl's to have late-bound regions. Introduces another level of
region binding at the impl site, so for method types that come from impls,
it is necessary to liberate/instantiate late-bound regions at multiple
depths.
2014-11-18 12:32:38 -05:00
Niko Matsakis
6fb68f1c81 Introduce machinery for higher-ranked TraitRefs 2014-11-18 12:32:38 -05:00
Niko Matsakis
ecdb741df7 Test resolving of names with for binders. 2014-11-18 12:32:38 -05:00
Niko Matsakis
a298014245 Miscellaneous reformatttings and renamings. 2014-11-18 12:32:38 -05:00
Niko Matsakis
efef81e966 Stop checking the correctness of explicit self twice; instead, just
use simple pattern matching to take a guess at what the method's self
category is in astconv, and check it more thoroughly later.
2014-11-18 12:32:38 -05:00
Niko Matsakis
c8a94c5dfa Convert TyPolyTraitRef to accept arbitary bounds, so that things like
`Box<for<'a> Foo<&'a T> + 'a>` can be accepted. Also cleanup the visitor/fold
in general, exposing more callbacks.
2014-11-18 12:32:37 -05:00
Niko Matsakis
9c808ffee4 Make it an error to use parenthetical notation with
something other than a trait type.
2014-11-18 12:32:37 -05:00