Commit Graph

39776 Commits

Author SHA1 Message Date
Björn Steinbrink
3a8f989dbb Always evaluate the expression in [expr; n]
In case that there is a destination for the array, like in
"let x = [expr; n]", we currently don't evaluate the given expression if
n is zero. That's inconsistent with all other cases, including "[expr;
0]" without a destination.

Fixes #23354
2015-03-14 14:19:29 +01:00
bors
766a4e1acc Auto merge of #23333 - oli-obk:slice_from_raw_parts, r=alexcrichton
at least that's what the docs say: http://doc.rust-lang.org/std/slice/fn.from_raw_parts.html

A few situations got prettier. In some situations the mutability of the resulting and source pointers differed (and was cast away by transmute), the mutability matches now.
2015-03-14 08:55:31 +00:00
bors
f7453f940b Auto merge of #22948 - rprichard:simple-panic-opt, r=alexcrichton
Reduce code size overhead from core::panicking::panic

core::panicking::panic currently creates an Arguments structure using
format_args!("{}", expr), which formats the expr str using the Display::fmt.
Display::fmt pulls in Formatter::pad, which then also pulls in string-related
code for truncation and padding.

If core::panicking::panic instead creates an Arguments structure with a string
piece, it is possible that the Display::fmt function for str can be optimized
out of the program.

In my testing with a 32-bit x86 bare metal program, the change tended to save
between ~100 bytes and ~5500 bytes, depending on what other panic* functions
the program invokes and whether the panic_fmt lang item uses the Arguments
value.
2015-03-14 01:04:37 +00:00
bors
3e4be02b80 Auto merge of #23292 - alexcrichton:stabilize-io, r=aturon
The new `std::io` module has had some time to bake now, and this commit
stabilizes its functionality. There are still portions of the module which
remain unstable, and below contains a summart of the actions taken.

This commit also deprecates the entire contents of the `old_io` module in a
blanket fashion. All APIs should now have a reasonable replacement in the
new I/O modules.

Stable APIs:

* `std::io` (the name)
* `std::io::prelude` (the name)
* `Read`
* `Read::read`
* `Read::{read_to_end, read_to_string}` after being modified to return a `usize`
  for the number of bytes read.
* `ReadExt`
* `Write`
* `Write::write`
* `Write::{write_all, write_fmt}`
* `WriteExt`
* `BufRead`
* `BufRead::{fill_buf, consume}`
* `BufRead::{read_line, read_until}` after being modified to return a `usize`
  for the number of bytes read.
* `BufReadExt`
* `BufReader`
* `BufReader::{new, with_capacity}`
* `BufReader::{get_ref, get_mut, into_inner}`
* `{Read,BufRead} for BufReader`
* `BufWriter`
* `BufWriter::{new, with_capacity}`
* `BufWriter::{get_ref, get_mut, into_inner}`
* `Write for BufWriter`
* `IntoInnerError`
* `IntoInnerError::{error, into_inner}`
* `{Error,Display} for IntoInnerError`
* `LineWriter`
* `LineWriter::{new, with_capacity}` - `with_capacity` was added
* `LineWriter::{get_ref, get_mut, into_inner}` - `get_mut` was added)
* `Write for LineWriter`
* `BufStream`
* `BufStream::{new, with_capacities}`
* `BufStream::{get_ref, get_mut, into_inner}`
* `{BufRead,Read,Write} for BufStream`
* `stdin`
* `Stdin`
* `Stdin::lock`
* `Stdin::read_line` - added method
* `StdinLock`
* `Read for Stdin`
* `{Read,BufRead} for StdinLock`
* `stdout`
* `Stdout`
* `Stdout::lock`
* `StdoutLock`
* `Write for Stdout`
* `Write for StdoutLock`
* `stderr`
* `Stderr`
* `Stderr::lock`
* `StderrLock`
* `Write for Stderr`
* `Write for StderrLock`
* `io::Result`
* `io::Error`
* `io::Error::last_os_error`
* `{Display, Error} for Error`

Unstable APIs:

(reasons can be found in the commit itself)

* `Write::flush`
* `Seek`
* `ErrorKind`
* `Error::new`
* `Error::from_os_error`
* `Error::kind`

Deprecated APIs

* `Error::description` - available via the `Error` trait
* `Error::detail` - available via the `Display` implementation
* `thread::Builder::{stdout, stderr}`

Changes in functionality:

* `old_io::stdio::set_stderr` is now a noop as the infrastructure for printing
  backtraces has migrated to `std::io`.

[breaking-change]
2015-03-13 20:22:16 +00:00
bors
9eb69abad8 Auto merge of #23337 - Manishearth:rollup, r=Manishearth
r? @Manishearth
2015-03-13 17:49:15 +00:00
Alex Crichton
981bf5f690 Fallout of std::old_io deprecation 2015-03-13 10:00:28 -07:00
Manish Goregaokar
40b64645fe rm unused import 2015-03-13 19:52:18 +05:30
Manish Goregaokar
825f49a89a Fix def -> PathResolution 2015-03-13 19:51:09 +05:30
Manish Goregaokar
0d37323fd3 Rollup merge of #21468 - sanxiyn:dead-variant, r=
This implements a wish suggested in #17410, detecting enum variants that are never constructed, even in the presence of `#[derive(Clone)]`. The implementation is general and not specific to `#[derive(Clone)]`.

r? @jakub-
2015-03-13 18:12:05 +05:30
Manish Goregaokar
0e4b8d6117 Rollup merge of #23324 - rprichard:fix-freebsd, r=brson
Currently, target.mk passes -L \"\" when LLVM_STDCPP_LOCATION_$(2) is empty.

This fixes #23287.
2015-03-13 18:11:57 +05:30
Manish Goregaokar
d0f98fcc7f Rollup merge of #23322 - dotdash:jemalloc_attrs, r=brson
When this attribute is applied to a function, its return value gets the
noalias attribute, which is how you tell LLVM that the function returns
a \"new\" pointer that doesn't alias anything accessible to the caller,
i.e. it acts like a memory allocator.

Plain malloc doesn't need this attribute because LLVM already knows
about malloc and adds the attribute itself.
2015-03-13 18:11:51 +05:30
Manish Goregaokar
63cd9f9d89 Rollup merge of #23321 - apasel422:hash, r=alexcrichton
It is no longer possible to specialize on the `Hasher` because it moved to a method-level type parameter.
2015-03-13 18:11:46 +05:30
Manish Goregaokar
63bdfbf90a Rollup merge of #23317 - tanadeau:fix-formatting-and-grammar, r=steveklabnik
Fixed grammar errors (incorrect uses of commas and \"you're\" instead of \"your\") and broke up a long line.

r? @steveklabnik
2015-03-13 18:11:40 +05:30
Manish Goregaokar
b00c310985 Rollup merge of #23312 - gkoz:ptr_from_box_docs, r=steveklabnik
Show how to get a pointer without destroying the box.
Use `boxed::into_raw` instead of `mem::transmute`.

I removed the `let my_num: *const i32 = mem::transmute(my_num);` case altogether because we own the box, a `*mut` pointer is good anywhere a `*const` is needed, `from_raw` takes a mutable pointer and casting from a `*const` caused an ICE.
2015-03-13 18:11:34 +05:30
Manish Goregaokar
da054a5f87 Rollup merge of #23328 - alexcrichton:rustdoc-default-impl, r=brson
This adds a special code path for impls which are listed as default impls to
ensure that they're loaded correctly.
2015-03-13 18:11:27 +05:30
Manish Goregaokar
99ce371d1c Rollup merge of #23325 - brson:beta, r=alexcrichton
This is the second time I've made this typo.
2015-03-13 18:11:21 +05:30
Manish Goregaokar
6354387e42 Rollup merge of #23310 - michaelwoerister:gdb-std-pp, r=alexcrichton
```rust
Rust:  let slice: &[i32] = &[0, 1, 2, 3];
GDB:   $1 = &[i32](len: 4) = {0, 1, 2, 3}

Rust:  let vec = vec![4, 5, 6, 7];
GDB:   $2 = Vec<u64>(len: 4, cap: 4) = {4, 5, 6, 7}

Rust:  let str_slice = \"IAMA string slice!\";
GDB:   $3 = \"IAMA string slice!\"

Rust:  let string = \"IAMA string!\".to_string();
GDB:   $4 = \"IAMA string!\"
```
Neat!
2015-03-13 18:11:13 +05:30
Manish Goregaokar
7d2ee7a9da Rollup merge of #23307 - michaelwoerister:lldb-vec-pp-bug, r=alexcrichton
Fixes #22656. Also adds a nice pretty printer for `Vec`.
2015-03-13 18:11:07 +05:30
Oliver Schneider
85080fa81d fix tests 2015-03-13 13:09:34 +01:00
bors
ee7696383f Auto merge of #23307 - michaelwoerister:lldb-vec-pp-bug, r=alexcrichton
Fixes #22656. Also adds a nice pretty printer for `Vec`.
2015-03-13 11:44:47 +00:00
Oliver Schneider
6584ae5491 slice::from_raw_parts is preferred over transmuting a fresh raw::Slice 2015-03-13 09:56:18 +01:00
Alex Crichton
4e25765aa2 rustdoc: Fix ICE with cross-crate default impls
This adds a special code path for impls which are listed as default impls to
ensure that they're loaded correctly.
2015-03-12 21:01:49 -07:00
Alex Crichton
d54bd9f29a std: Stabilize the io module
The new `std::io` module has had some time to bake now, and this commit
stabilizes its functionality. There are still portions of the module which
remain unstable, and below contains a summart of the actions taken.

This commit also deprecates the entire contents of the `old_io` module in a
blanket fashion. All APIs should now have a reasonable replacement in the
new I/O modules.

Stable APIs:

* `std::io` (the name)
* `std::io::prelude` (the name)
* `Read`
* `Read::read`
* `Read::{read_to_end, read_to_string}` after being modified to return a `usize`
  for the number of bytes read.
* `Write`
* `Write::write`
* `Write::{write_all, write_fmt}`
* `BufRead`
* `BufRead::{fill_buf, consume}`
* `BufRead::{read_line, read_until}` after being modified to return a `usize`
  for the number of bytes read.
* `BufReader`
* `BufReader::{new, with_capacity}`
* `BufReader::{get_ref, get_mut, into_inner}`
* `{Read,BufRead} for BufReader`
* `BufWriter`
* `BufWriter::{new, with_capacity}`
* `BufWriter::{get_ref, get_mut, into_inner}`
* `Write for BufWriter`
* `IntoInnerError`
* `IntoInnerError::{error, into_inner}`
* `{Error,Display} for IntoInnerError`
* `LineWriter`
* `LineWriter::{new, with_capacity}` - `with_capacity` was added
* `LineWriter::{get_ref, get_mut, into_inner}` - `get_mut` was added)
* `Write for LineWriter`
* `BufStream`
* `BufStream::{new, with_capacities}`
* `BufStream::{get_ref, get_mut, into_inner}`
* `{BufRead,Read,Write} for BufStream`
* `stdin`
* `Stdin`
* `Stdin::lock`
* `Stdin::read_line` - added method
* `StdinLock`
* `Read for Stdin`
* `{Read,BufRead} for StdinLock`
* `stdout`
* `Stdout`
* `Stdout::lock`
* `StdoutLock`
* `Write for Stdout`
* `Write for StdoutLock`
* `stderr`
* `Stderr`
* `Stderr::lock`
* `StderrLock`
* `Write for Stderr`
* `Write for StderrLock`
* `io::Result`
* `io::Error`
* `io::Error::last_os_error`
* `{Display, Error} for Error`

Unstable APIs:

(reasons can be found in the commit itself)

* `Write::flush`
* `Seek`
* `ErrorKind`
* `Error::new`
* `Error::from_os_error`
* `Error::kind`

Deprecated APIs

* `Error::description` - available via the `Error` trait
* `Error::detail` - available via the `Display` implementation
* `thread::Builder::{stdout, stderr}`

Changes in functionality:

* `old_io::stdio::set_stderr` is now a noop as the infrastructure for printing
  backtraces has migrated to `std::io`.
* The `ReadExt`, `WriteExt`, and `BufReadExt` extension traits were all removed
  by folding functionality into the corresponding trait.

[breaking-change]
2015-03-12 20:39:03 -07:00
Björn Steinbrink
0942803f50 Add an "allocator" attribute to mark functions as allocators
When this attribute is applied to a function, its return value gets the
noalias attribute, which is how you tell LLVM that the function returns
a "new" pointer that doesn't alias anything accessible to the caller,
i.e. it acts like a memory allocator.

Plain malloc doesn't need this attribute because LLVM already knows
about malloc and adds the attribute itself.
2015-03-13 03:19:30 +01:00
bors
79dd393a4f Auto merge of #23229 - aturon:stab-path, r=alexcrichton
This commit stabilizes essentially all of the new `std::path` API. The
API itself is changed in a couple of ways (which brings it in closer
alignment with the RFC):

* `.` components are now normalized away, unless they appear at the
  start of a path. This in turn effects the semantics of e.g. asking for
  the file name of `foo/` or `foo/.`, both of which yield `Some("foo")`
  now. This semantics is what the original RFC specified, and is also
  desirable given early experience rolling out the new API.

* The `parent` method is now `without_file` and succeeds if, and only
  if, `file_name` is `Some(_)`. That means, in particular, that it fails
  for a path like `foo/../`. This change affects `pop` as well.

In addition, the `old_path` module is now deprecated.

[breaking-change]

r? @alexcrichton
2015-03-13 01:00:02 +00:00
Brian Anderson
ebcb1dca43 Fix naming of beta artifacts again 2015-03-12 17:37:51 -07:00
Aaron Turon
42c4e481cd Stabilize std::path
This commit stabilizes essentially all of the new `std::path` API. The
API itself is changed in a couple of ways (which brings it in closer
alignment with the RFC):

* `.` components are now normalized away, unless they appear at the
  start of a path. This in turn effects the semantics of e.g. asking for
  the file name of `foo/` or `foo/.`, both of which yield `Some("foo")`
  now. This semantics is what the original RFC specified, and is also
  desirable given early experience rolling out the new API.

* The `parent` function now succeeds if, and only if, the path has at
  least one non-root/prefix component. This change affects `pop` as
  well.

* The `Prefix` component now involves a separate `PrefixComponent`
  struct, to better allow for keeping both parsed and unparsed prefix data.

In addition, the `old_path` module is now deprecated.

Closes #23264

[breaking-change]
2015-03-12 16:38:58 -07:00
Andrew Paseltiner
ae21b4f581 remove mention of specialization from Hash trait
It is no longer possible to specialize on the `Hasher` because it moved
to a method-level type parameter.
2015-03-12 18:09:52 -04:00
Trent Nadeau
ccfc381044 Fixed several grammar errors and broke up very long line. 2015-03-12 17:00:35 -04:00
bors
c9b03c24ec Auto merge of #23265 - eddyb:meth-ast-refactor, r=nikomatsakis
The end result is that common fields (id, name, attributes, etc.) are stored in now-structures `ImplItem` and `TraitItem`.
The signature of a method is no longer duplicated between methods with a body (default/impl) and those without, they now share `MethodSig`.

This is also a [breaking-change] because of minor bugfixes and changes to syntax extensions:
* `pub fn` methods in a trait no longer parse - remove the `pub`, it has no meaning anymore
* `MacResult::make_methods` is now `make_impl_items` and the return type has changed accordingly
* `quote_method` is gone, because `P<ast::Method>` doesn't exist and it couldn't represent a full method anyways - could be replaced by `quote_impl_item`/`quote_trait_item` in the future, but I do hope we realize how silly that combinatorial macro expansion is and settle on a single `quote` macro + some type hints - or just no types at all (only token-trees)

r? @nikomatsakis This is necessary (hopefully also sufficient) for associated constants.
2015-03-12 20:13:23 +00:00
Gleb Kozyrev
5d9ed0bc0e Update the ways to get a pointer from a box
Show how to get a pointer without destroying the box.
Use `boxed::into_raw` instead of `mem::transmute`.
2015-03-12 20:48:04 +02:00
bors
538840bc2d Auto merge of #23245 - alexcrichton:allow-warnings-again, r=aturon
These were suppressing lots of interesting warnings! Turns out there was also
quite a bit of dead code.
2015-03-12 17:39:30 +00:00
Alex Crichton
c933d44f7b std: Remove #[allow] directives in sys modules
These were suppressing lots of interesting warnings! Turns out there was also
quite a bit of dead code.
2015-03-12 10:23:27 -07:00
Michael Woerister
90fc28d0f2 debuginfo: Add GDB pretty printers for slices, Vec<>, and String. 2015-03-12 17:05:44 +01:00
bors
206ee0e853 Auto merge of #23299 - mdinger:monospace_table, r=steveklabnik
The [literals table](http://doc.rust-lang.org/reference.html#characters-and-strings) now looks ugly but compact. Add back the monospace text.
2015-03-12 13:47:20 +00:00
Michael Woerister
07240d6026 debuginfo: Make LLDB pretty printer correctly handle zero-sized fields. 2015-03-12 12:18:15 +01:00
Ryan Prichard
de52403295 Avoid passing -L "" to rustc.
Currently, target.mk passes -L "" when LLVM_STDCPP_LOCATION_$(2) is empty.

This fixes #23287.
2015-03-12 04:09:12 -07:00
bors
49f7550a25 Auto merge of #23162 - sfackler:debug-builders, r=alexcrichton
I've made some minor changes from the implementation attached to the RFC to try to minimize codegen. The methods now take `&Debug` trait objects rather than being parameterized and there are inlined stub methods that call to non-inlined methods to do the work.

r? @alexcrichton 

cc @huonw for the `derive(Debug)` changes.
2015-03-12 07:30:44 +00:00
bors
8715a65496 Auto merge of #23298 - Manishearth:rollup, r=Manishearth
None
2015-03-12 04:53:31 +00:00
mdinger
fb0ee646e9 Add monospace font back to literals table 2015-03-12 00:37:47 -04:00
Manish Goregaokar
419c0ff321 Rm unused feature 2015-03-12 09:16:36 +05:30
Manish Goregaokar
7f7a3cc29d Rollup merge of #23296 - shepmaster:explain-why-joinguard-is-must-use, r=alexcrichton 2015-03-12 09:15:06 +05:30
Manish Goregaokar
3d70c7042c Rollup merge of #23295 - johnz133:patch-1, r=steveklabnik
Changed the docs to reflect that
2015-03-12 09:14:59 +05:30
Manish Goregaokar
85d836a2b2 Rollup merge of #23279 - steveklabnik:gh23244, r=alexcrichton
Fixes #23244
2015-03-12 09:14:51 +05:30
Manish Goregaokar
cc6ef80fa4 Rollup merge of #23275 - aochagavia:constants, r=eddyb
Fixes #23260

r? @eddyb
2015-03-12 09:14:44 +05:30
Manish Goregaokar
e4e5640a6e Rollup merge of #23274 - rprichard:fix-21715, r=pnkfelix
* Consumers of handle_options assume the unstable options are defined in
   the getopts::Matches value if -Z unstable-options is set, but that's not
   the case if there weren't any actual unstable options. Fix this by
   always reparsing options when -Z unstable-options is set.

 * If both argument parsing attempts fail, print the error from the second
   attempt rather than the first. The error from the first is very poor
   whenever unstable options are present. e.g.:

       $ rustc hello.rs -Z unstable-options --show-span
       error: Unrecognized option: 'show-span'.
       $ rustc hello.rs -Z unstable-options --pretty --pretty
       error: Unrecognized option: 'pretty'.
       $ rustc hello.rs -Z unstable-options --pretty --bad-option
       error: Unrecognized option: 'pretty'.

 * On the second parse, add a separate pass to reject unstable options if
   -Z unstable-options wasn't specified.

Fixes #21715.
r? @pnkfelix
2015-03-12 09:14:38 +05:30
Manish Goregaokar
99dc60dc24 Rollup merge of #23270 - frewsxcv:patch-5, r=alexcrichton
Markdown requires a newline before bullet points, and since there's not one here, they'll get rendered incorrectly
2015-03-12 09:14:31 +05:30
Manish Goregaokar
6290a344a6 Rollup merge of #23263 - alexcrichton:stabilize-from-raw-parts, r=brson
These new APIs have had some time to bake now, and no pressing issues have come
up so they should be ok for stabilizing. Specifically, these two APIs were
stabilized:

* `slice::from_raw_parts`
* `slice::from_raw_parts_mut`
2015-03-12 09:14:26 +05:30
Manish Goregaokar
34d87b29f0 Rollup merge of #23257 - jmesmon:fix-debug, r=alexcrichton
configure: have --enable-debug set -C debug-assertions=on so `debug!()` works again
2015-03-12 09:14:21 +05:30
Manish Goregaokar
e4010d1bf6 Rollup merge of #23255 - dhuseby:master, r=alexcrichton
it turns out that jemalloc doesn't behave well on bitrig.  with jemalloc enabled i get some kernel errors related to sbrk failures.  with jemalloc disabled, the errors go away.  i am investigating, but in the mean time, we should just disable jemalloc by default on bitrig.
2015-03-12 09:14:16 +05:30