about summary refs log tree commit diff
path: root/src/libcore/ptr.rs
AgeCommit message (Collapse)AuthorLines
2014-09-16Fallout from renamingAaron Turon-2/+2
2014-09-16Align with _mut conventionsAaron Turon-1/+5
As per [RFC 52](https://github.com/rust-lang/rfcs/blob/master/active/0052-ownership-variants.md), use `_mut` suffixes to mark mutable variants, and `into_iter` for moving iterators. [breaking-change]
2014-08-31Rename `RawPtr::to_option()` to `RawPtr::as_ref()`Andrew Poelstra-8/+38
As outlined in https://aturon.github.io/style/naming/conversions.html `to_` functions names should only be used for expensive operations. Thus `to_option` is better named `as_option`. Also, putting type names into method names is considered bad style; what the user is really trying to get is a reference. This `as_ref` is even better. Also, we are missing a mutable version of this method. So add a new trait `RawMutPtr` with a corresponding `as_mut` methode. Finally, there is a bug in the signature of `to_option` which has been around since lifetime elision: originally the returned reference had 'static lifetime, but since the elision changes this become the lifetime of the raw pointer (which does not make sense, since the pointer lifetime and referent lifetime are unrelated). Fix the bug to return a reference with a fresh lifetime (which will be inferred from the calling context). [breaking-change]
2014-08-08Register new snapshot 12e0f72Niko Matsakis-3/+0
2014-07-24librustc: Stop desugaring `for` expressions and translate them directly.Patrick Walton-1/+4
This makes edge cases in which the `Iterator` trait was not in scope and/or `Option` or its variants were not in scope work properly. This breaks code that looks like: struct MyStruct { ... } impl MyStruct { fn next(&mut self) -> Option<int> { ... } } for x in MyStruct { ... } { ... } Change ad-hoc `next` methods like the above to implementations of the `Iterator` trait. For example: impl Iterator<int> for MyStruct { fn next(&mut self) -> Option<int> { ... } } Closes #15392. [breaking-change]
2014-07-09libcore: Reexport a couple of widely-used low-level intrinsics to reducePatrick Walton-80/+4
code bloat. This didn't make a difference in any compile times that I saw, but it fits what we're doing with `transmute` and seems prudent.
2014-06-29Implement RFC#28: Add PartialOrd::partial_cmpSteven Fackler-1/+41
I ended up altering the semantics of Json's PartialOrd implementation. It used to be the case that Null < Null, but I can't think of any reason for an ordering other than the default one so I just switched it over to using the derived implementation. This also fixes broken `PartialOrd` implementations for `Vec` and `TreeMap`. RFC: 0028-partial-cmp
2014-06-29Extract tests from libcore to a separate crateSteven Fackler-267/+2
Libcore's test infrastructure is complicated by the fact that many lang items are defined in the crate. The current approach (realcore/realstd imports) is hacky and hard to work with (tests inside of core::cmp haven't been run for months!). Moving tests to a separate crate does mean that they can only test the public API of libcore, but I don't feel that that is too much of an issue. The only tests that I had to get rid of were some checking the various numeric formatters, but those are also exercised through normal format! calls in other tests.
2014-06-29c_str: replace .with_ref with .as_ptr throughout the codebase.Huon Wilson-12/+8
2014-06-28Rename all raw pointers as necessaryAlex Crichton-42/+46
2014-06-24librustc: Remove the fallback to `int` from typechecking.Niko Matsakis-4/+4
This breaks a fair amount of code. The typical patterns are: * `for _ in range(0, 10)`: change to `for _ in range(0u, 10)`; * `println!("{}", 3)`: change to `println!("{}", 3i)`; * `[1, 2, 3].len()`: change to `[1i, 2, 3].len()`. RFC #30. Closes #6023. [breaking-change]
2014-06-11rustc: Remove ~[T] from the languageAlex Crichton-19/+26
The following features have been removed * box [a, b, c] * ~[a, b, c] * box [a, ..N] * ~[a, ..N] * ~[T] (as a type) * deprecated_owned_vector lint All users of ~[T] should move to using Vec<T> instead.
2014-06-04core: Apply stability attributes to ptr modBrian Anderson-30/+60
* null and mut_null are unstable. Their names may change if the unsafe pointer types change. * copy_memory and copy_overlapping_memory are unstable. We think they aren't going to change. * set_memory and zero_memory are experimental. Both the names and the semantics are under question. * swap and replace are unstable and probably won't change. * read is unstable, probably won't change * read_and_zero is experimental. It's necessity is in doubt. * mem::overwrite is now called ptr::write to match read and is unstable. mem::overwrite is now deprecated * array_each, array_each_with_len, buf_len, and position are all deprecated because they use old style iteration and their utility is generally under question.
2014-06-01std: Drop Total from Total{Eq,Ord}Alex Crichton-3/+3
This completes the last stage of the renaming of the comparison hierarchy of traits. This change renames TotalEq to Eq and TotalOrd to Ord. In the future the new Eq/Ord will be filled out with their appropriate methods, but for now this change is purely a renaming change. [breaking-change]
2014-05-30std: Rename {Eq,Ord} to Partial{Eq,Ord}Alex Crichton-8/+8
This is part of the ongoing renaming of the equality traits. See #12517 for more details. All code using Eq/Ord will temporarily need to move to Partial{Eq,Ord} or the Total{Eq,Ord} traits. The Total traits will soon be renamed to {Eq,Ord}. cc #12517 [breaking-change]
2014-05-24auto merge of #14392 : alexcrichton/rust/mem-updates, r=sfacklerbors-3/+3
* All of the *_val functions have gone from #[unstable] to #[stable] * The overwrite and zeroed functions have gone from #[unstable] to #[stable] * The uninit function is now deprecated, replaced by its stable counterpart, uninitialized [breaking-change]
2014-05-23core: Finish stabilizing the `mem` module.Alex Crichton-3/+3
* All of the *_val functions have gone from #[unstable] to #[stable] * The overwrite and zeroed functions have gone from #[unstable] to #[stable] * The uninit function is now deprecated, replaced by its stable counterpart, uninitialized [breaking-change]
2014-05-23auto merge of #14359 : brson/rust/minordoc, r=alexcrichtonbors-11/+6
2014-05-23Minor library doc copyeditingBrian Anderson-11/+6
2014-05-22libcore: Remove all uses of `~str` from `libcore`.Patrick Walton-2/+3
[breaking-change]
2014-05-18Removed unnecessary transmuteAdolfo Ochagavía-2/+2
2014-05-15core: Update all tests for fmt movementAlex Crichton-7/+1
2014-05-11core: Remove the cast moduleAlex Crichton-20/+18
This commit revisits the `cast` module in libcore and libstd, and scrutinizes all functions inside of it. The result was to remove the `cast` module entirely, folding all functionality into the `mem` module. Specifically, this is the fate of each function in the `cast` module. * transmute - This function was moved to `mem`, but it is now marked as #[unstable]. This is due to planned changes to the `transmute` function and how it can be invoked (see the #[unstable] comment). For more information, see RFC 5 and #12898 * transmute_copy - This function was moved to `mem`, with clarification that is is not an error to invoke it with T/U that are different sizes, but rather that it is strongly discouraged. This function is now #[stable] * forget - This function was moved to `mem` and marked #[stable] * bump_box_refcount - This function was removed due to the deprecation of managed boxes as well as its questionable utility. * transmute_mut - This function was previously deprecated, and removed as part of this commit. * transmute_mut_unsafe - This function doesn't serve much of a purpose when it can be achieved with an `as` in safe code, so it was removed. * transmute_lifetime - This function was removed because it is likely a strong indication that code is incorrect in the first place. * transmute_mut_lifetime - This function was removed for the same reasons as `transmute_lifetime` * copy_lifetime - This function was moved to `mem`, but it is marked `#[unstable]` now due to the likelihood of being removed in the future if it is found to not be very useful. * copy_mut_lifetime - This function was also moved to `mem`, but had the same treatment as `copy_lifetime`. * copy_lifetime_vec - This function was removed because it is not used today, and its existence is not necessary with DST (copy_lifetime will suffice). In summary, the cast module was stripped down to these functions, and then the functions were moved to the `mem` module. transmute - #[unstable] transmute_copy - #[stable] forget - #[stable] copy_lifetime - #[unstable] copy_mut_lifetime - #[unstable] [breaking-change]
2014-05-07std: Small doc tweaksBrian Anderson-0/+2
2014-05-07core: Get coretest workingAlex Crichton-3/+3
This mostly involved frobbing imports between realstd, realcore, and the core being test. Some of the imports are a little counterintuitive, but it mainly focuses around libcore's types not implementing Show while libstd's types implement Show.
2014-05-07core: Inherit the ptr moduleAlex Crichton-0/+736
2013-05-22libstd: Rename libcore to libstd and libstd to libextra; update makefiles.Patrick Walton-561/+0
This only changes the directory names; it does not change the "real" metadata names.
2013-05-20auto merge of #6604 : bjz/rust/ptr-to-option, r=brsonbors-0/+51
2013-05-20Update to stop unsolicited copying and mark methods as unsafeBrendan Zabarauskas-11/+29
2013-05-19Use assert_eq! rather than assert! where possibleCorey Richardson-12/+12
2013-05-19Add Ptr::to_option methodBrendan Zabarauskas-0/+33
2013-05-15Rename vec::len(var) to var.len()Youngmin Yoo-1/+1
2013-05-14Use static string with fail!() and remove fail!(fmt!())Björn Steinbrink-2/+2
fail!() used to require owned strings but can handle static strings now. Also, it can pass its arguments to fmt!() on its own, no need for the caller to call fmt!() itself.
2013-05-13Remove re-exports from libcore/core.rcAlex Crichton-1/+1
Also fix up all the fallout elsewhere throughout core. It's really nice being able to have the prelude.
2013-05-08auto merge of #6327 : z0w0/rust/rm-notest, r=brsonbors-5/+5
Makes it more consistent, imo.
2013-05-08libcore: Remove mutable fields from os and ptrPatrick Walton-1/+4
2013-05-08Remove #[cfg(notest)] and use #[cfg(not(test))] to cooincide with #[cfg(debug)]Zack Corr-5/+5
2013-05-01correct incorrect handling of overloaded operators, exposing various other ↵Niko Matsakis-8/+8
bits of rot
2013-04-29librustc: Rename `reinterpret_cast` to `transmute_copy` and remove the intrinsicPatrick Walton-4/+4
2013-04-29librustc: Remove `ptr::addr_of`.Patrick Walton-11/+0
2013-04-20Replaced many instances of reinterpret_cast with transmuteMatthijs Hofstra-17/+17
2013-04-16libcore,std,syntax,rustc: move tests into `mod tests`, make them private (no ↵Huon Wilson-102/+100
pub mod or pub fn).
2013-04-14core: remove unnecessary unsafe blocks/functionsAlex Crichton-6/+2
2013-03-29Add AbiSet and integrate it into the AST.Niko Matsakis-1/+1
I believe this patch incorporates all expected syntax changes from extern function reform (#3678). You can now write things like: extern "<abi>" fn foo(s: S) -> T { ... } extern "<abi>" mod { ... } extern "<abi>" fn(S) -> T The ABI for foreign functions is taken from this syntax (rather than from an annotation). We support the full ABI specification I described on the mailing list. The correct ABI is chosen based on the target architecture. Calls by pointer to C functions are not yet supported, and the Rust type of crust fns is still *u8.
2013-03-29librustc: Remove `fail_unless!`Patrick Walton-26/+26
2013-03-28Removing unused importsAlex Crichton-1/+2
2013-03-26librustc: Modify all code to use new lifetime binder syntaxPatrick Walton-3/+3
2013-03-22libcore: Remove `pure` from libcore. rs=depurePatrick Walton-34/+34
2013-03-18librustc: Make the compiler ignore purity.Patrick Walton-6/+6
For bootstrapping purposes, this commit does not remove all uses of the keyword "pure" -- doing so would cause the compiler to no longer bootstrap due to some syntax extensions ("deriving" in particular). Instead, it makes the compiler ignore "pure". Post-snapshot, we can remove "pure" from the language. There are quite a few (~100) borrow check errors that were essentially all the result of mutable fields or partial borrows of `@mut`. Per discussions with Niko I think we want to allow partial borrows of `@mut` but detect obvious footguns. We should also improve the error message when `@mut` is erroneously reborrowed.
2013-03-18librustc: Convert all uses of old lifetime notation to new lifetime ↵Patrick Walton-9/+9
notation. rs=delifetiming