about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2018-04-13std: Minimize size of panicking on wasmAlex Crichton-0/+27
This commit applies a few code size optimizations for the wasm target to the standard library, namely around panics. We notably know that in most configurations it's impossible for us to print anything in wasm32-unknown-unknown so we can skip larger portions of panicking that are otherwise simply informative. This allows us to get quite a nice size reduction. Finally we can also tweak where the allocation happens for the `Box<Any>` that we panic with. By only allocating once unwinding starts we can reduce the size of a panicking wasm module from 44k to 350 bytes.
2018-04-13Auto merge of #49669 - SimonSapin:global-alloc, r=alexcrichtonbors-47/+43
Add GlobalAlloc trait + tweaks for initial stabilization This is the outcome of discussion at the Rust All Hands in Berlin. The high-level goal is stabilizing sooner rather than later the ability to [change the global allocator](https://github.com/rust-lang/rust/issues/27389), as well as allocating memory without abusing `Vec::with_capacity` + `mem::forget`. Since we’re not ready to settle every detail of the `Alloc` trait for the purpose of collections that are generic over the allocator type (for example the possibility of a separate trait for deallocation only, and what that would look like exactly), we propose introducing separately **a new `GlobalAlloc` trait**, for use with the `#[global_allocator]` attribute. We also propose a number of changes to existing APIs. They are batched in this one PR in order to minimize disruption to Nightly users. The plan for initial stabilization is detailed in the tracking issue https://github.com/rust-lang/rust/issues/49668. CC @rust-lang/libs, @glandium ## Immediate breaking changes to unstable features * For pointers to allocated memory, change the pointed type from `u8` to `Opaque`, a new public [extern type](https://github.com/rust-lang/rust/issues/43467). Since extern types are not `Sized`, `<*mut _>::offset` cannot be used without first casting to another pointer type. (We hope that extern types can also be stabilized soon.) * In the `Alloc` trait, change these pointers to `ptr::NonNull` and change the `AllocErr` type to a zero-size struct. This makes return types `Result<ptr::NonNull<Opaque>, AllocErr>` be pointer-sized. * Instead of a new `Layout`, `realloc` takes only a new size (in addition to the pointer and old `Layout`). Changing the alignment is not supported with `realloc`. * Change the return type of `Layout::from_size_align` from `Option<Self>` to `Result<Self, LayoutErr>`, with `LayoutErr` a new opaque struct. * A `static` item registered as the global allocator with the `#[global_allocator]` **must now implement the new `GlobalAlloc` trait** instead of `Alloc`. ## Eventually-breaking changes to unstable features, with a deprecation period * Rename the respective `heap` modules to `alloc` in the `core`, `alloc`, and `std` crates. (Yes, this does mean that `::alloc::alloc::Alloc::alloc` is a valid path to a trait method if you have `exetrn crate alloc;`) * Rename the the `Heap` type to `Global`, since it is the entry point for what’s registered with `#[global_allocator]`. Old names remain available for now, as deprecated `pub use` reexports. ## Backward-compatible changes * Add a new [extern type](https://github.com/rust-lang/rust/issues/43467) `Opaque`, for use in pointers to allocated memory. * Add a new `GlobalAlloc` trait shown below. Unlike `Alloc`, it uses bare `*mut Opaque` without `NonNull` or `Result`. NULL in return values indicates an error (of unspecified nature). This is easier to implement on top of `malloc`-like APIs. * Add impls of `GlobalAlloc` for both the `Global` and `System` types, in addition to existing impls of `Alloc`. This enables calling `GlobalAlloc` methods on the stable channel before `Alloc` is stable. Implementing two traits with identical method names can make some calls ambiguous, but most code is expected to have no more than one of the two traits in scope. Erroneous code like `use std::alloc::Global; #[global_allocator] static A: Global = Global;` (where `Global` is defined to call itself, causing infinite recursion) is not statically prevented by the type system, but we count on it being hard enough to do accidentally and easy enough to diagnose. ```rust extern { pub type Opaque; } pub unsafe trait GlobalAlloc { unsafe fn alloc(&self, layout: Layout) -> *mut Opaque; unsafe fn dealloc(&self, ptr: *mut Opaque, layout: Layout); unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut Opaque { // Default impl: self.alloc() and ptr::write_bytes() } unsafe fn realloc(&self, ptr: *mut Opaque, old_layout: Layout, new_size: usize) -> *mut Opaque { // Default impl: self.alloc() and ptr::copy_nonoverlapping() and self.dealloc() } fn oom(&self) -> ! { // intrinsics::abort } // More methods with default impls may be added in the future } ``` ## Bikeshed The tracking issue https://github.com/rust-lang/rust/issues/49668 lists some open questions. If consensus is reached before this PR is merged, changes can be integrated.
2018-04-13Auto merge of #49718 - petrochenkov:fieldcmp, r=eddybbors-83/+478
Hygiene 2.0: Avoid comparing fields by name There are two separate commits here (not counting tests): - The first one unifies named (`obj.name`) and numeric (`obj.0`) field access expressions in AST and HIR. Before field references in these expressions are resolved it doesn't matter whether the field is named or numeric (it's just a symbol) and 99% of code is common. After field references are resolved we work with them by index for all fields (see the second commit), so it's again not important whether the field was named or numeric (this includes MIR where all fields were already by index). (This refactoring actually fixed some bugs in HIR-based borrow checker where borrows through names (`S { 0: ref x }`) and indices (`&s.0`) weren't considered overlapping.) - The second commit removes all by-name field comparison and instead resolves field references to their indices once, and then uses those resolutions. (There are still a few name comparisons in save-analysis, because save-analysis is weird, but they are made correctly hygienic). Thus we are fixing a bunch of "secondary" field hygiene bugs (in borrow checker, lints). Fixes https://github.com/rust-lang/rust/issues/46314
2018-04-12Rename alloc::Void to alloc::OpaqueSimon Sapin-10/+10
2018-04-12Use NonNull<Void> instead of *mut u8 in the Alloc traitMike Hommey-12/+13
Fixes #49608
2018-04-12Restore Global.oom() functionalitySimon Sapin-0/+1
… now that #[global_allocator] does not define a symbol for it
2018-04-12Remove the now-unit-struct AllocErr parameter of oom()Simon Sapin-5/+5
2018-04-12Use the GlobalAlloc trait for #[global_allocator]Simon Sapin-33/+27
2018-04-12Add some new tests + Fix failing testsVadim Petrochenkov-39/+208
2018-04-12Move hygiene tests to UIVadim Petrochenkov-0/+223
2018-04-12Avoid comparing fields by name when possibleVadim Petrochenkov-1/+1
Resolve them into field indices once and then use those resolutions + Fix rebase
2018-04-12AST/HIR: Merge field access expressions for named and numeric fieldsVadim Petrochenkov-43/+46
2018-04-12Implement inferring outlives requirements for references, structs, enum, ↵toidiu-1/+674
union, and projection types. added a feature gate and tests for these scenarios.
2018-04-12Auto merge of #49371 - scottmcm:catch-wrapping, r=nikomatsakisbors-22/+70
Add ok-wrapping to catch blocks, per RFC Updates the `catch{}` lowering to wrap the result in `Try::from_ok`. r? @nikomatsakis Fixes #41414 Fixes #43818
2018-04-12Auto merge of #48528 - bitshifter:repr_packed, r=eddybbors-85/+673
Implementation of `#[repr(packed(n))]` RFC 1399. Tracking issue https://github.com/rust-lang/rust/issues/33158.
2018-04-12Auto merge of #49698 - SimonSapin:unicode-for-everyone, r=alexcrichtonbors-7/+5
Merge the std_unicode crate into the core crate [The standard library facade](https://github.com/rust-lang/rust/issues/27783) has historically contained a number of crates with different roles, but that number has decreased over time. `rand` and `libc` have moved to crates.io, and [`collections` was merged into `alloc`](https://github.com/rust-lang/rust/pull/42648). Today we have `core` that applies everywhere, `std` that expects a full operating system, and `alloc` in-between that only requires a memory allocator (which can be provided by users)… and `std_unicode`, which doesn’t really have a reason to be separate anymore. It contains functionality based on Unicode data tables that can be large, but as long as relevant functions are not called the tables should be removed from binaries by linkers. This deprecates the unstable `std_unicode` crate and moves all of its contents into `core`, replacing them with `pub use` reexports. The crate can be removed later. This also removes the `CharExt` trait (replaced with inherent methods in libcore) and `UnicodeStr` trait (merged into `StrExt`). There traits were both unstable and not intended to be used or named directly. A number of new items are newly-available in libcore and instantly stable there, but only if they were already stable in libstd. Fixes #49319.
2018-04-12Dedicated tracking issue for UnicodeVersion and UNICODE_VERSION.Simon Sapin-3/+1
2018-04-12Move contents of libstd_unicode into libcoreSimon Sapin-4/+4
2018-04-11Auto merge of #49875 - kennytm:rollup, r=kennytmbors-8/+173
Rollup of 14 pull requests Successful merges: - #49525 (Use sort_by_cached_key where appropriate) - #49575 (Stabilize `Option::filter`.) - #49614 (in which the non-shorthand patterns lint keeps its own counsel in macros) - #49665 (Small nits to make couple of tests pass on mips targets.) - #49781 (add regression test for #16223 (NLL): use of collaterally moved value) - #49795 (Properly look for uninhabitedness of variants in niche-filling check) - #49809 (Stop emitting color codes on TERM=dumb) - #49856 (Do not uppercase-lint #[no_mangle] statics) - #49863 (fixed typo) - #49857 (Fix "fp" target feature for AArch64) - #49849 (Add --enable-debug flag to musl CI build script) - #49734 (proc_macro: Generalize `FromIterator` impl) - #49730 (Fix ICE with impl Trait) - #48270 (Replace `structurally_resolved_type` in casts check.) Failed merges:
2018-04-12Rollup merge of #48270 - leodasvacas:refactor-casts, r=nikomatsakiskennytm-0/+36
Replace `structurally_resolved_type` in casts check. The behaviour of `resolve_type_vars_if_possible` is simpler and infallible. Other minor refactorings. I'm not sure if this is backwards compatible, in theory resolving obligations between two cast checks could solve a dependency between them, but I don't know if that's actually possible and it doesn't sound like something we'd want to support.
2018-04-12Rollup merge of #49730 - sinkuu:fix_ice_49556, r=cramertjkennytm-0/+22
Fix ICE with impl Trait Fixes https://github.com/rust-lang/rust/issues/49556#issuecomment-379154713. May or may not fix 49556 itself. Closures like `|x: &'a _| x` has `ClosureSubsts` of `fn(&'a _) -> &'(ReScope) _`, so `tcx.note_and_explain_free_region` (called [here](https://github.com/rust-lang/rust/blob/a143462783cec88b7b733e8aa09990bfeb59f754/src/librustc/infer/anon_types/mod.rs#L572)) panics.
2018-04-12Rollup merge of #49856 - varkor:no_mangle-statics-unlinted, r=michaelwoeristerkennytm-0/+3
Do not uppercase-lint #[no_mangle] statics The reasoning being that `#[no_mangle]` expresses enough intention that there's likely a good reason for the name. Fixes #36258.
2018-04-11Auto merge of #49861 - pnkfelix:compare-mode-nll-followup-2, r=nikomatsakisbors-54/+3597
Blindly checkpoint status of NLL mode ui tests This takes the next (and potentially final?) step with #48879. Namely, this PR got things to the point where I can successfully run `compiletest` on `src/test/ui` with `--compile-mode=nll`. Here are the main pieces of it: 1. To figure out how to even run `compiletest` normally on the ui directory, I ran `x.py test -vv`, and then looked for the `compiletest` invocation that mentioned `src/test/ui`. 2. I took the aforementioned `compiletest` invocation and used it, adding `--compile-mode=nll` to the end. It had 170 failing cases. 3. Due to #49855, I had to edit some of the tests so that they fail even under NLL, via `#[rustc_error]`. That's the first commit. (Then goto 2 to double-check no such tests remain.) 4. I took the generated `build/target/test/foo.stderr` file for every case that failed, and blindly copied it to `src/test/foo.nll.stderr`. That's the second commit. 5. Goto 2 until there were no failing cases. 6. Remove any stamp files, and re-run `x.py test` to make sure that the edits and new `.nll.stderr` files haven't broken the pre-existing test suite.
2018-04-11Implementation of `#[repr(packed(n))]` RFC 1399.Cameron Hart-85/+673
2018-04-11Rollup merge of #49795 - nox:niche-with-uninhabited-fields, r=eddybkennytm-0/+7
Properly look for uninhabitedness of variants in niche-filling check
2018-04-11Rollup merge of #49781 - Robbepop:master, r=nikomatsakiskennytm-0/+63
add regression test for #16223 (NLL): use of collaterally moved value Adds regression test for https://github.com/rust-lang/rust/issues/16223 which NLL fixes. The current downside of this test is that it uses the `#![feature(box_patterns)]` and I haven't come up with a proper test that only uses the `#![feature(nll)]` - however, I don't know if this is even possible to test without `#![feature(box_syntax)]` or `#![feature(box_patterns)]`.
2018-04-11Rollup merge of #49665 - draganmladjenovic:mips_tests, r=nikomatsakiskennytm-8/+18
Small nits to make couple of tests pass on mips targets.
2018-04-11Rollup merge of #49614 - zackmdavis:the_phantom_menace, r=petrochenkovkennytm-0/+24
in which the non-shorthand patterns lint keeps its own counsel in macros In issue #49588, Michael Lamparski pointed out a scenario in which the non-shorthand-field-patterns lint could be triggered by a macro-expanded pattern, in a way which was direly unwieldy for the macro author to guard against and unreasonable to expect the macro user to take into account. We can avoid this by not linting patterns that come from macro-expansions. Although this entails accepting "false negatives" where the lint could genuinely improve macro-templated code, avoiding the reported "true-but-super-annoying positive" may be worth the trade? (Some precedent for these relative priorities exists as no. 47775 (5985b0b0).) Resolves #49588.
2018-04-10Tweak span for ok-wrapping in no-tail blockScott McMurray-8/+4
2018-04-10Add a UI test that the span for the catch type error is in the right placeScott McMurray-0/+51
2018-04-10Add ok-wrapping to catch blocks, per RFCScott McMurray-22/+23
2018-04-11Checkpoint the current status of NLL on `ui` tests via compare-mode=nll.Felix S. Klock II-0/+3543
2018-04-11Workaround rust-lang/rust#49855 by forcing rustc_error in any mode, ↵Felix S. Klock II-54/+54
including NLL. NOTE: I was careful to make each change in a manner that preserves the existing diagnostic output (usually by ensuring that no lines were added or removed). This means that the resulting source files are not as nice to read as they were at the start. But we will have to review these cases by hand anyway as follow-up work, so cleanup could reasonably happen then (or not at all).
2018-04-10Do not uppercase-lint no_mangle staticsvarkor-0/+3
2018-04-10Auto merge of #48914 - gaurikholkar:e0389, r=nikomatsakisbors-1/+32
Modify compile-fail/E0389 error message WIP This fixes #47388 cc @nikomatsakis @estebank r? @nikomatsakis Certain ui tests were failing locally. I'll check if the same happens here too.
2018-04-10Add ignores for powerpc and s390x to target-feature-wrong.rs and update ↵dragan.mladjenovic-7/+9
references.
2018-04-10Update ui test references.dragan.mladjenovic-7/+7
2018-04-10Small nits to make couple of tests pass on mips targets.dragan.mladjenovic-0/+8
2018-04-10Auto merge of #49504 - GuillaumeGomez:doc-all-types, r=QuietMisdreavusbors-0/+30
Add page to list all crate's items r? @QuietMisdreavus
2018-04-10Auto merge of #49258 - zackmdavis:not_going_to_recover, r=petrochenkovbors-0/+94
suggest `!` for erroneous identifier `not` ![not_recovery](https://user-images.githubusercontent.com/1076988/37753255-3b669c42-2d59-11e8-9071-efad8eaf3086.png) This supersedes #48858. r? @petrochenkov
2018-04-10Auto merge of #49435 - tmandry:rule-implied-bound-from-trait, r=nikomatsakisbors-1/+147
chalkify: Implement lowering rule Implied-Bound-From-Trait For #49177. TODO: - [x] Implement where clauses besides trait and projection predicates - [x] Is the output of the `lower_trait_higher_rank` test correct? - [ ] Remove `Self::Trait` from the query `tcx.predicates_of(<trait_id>).predicates` - [ ] Consider moving tests to compile-fail to make them more manageable
2018-04-09add regression test for issue #16223: fixed by NLLHero-0/+63
2018-04-09in which the non-shorthand patterns lint keeps its own counsel in macrosZack M. Davis-0/+24
In issue #49588, Michael Lamparski pointed out a scenario in which the non-shorthand-field-patterns lint could be triggered by a macro-expanded pattern, in a way which was direly unwieldy for the macro author to guard against and unreasonable to expect the macro user to take into account. We can avoid this by not linting patterns that come from macro-expansions. Although this entails accepting "false negatives" where the lint could genuinely improve macro-templated code, avoiding the reported "true-but-super-annoying positive" may be worth the trade? (Some precedent for these relative priorities exists as no. 47775 (5985b0b0).) Resolves #49588.
2018-04-09in which `!` is suggested for erroneous identifier `not`Zack M. Davis-0/+94
Impressing confused Python users with magical diagnostics is perhaps worth this not-grossly-unreasonable (only 40ish lines) extra complexity in the parser? Thanks to Vadim Petrochenkov for guidance. This resolves #46836.
2018-04-09Properly look for uninhabitedness of variants in niche-filling checkAnthony Ramine-0/+7
2018-04-08Auto merge of #49752 - sinkuu:fix_incrcmp_str_lit, r=oli-obkbors-0/+64
[incremental] Hash `Allocation`s `HashSet::insert` returns `true` if the value did not exist, which is the timing we want to hash the `Allocation`. Fixes #49595 cc @oli-obk
2018-04-08Auto merge of #49714 - nikomatsakis:issue-49631, r=eddybbors-0/+82
mem-categorization, coherence fix make mem-categorization use adjusted type for patterns: Fixes #49631 do not propagate `Err` when determing causal info: Fixes #48728 r? @eddyb
2018-04-08Auto merge of #49704 - leodasvacas:fix-#49344, r=nikomatsakisbors-0/+4
Fix regression in defaults #49344 Fixes #49344 by not checking the well-formedness wrt defaults of predicates that contain lifetimes, which is consistent with not checking generic predicates. r? @nikomatsakis
2018-04-07Auto merge of #49678 - bobtwinkles:fix_multiple_activations, r=nikomatsakisbors-0/+84
two-phase borrows: support multiple activations in one statement The need for this has arisen since the introduction of two-phase borrows on method autorefs in #49348. r'ing @pnkfelix to keep things off Niko's plate so he can make this redundant, and @pnkfelix is familiar with the code. Fixes #49635 Fixes #49662 r? @pnkfelix
2018-04-07Auto merge of #49672 - alexcrichton:fix-another-std-core-cycle, ↵bors-0/+1
r=michaelwoerister Fix another circular deps link args issue It turns out that the support in #49316 wasn't enough to handle all cases notably the example in #48661. The underlying bug was connected to panic=abort where lang items were listed in the `missing_lang_items` sets but didn't actually exist anywhere. This caused the linker backend to deduce that start-group/end-group wasn't needed because not all items were defined. Instead the missing lang items that don't actually need to have a definition are filtered out and not considered for the start-group/end-group arguments Closes #48661