rust/src/libsyntax
Alex Crichton f3657170b1 rollup merge of #22482: alexcrichton/cstr-changes
This commit is an implementation of [RFC 592][r592] and [RFC 840][r840]. These
two RFCs tweak the behavior of `CString` and add a new `CStr` unsized slice type
to the module.

[r592]: https://github.com/rust-lang/rfcs/blob/master/text/0592-c-str-deref.md
[r840]: https://github.com/rust-lang/rfcs/blob/master/text/0840-no-panic-in-c-string.md

The new `CStr` type is only constructable via two methods:

1. By `deref`'ing from a `CString`
2. Unsafely via `CStr::from_ptr`

The purpose of `CStr` is to be an unsized type which is a thin pointer to a
`libc::c_char` (currently it is a fat pointer slice due to implementation
limitations). Strings from C can be safely represented with a `CStr` and an
appropriate lifetime as well. Consumers of `&CString` should now consume `&CStr`
instead to allow producers to pass in C-originating strings instead of just
Rust-allocated strings.

A new constructor was added to `CString`, `new`, which takes `T: IntoBytes`
instead of separate `from_slice` and `from_vec` methods (both have been
deprecated in favor of `new`). The `new` method returns a `Result` instead of
panicking.  The error variant contains the relevant information about where the
error happened and bytes (if present). Conversions are provided to the
`io::Error` and `old_io::IoError` types via the `FromError` trait which
translate to `InvalidInput`.

This is a breaking change due to the modification of existing `#[unstable]` APIs
and new deprecation, and more detailed information can be found in the two RFCs.
Notable breakage includes:

* All construction of `CString` now needs to use `new` and handle the outgoing
  `Result`.
* Usage of `CString` as a byte slice now explicitly needs a `.as_bytes()` call.
* The `as_slice*` methods have been removed in favor of just having the
  `as_bytes*` methods.

Closes #22469
Closes #22470
[breaking-change]
2015-02-18 14:32:10 -08:00
..
ast_map Opt for .cloned() over .map(|x| x.clone()) etc. 2015-02-18 00:56:07 +00:00
diagnostics Remove usage of .map(|&foo| foo) 2015-02-18 00:57:35 +00:00
ext rollup merge of #22480: alexcrichton/hashv3 2015-02-18 14:32:03 -08:00
parse Remove usage of .map(|&foo| foo) 2015-02-18 00:57:35 +00:00
print rollup merge of #22287: Ryman/purge_carthographers 2015-02-18 14:31:55 -08:00
util std: Stabilize the hash module 2015-02-18 08:26:20 -08:00
abi.rs openbsd support 2015-02-01 14:41:38 +01:00
ast_util.rs Libsyntax has been updated 2015-02-06 11:59:10 +01:00
ast.rs Update metadata to reflect that predicates/schemes/trait-defs are now severed 2015-02-12 13:02:37 -05:00
attr.rs Update to last version, remove "[]" as much as possible 2015-02-06 12:03:46 +01:00
codemap.rs make codemap more robust in face of ill-formed spans. 2015-02-05 23:47:17 +01:00
config.rs Process cfg_attr right before stripping cfg 2015-02-09 10:12:14 -08:00
diagnostic.rs std: Implement CString-related RFCs 2015-02-18 14:15:43 -08:00
feature_gate.rs Rollup merge of #22383 - pnkfelix:pass-features-along-during-expansion, r=huonw 2015-02-17 17:33:20 +05:30
fold.rs rollup merge of #22116: kmcallister/cfg_attr 2015-02-10 08:43:01 -08:00
lib.rs std: Stabilize the hash module 2015-02-18 08:26:20 -08:00
owned_slice.rs cleanup: replace as[_mut]_slice() calls with deref coercions 2015-02-05 13:45:01 -05:00
ptr.rs std: Stabilize the hash module 2015-02-18 08:26:20 -08:00
show_span.rs
std_inject.rs Fake up #![no_std] on pretty-printing; keep it out of AST 2015-02-07 10:49:58 -08:00
test.rs rustc: Fix a number of stability lint holes 2015-02-11 12:14:59 -08:00
visit.rs cleanup: replace as[_mut]_slice() calls with deref coercions 2015-02-05 13:45:01 -05:00