about summary refs log tree commit diff
path: root/src/libcoretest/ptr.rs
AgeCommit message (Collapse)AuthorLines
2015-08-09Replace many uses of `mem::transmute` with more specific functionsTobias Bucher-2/+1
The replacements are functions that usually use a single `mem::transmute` in their body and restrict input and output via more concrete types than `T` and `U`. Worth noting are the `transmute` functions for slices and the `from_utf8*` family for mutable slices. Additionally, `mem::transmute` was often used for casting raw pointers, when you can already cast raw pointers just fine with `as`.
2015-07-09Use vec![elt; n] where possibleUlrik Sverdrup-3/+2
The common pattern `iter::repeat(elt).take(n).collect::<Vec<_>>()` is exactly equivalent to `vec![elt; n]`, do this replacement in the whole tree. (Actually, vec![] is smart enough to only call clone n - 1 times, while the former solution would call clone n times, and this fact is virtually irrelevant in practice.)
2015-03-30std: Standardize (input, output) param orderingsAlex Crichton-6/+3
This functions swaps the order of arguments to a few functions that previously took (output, input) parameters, but now take (input, output) parameters (in that order). The affected functions are: * ptr::copy * ptr::copy_nonoverlapping * slice::bytes::copy_memory * intrinsics::copy * intrinsics::copy_nonoverlapping Closes #22890 [breaking-change]
2015-03-26Mass rename uint/int to usize/isizeAlex Crichton-14/+14
Now that support has been removed, all lingering use cases are renamed.
2015-03-25Add trivial cast lints.Nick Cameron-7/+7
This permits all coercions to be performed in casts, but adds lints to warn in those cases. Part of this patch moves cast checking to a later stage of type checking. We acquire obligations to check casts as part of type checking where we previously checked them. Once we have type checked a function or module, then we check any cast obligations which have been acquired. That means we have more type information available to check casts (this was crucial to making coercions work properly in place of some casts), but it means that casts cannot feed input into type inference. [breaking change] * Adds two new lints for trivial casts and trivial numeric casts, these are warn by default, but can cause errors if you build with warnings as errors. Previously, trivial numeric casts and casts to trait objects were allowed. * The unused casts lint has gone. * Interactions between casting and type inference have changed in subtle ways. Two ways this might manifest are: - You may need to 'direct' casts more with extra type information, for example, in some cases where `foo as _ as T` succeeded, you may now need to specify the type for `_` - Casts do not influence inference of integer types. E.g., the following used to type check: ``` let x = 42; let y = &x as *const u32; ``` Because the cast would inform inference that `x` must have type `u32`. This no longer applies and the compiler will fallback to `i32` for `x` and thus there will be a type error in the cast. The solution is to add more type information: ``` let x: u32 = 42; let y = &x as *const u32; ```
2015-03-21std: Remove deprecated ptr functionsAlex Crichton-7/+7
The method with which backwards compatibility was retained ended up leading to documentation that rustdoc didn't handle well and largely ended up confusing.
2015-03-05Remove integer suffixes where the types in compiled code are identical.Eduard Burtescu-3/+3
2015-02-24Use arrays instead of vectors in testsVadim Petrochenkov-1/+1
2015-02-18Rewrite `Unique<T>` so that it is covariant in T, implies `NonZero` and ↵Niko Matsakis-2/+2
ownership, and also follows the API of `NonZero` a bit more closely. More to do here I think (including perhaps a new name).
2015-02-12Auto merge of #21895 - alfie:libcoretest, r=pnkfelixbors-1/+1
2015-02-11Add core::marker::PhantomData.Felix S. Klock II-1/+1
Port `core::ptr::Unique` to have `PhantomData`. Add `PhantomData` to `TypedArena` and `Vec` as well. As a drive-by, switch `ptr::Unique` from a tuple-struct to a struct with fields.
2015-02-10Deprecating i/u suffixes in libcoretestAlfie John-1/+1
2015-02-10Made the `ptr::Unique` type accept unsized types, to allow for use casesMarvin Löbel-0/+9
like sending a raw pointer slice across thread boundaries.
2015-01-30Remove all `i` suffixesTobias Bucher-4/+4
2015-01-03Remove deprecated functionalityAlex Crichton-6/+3
This removes a large array of deprecated functionality, regardless of how recently it was deprecated. The purpose of this commit is to clean out the standard libraries and compiler for the upcoming alpha release. Some notable compiler changes were to enable warnings for all now-deprecated command line arguments (previously the deprecated versions were silently accepted) as well as removing deriving(Zero) entirely (the trait was removed). The distribution no longer contains the libtime or libregex_macros crates. Both of these have been deprecated for some time and are available externally.
2015-01-02Fallout - change array syntax to use `;`Nick Cameron-2/+2
2014-10-19Remove a large amount of deprecated functionalityAlex Crichton-119/+13
Spring cleaning is here! In the Fall! This commit removes quite a large amount of deprecated functionality from the standard libraries. I tried to ensure that only old deprecated functionality was removed. This is removing lots and lots of deprecated features, so this is a breaking change. Please consult the deprecation messages of the deleted code to see how to migrate code forward if it still needs migration. [breaking-change]
2014-08-31Rename `RawPtr::to_option()` to `RawPtr::as_ref()`Andrew Poelstra-5/+30
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-07-24Deprecated `str::raw::from_c_str`Adolfo Ochagavía-9/+7
Use `string::raw::from_buf` instead [breaking-change]
2014-06-29Extract tests from libcore to a separate crateSteven Fackler-0/+255
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.