about summary refs log tree commit diff
path: root/src/libstd/ptr.rs
AgeCommit message (Collapse)AuthorLines
2014-05-07core: Inherit the ptr moduleAlex Crichton-772/+0
2014-05-06librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, exceptPatrick Walton-7/+7
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box<Type>`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change]
2014-05-02Replace most ~exprs with 'box'. #11779Brian Anderson-9/+9
2014-05-01Fix a/an typosJorge Aparicio-1/+1
2014-04-21Fix misspellings in comments.Joseph Crail-1/+1
2014-04-18std: Make ~[T] no longer a growable vectorAlex Crichton-3/+2
This removes all resizability support for ~[T] vectors in preparation of DST. The only growable vector remaining is Vec<T>. In summary, the following methods from ~[T] and various functions were removed. Each method/function has an equivalent on the Vec type in std::vec unless otherwise stated. * slice::OwnedCloneableVector * slice::OwnedEqVector * slice::append * slice::append_one * slice::build (no replacement) * slice::bytes::push_bytes * slice::from_elem * slice::from_fn * slice::with_capacity * ~[T].capacity() * ~[T].clear() * ~[T].dedup() * ~[T].extend() * ~[T].grow() * ~[T].grow_fn() * ~[T].grow_set() * ~[T].insert() * ~[T].pop() * ~[T].push() * ~[T].push_all() * ~[T].push_all_move() * ~[T].remove() * ~[T].reserve() * ~[T].reserve_additional() * ~[T].reserve_exect() * ~[T].retain() * ~[T].set_len() * ~[T].shift() * ~[T].shrink_to_fit() * ~[T].swap_remove() * ~[T].truncate() * ~[T].unshift() * ~str.clear() * ~str.set_len() * ~str.truncate() Note that no other API changes were made. Existing apis that took or returned ~[T] continue to do so. [breaking-change]
2014-04-08std: Add more docs for ptr modBrian Anderson-53/+182
2014-03-23use TotalEq for HashMapDaniel Micay-1/+7
Closes #5283
2014-03-20rename std::vec -> std::sliceDaniel Micay-1/+1
Closes #12702
2014-03-15log: Introduce liblog, the old std::loggingAlex Crichton-3/+0
This commit moves all logging out of the standard library into an external crate. This crate is the new crate which is responsible for all logging macros and logging implementation. A few reasons for this change are: * The crate map has always been a bit of a code smell among rust programs. It has difficulty being loaded on almost all platforms, and it's used almost exclusively for logging and only logging. Removing the crate map is one of the end goals of this movement. * The compiler has a fair bit of special support for logging. It has the __log_level() expression as well as generating a global word per module specifying the log level. This is unfairly favoring the built-in logging system, and is much better done purely in libraries instead of the compiler itself. * Initialization of logging is much easier to do if there is no reliance on a magical crate map being available to set module log levels. * If the logging library can be written outside of the standard library, there's no reason that it shouldn't be. It's likely that we're not going to build the highest quality logging library of all time, so third-party libraries should be able to provide just as high-quality logging systems as the default one provided in the rust distribution. With a migration such as this, the change does not come for free. There are some subtle changes in the behavior of liblog vs the previous logging macros: * The core change of this migration is that there is no longer a physical log-level per module. This concept is still emulated (it is quite useful), but there is now only a global log level, not a local one. This global log level is a reflection of the maximum of all log levels specified. The previously generated logging code looked like: if specified_level <= __module_log_level() { println!(...) } The newly generated code looks like: if specified_level <= ::log::LOG_LEVEL { if ::log::module_enabled(module_path!()) { println!(...) } } Notably, the first layer of checking is still intended to be "super fast" in that it's just a load of a global word and a compare. The second layer of checking is executed to determine if the current module does indeed have logging turned on. This means that if any module has a debug log level turned on, all modules with debug log levels get a little bit slower (they all do more expensive dynamic checks to determine if they're turned on or not). Semantically, this migration brings no change in this respect, but runtime-wise, this will have a perf impact on some code. * A `RUST_LOG=::help` directive will no longer print out a list of all modules that can be logged. This is because the crate map will no longer specify the log levels of all modules, so the list of modules is not known. Additionally, warnings can no longer be provided if a malformed logging directive was supplied. The new "hello world" for logging looks like: #[phase(syntax, link)] extern crate log; fn main() { debug!("Hello, world!"); }
2014-02-28std: Change assert_eq!() to use {} instead of {:?}Alex Crichton-1/+1
Formatting via reflection has been a little questionable for some time now, and it's a little unfortunate that one of the standard macros will silently use reflection when you weren't expecting it. This adds small bits of code bloat to libraries, as well as not always being necessary. In light of this information, this commit switches assert_eq!() to using {} in the error message instead of {:?}. In updating existing code, there were a few error cases that I encountered: * It's impossible to define Show for [T, ..N]. I think DST will alleviate this because we can define Show for [T]. * A few types here and there just needed a #[deriving(Show)] * Type parameters needed a Show bound, I often moved this to `assert!(a == b)` * `Path` doesn't implement `Show`, so assert_eq!() cannot be used on two paths. I don't think this is much of a regression though because {:?} on paths looks awful (it's a byte array). Concretely speaking, this shaved 10K off a 656K binary. Not a lot, but sometime significant for smaller binaries.
2014-02-23std: Move intrinsics to std::intrinsics.Brian Anderson-1/+1
Issue #1457
2014-02-20ptr::RawPtr, spell out units used for the `offset` argument.Felix S. Klock II-1/+2
spell out units used for the `offset` argument, so that callers do not try to scale to byte units themselves.
2014-02-15std: clean up ptr a bitCorey Richardson-74/+36
2014-02-13remove duplicate function from std::ptr (is_null, is_not_null, offset, ↵JeremyLetang-34/+9
mut_offset)
2014-02-11Move replace and swap to std::mem. Get rid of std::utilEdward Wang-2/+1
Also move Void to std::any, move drop to std::mem and reexport in prelude.
2014-02-09std: Stop parameterizing some memcpy functions over RawPtrBrian Anderson-9/+9
It unsafe assumptions that any impl of RawPtr is for actual pointers, that they can be copied by memcpy. Removing it is easy, so I don't think it's solving a real problem.
2014-02-09std: Add init and uninit to mem. Replace direct intrinsic usageBrian Anderson-2/+3
2014-01-21Remove unnecessary parentheses.Huon Wilson-2/+2
2013-12-20std: silence warnings when compiling test.Huon Wilson-2/+0
2013-12-19std::vec: remove .as_imm_buf, replaced by .as_ptr & .len.Huon Wilson-36/+32
There's no need for the restrictions of a closure with the above methods.
2013-12-16Spell out the units used for the `offset` argument, so that people doFelix S. Klock II-1/+5
not try to scale to units of bytes themselves.
2013-12-15std::vec: convert to(_mut)_ptr to as_... methods on &[] and &mut [].Huon Wilson-14/+12
2013-11-26test: Remove non-procedure uses of `do` from compiletest, libstd tests,Patrick Walton-22/+22
compile-fail tests, run-fail tests, and run-pass tests.
2013-11-21`std::ptr::read_ptr` now takes `*T` instead of `*mut T`Ziad Hatahet-2/+2
Closes #10579
2013-11-19libstd: Change all uses of `&fn(A)->B` over to `|A|->B` in libstdPatrick Walton-3/+3
2013-11-06Register new snapshotsAlex Crichton-83/+0
2013-11-03simplify memcpy/memmove/memset intrinsicsDaniel Micay-6/+42
This moves the per-architecture difference into the compiler.
2013-10-25Implement Clone trait for mutable unsafe pointersSeo Sanghyeon-0/+7
2013-10-22Drop the '2' suffix from logging macrosAlex Crichton-7/+7
Who doesn't like a massive renaming?
2013-09-30std: Remove usage of fmt!Alex Crichton-10/+9
2013-09-18Register new snapshotsAlex Crichton-83/+4
2013-09-12implement raw pointer comparisons in librustcDaniel Micay-4/+64
This is mostly for consistency, as you can now compare raw pointers in constant expressions or without the standard library. It also reduces the number of `ptrtoint` instructions in the IR, making tracking down culprits of what's usually an anti-pattern easier.
2013-09-09rename `std::iterator` to `std::iter`Daniel Micay-1/+1
The trait will keep the `Iterator` naming, but a more concise module name makes using the free functions less verbose. The module will define iterables in addition to iterators, as it deals with iteration in general.
2013-08-30fix various warningsErick Tryzelaar-0/+1
2013-08-27Remove offset_inbounds for an unsafe offset functionAlex Crichton-76/+22
2013-08-27librustc: Remove `&const` and `*const` from the language.Patrick Walton-32/+114
They are still present as part of the borrow check.
2013-08-22auto merge of #8596 : vadimcn/rust/master, r=alexcrichtonbors-2/+0
This resolves issue #908. Notable changes: - On Windows, LLVM integrated assembler emits bad stack unwind tables when segmented stacks are enabled. However, unwind info directives in the assembly output are correct, so we generate assembly first and then run it through an external assembler, just like it is already done for Android builds. - Linker is invoked via "g++" command instead of "gcc": g++ passes the appropriate magic parameters to the linker, which ensure correct registration of stack unwind tables in dynamic libraries.
2013-08-22Enabled unit tests in std and extra.Vadim Chugunov-2/+0
2013-08-21Adjust callbacks in the libraries for the new type of extern fnsNiko Matsakis-0/+41
cc #3678
2013-08-18auto merge of #8551 : huonw/rust/speling, r=alexcrichtonbors-1/+1
(This doesn't add/remove `u`s or change `ize` to `ise`, or anything like that.)
2013-08-17Fix warnings in testsErick Tryzelaar-1/+1
2013-08-16auto merge of #8532 : kballard/rust/cstr-cleanup, r=ericktbors-4/+4
Implement interior null checking in `.to_c_str()`, among other changes.
2013-08-16doc: correct spelling in documentation.Huon Wilson-1/+1
2013-08-15ptr: inline the Clone implementationDaniel Micay-0/+1
2013-08-15Add ToCStr method .with_c_str()Kevin Ballard-4/+4
.with_c_str() is a replacement for the old .as_c_str(), to avoid unnecessary boilerplate. Replace all usages of .to_c_str().with_ref() with .with_c_str().
2013-08-12Forbid pub/priv where it has no effectAlex Crichton-4/+4
Closes #5495
2013-08-12fix build with the new snapshot compilerDaniel Micay-22/+0
2013-08-07Merge remote-tracking branch 'remotes/origin/master' into ↵Erick Tryzelaar-0/+41
remove-str-trailing-nulls
2013-08-06vec: use `offset_inbounds` for iteratorsDaniel Micay-1/+20
This allows LLVM to optimize vector iterators to an `getelementptr` and `icmp` pair, instead of `getelementptr` and *two* comparisons. Code snippet: ~~~ fn foo(xs: &mut [f64]) { for x in xs.mut_iter() { *x += 10.0; } } ~~~ LLVM IR at stage0: ~~~ ; Function Attrs: noinline uwtable define void @"_ZN3foo17_68e1b25bca131dba7_0$x2e0E"({ i64, %tydesc*, i8*, i8*, i8 }* nocapture, { double*, i64 }* nocapture) #1 { "function top level": %2 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 0 %3 = load double** %2, align 8 %4 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 1 %5 = load i64* %4, align 8 %6 = ptrtoint double* %3 to i64 %7 = and i64 %5, -8 %8 = add i64 %7, %6 %9 = inttoptr i64 %8 to double* %10 = icmp eq double* %3, %9 %11 = icmp eq double* %3, null %or.cond6 = or i1 %10, %11 br i1 %or.cond6, label %match_case, label %match_else match_else: ; preds = %"function top level", %match_else %12 = phi double* [ %13, %match_else ], [ %3, %"function top level" ] %13 = getelementptr double* %12, i64 1 %14 = load double* %12, align 8 %15 = fadd double %14, 1.000000e+01 store double %15, double* %12, align 8 %16 = icmp eq double* %13, %9 %17 = icmp eq double* %13, null %or.cond = or i1 %16, %17 br i1 %or.cond, label %match_case, label %match_else match_case: ; preds = %match_else, %"function top level" ret void } ~~~ Optimized LLVM IR at stage1/stage2: ~~~ ; Function Attrs: noinline uwtable define void @"_ZN3foo17_68e1b25bca131dba7_0$x2e0E"({ i64, %tydesc*, i8*, i8*, i8 }* nocapture, { double*, i64 }* nocapture) #1 { "function top level": %2 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 0 %3 = load double** %2, align 8 %4 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 1 %5 = load i64* %4, align 8 %6 = lshr i64 %5, 3 %7 = getelementptr inbounds double* %3, i64 %6 %8 = icmp eq i64 %6, 0 %9 = icmp eq double* %3, null %or.cond6 = or i1 %8, %9 br i1 %or.cond6, label %match_case, label %match_else match_else: ; preds = %"function top level", %match_else %.sroa.0.0.in7 = phi double* [ %10, %match_else ], [ %3, %"function top level" ] %10 = getelementptr inbounds double* %.sroa.0.0.in7, i64 1 %11 = load double* %.sroa.0.0.in7, align 8 %12 = fadd double %11, 1.000000e+01 store double %12, double* %.sroa.0.0.in7, align 8 %13 = icmp eq double* %10, %7 br i1 %13, label %match_case, label %match_else match_case: ; preds = %match_else, %"function top level" ret void } ~~~