about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2015-03-27Rollup merge of #23712 - nikomatsakis:reflect-trait, r=FlaPer87Manish Goregaokar-7/+153
This PR introduces a `Reflect` marker trait which is a supertrait of `Any`. The idea is that `Reflect` is defined for all concrete types, but is not defined for type parameters unless there is a `T:Reflect` bound. This is intended to preserve the parametricity property. This allows the `Any` interface to be stabilized without committing us to unbounded reflection that is not easily detectable by the caller. The implementation of `Reflect` relies on an experimental variant of OIBIT. This variant behaves differently for objects, since it requires that all types exposed as part of the object's *interface* are `Reflect`, but isn't concerned about other types that may be closed over. In other words, you don't have to write `Foo+Reflect` in order for `Foo: Reflect` to hold (where `Foo` is a trait). Given that `Any` is slated to stabilization and hence that we are committed to some form of reflection, the goal of this PR is to leave our options open with respect to parametricity. I see the options for full stabilization as follows (I think an RFC would be an appropriate way to confirm whichever of these three routes we take): 1. We make `Reflect` a lang-item. 2. We stabilize some version of the OIBIT variation I implemented as a general mechanism that may be appropriate for other use cases. 3. We give up on preserving parametricity here and just have `impl<T> Reflect for T` instead. In that case, `Reflect` is a harmless but not especially useful trait going forward. cc @aturon cc @alexcrichton cc @glaebhoerl (this is more-or-less your proposal, as I understood it) cc @reem (this is more-or-less what we discussed on IRC at some point) cc @FlaPer87 (vaguely pertains to OIBIT)
2015-03-27Rollup merge of #23625 - fhahn:issue-23620-ice-unicode-bytestring, ↵Manish Goregaokar-1/+49
r=alexcrichton closes #23620 This PR patches the issue mentioned in #23620, but there is also an ICE for invalid escape sequences in byte literals. This is due to the fact that the `scan_byte` function returns ` token::intern(\"??\") ` for invalid bytes, resulting in an ICE later on. Is there a reason for this behavior? Shouldn't `scan_byte` fail when it encounters an invalid byte? And I noticed a small inconsistency in the documentation. According to the formal byte literal definition in http://doc.rust-lang.org/reference.html#byte-and-byte-string-literals , a byte string literal contains `string_body *`, but according to the text (and the behavior of the lexer) it should not accept unicode escape sequences. Hence it should be replaced by `byte_body *`. If this is valid, I can add this fix to this PR.
2015-03-27Prevent ICEs when parsing invalid escapes, closes #23620Florian Hahn-1/+49
2015-03-26Drive-by fix for incorrect variance rule that I noticed.Niko Matsakis-0/+25
2015-03-26Implement `Reflect` trait with a variant on the standard OIBITNiko Matsakis-7/+128
semantics that tests the *interface* of trait objects, rather than what they close over.
2015-03-26Register new snapshotsAlex Crichton-13/+0
2015-03-26Auto merge of #21237 - erickt:derive-assoc-types, r=ericktbors-0/+240
This PR adds support for associated types to the `#[derive(...)]` syntax extension. In order to do this, it switches over to using where predicates to apply the type constraints. So now this: ```rust type Trait { type Type; } #[derive(Clone)] struct Foo<A> where A: Trait { a: A, b: <A as Trait>::Type, } ``` Gets expended into this impl: ```rust impl<A: Clone> Clone for Foo<A> where A: Trait, <A as Trait>::Type: Clone, { fn clone(&self) -> Foo<T> { Foo { a: self.a.clone(), b: self.b.clone(), } } } ```
2015-03-26Auto merge of #23718 - alexcrichton:flaky-test, r=huonwbors-4/+4
It's considered an error to access stdout while a process is being shut down, so tweak this test a bit to actually wait for the child thread to exit. This was discovered with a recent [snap-mac3 failure](http://buildbot.rust-lang.org/builders/snap3-mac/builds/164/steps/test/logs/stdio)
2015-03-25test: Make a test less flakyAlex Crichton-4/+4
It's considered an error to access stdout while a process is being shut down, so tweak this test a bit to actually wait for the child thread to exit.
2015-03-25Auto merge of #23695 - sae-bom:mac-android-debuginfo, r=alexcrichtonbors-1/+4
1. when mac-android cross compile and make-check , make it use gdb instead of lldb so as to it passes debuginfo tests. 2. ignore some tests on aarch64
2015-03-25Rollup merge of #23702 - dotdash:match_reass, r=eddybManish Goregaokar-0/+30
The reassignment checker effectively only checks whether the last assignment in a body affects the discriminant, but it should of course check all the assignments. Fixes #23698
2015-03-25Rollup merge of #23692 - yjh0502:fix/simd-overflow, r=pnkfelixManish Goregaokar-0/+19
Disable overflow checking on SIMD operations, fix #23037
2015-03-25Always properly copy values into bindings when mutating the match discriminantBjörn Steinbrink-0/+30
The reassignment checker effectively only checks whether the last assignment in a body affects the discriminant, but it should of course check all the assignments. Fixes #23698
2015-03-25Ignore some tests on aarch64Sae-bom Kim-1/+4
2015-03-25Fix ICE on SIMD overflow checkingJihyun Yu-0/+19
Disable overflow checking on SIMD operations, fix #23037
2015-03-24rollup merge of #23638: pnkfelix/fsk-reject-specialized-dropsAlex Crichton-6/+85
Reject specialized Drop impls. See Issue #8142 for discussion. This makes it illegal for a Drop impl to be more specialized than the original item. So for example, all of the following are now rejected (when they would have been blindly accepted before): ```rust struct S<A> { ... }; impl Drop for S<i8> { ... } // error: specialized to concrete type struct T<'a> { ... }; impl Drop for T<'static> { ... } // error: specialized to concrete region struct U<A> { ... }; impl<A:Clone> Drop for U<A> { ... } // error: added extra type requirement struct V<'a,'b>; impl<'a,'b:a> Drop for V<'a,'b> { ... } // error: added extra region requirement ``` Due to examples like the above, this is a [breaking-change]. (The fix is to either remove the specialization from the `Drop` impl, or to transcribe the requirements into the struct/enum definition; examples of both are shown in the PR's fixed to `libstd`.) ---- This is likely to be the last thing blocking the removal of the `#[unsafe_destructor]` attribute. Fix #8142 Fix #23584
2015-03-24rollup merge of #23546: alexcrichton/hyphensAlex Crichton-103/+91
The compiler will now issue a warning for crates that have syntax of the form `extern crate "foo" as bar`, but it will still continue to accept this syntax. Additionally, the string `foo-bar` will match the crate name `foo_bar` to assist in the transition period as well. This patch will land hopefully in tandem with a Cargo patch that will start translating all crate names to have underscores instead of hyphens. cc #23533
2015-03-24rustc: Add support for `extern crate foo as bar`Alex Crichton-103/+91
The compiler will now issue a warning for crates that have syntax of the form `extern crate "foo" as bar`, but it will still continue to accept this syntax. Additionally, the string `foo-bar` will match the crate name `foo_bar` to assist in the transition period as well. This patch will land hopefully in tandem with a Cargo patch that will start translating all crate names to have underscores instead of hyphens. cc #23533
2015-03-24rollup merge of #23630: nrc/coerce-tidyAlex Crichton-143/+215
See notes on the first commit Closes #18601 r? @nikomatsakis cc @eddyb
2015-03-24rollup merge of #23282: nikomatsakis/fn-trait-inheritanceAlex Crichton-57/+208
The primary motivation here is to sidestep #19032 -- for a time, I thought that we should improve coherence or otherwise extend the language, but I now think that any such changes will require more time to bake. In the meantime, inheritance amongst the fn traits is both logically correct *and* a simple solution to that obstacle. This change introduces inheritance and modifies the compiler so that it can properly generate impls for closures and fns. Things enabled by this PR (but not included in this PR): 1. An impl of `FnMut` for `&mut F` where `F : FnMut` (https://github.com/rust-lang/rust/issues/23015). 2. A better version of `Thunk` I've been calling `FnBox`. I did not include either of these in the PR because: 1. Adding the impls in 1 currently induces a coherence conflict with the pattern trait. This is interesting and merits some discussion. 2. `FnBox` deserves to be a PR of its own. The main downside to this design is (a) the need to write impls by hand; (b) the possibility of implementing `FnMut` with different semantics from `Fn`, etc. Point (a) is minor -- in particular, it does not affect normal closure usage -- and could be addressed in the future in many ways (better defaults; convenient macros; specialization; etc). Point (b) is unfortunate but "just a bug" from my POV, and certainly not unique to these traits (c.f. Copy/Clone, PartialEq/Eq, etc). (Until we lift the feature-gate on implementing the Fn traits, in any case, there is room to correct both of these if we find a nice way.) Note that I believe this change is reversible in the future if we decide on another course of action, due to the feature gate on implementing the `Fn` traits, though I do not (currently) think we should reverse it. Fixes #18835. r? @nrc
2015-03-24syntax: Update #[derive(...)] to work with phantom and associated typesErick Tryzelaar-0/+239
Closes #7671, #19839
2015-03-24Unit tests for Issue 8142, collected into one file.Felix S. Klock II-0/+79
2015-03-24Reject specialized Drop impls.Felix S. Klock II-6/+6
See Issue 8142 for discussion. This makes it illegal for a Drop impl to be more specialized than the original item. So for example, all of the following are now rejected (when they would have been blindly accepted before): ```rust struct S<A> { ... }; impl Drop for S<i8> { ... } // error: specialized to concrete type struct T<'a> { ... }; impl Drop for T<'static> { ... } // error: specialized to concrete region struct U<A> { ... }; impl<A:Clone> Drop for U<A> { ... } // error: added extra type requirement struct V<'a,'b>; impl<'a,'b:a> Drop for V<'a,'b> { ... } // error: added extra region requirement ``` Due to examples like the above, this is a [breaking-change]. (The fix is to either remove the specialization from the `Drop` impl, or to transcribe the requirements into the struct/enum definition; examples of both are shown in the PR's fixed to `libstd`.) ---- This is likely to be the last thing blocking the removal of the `#[unsafe_destructor]` attribute. Includes two new error codes for the new dropck check. Update run-pass tests to accommodate new dropck pass. Update tests and docs to reflect new destructor restriction. ---- Implementation notes: We identify Drop impl specialization by not being as parametric as the struct/enum definition via unification. More specifically: 1. Attempt unification of a skolemized instance of the struct/enum with an instance of the Drop impl's type expression where all of the impl's generics (i.e. the free variables of the type expression) have been replaced with unification variables. 2. If unification fails, then reject Drop impl as specialized. 3. If unification succeeds, check if any of the skolemized variables "leaked" into the constraint set for the inference context; if so, then reject Drop impl as specialized. 4. Otherwise, unification succeeded without leaking skolemized variables: accept the Drop impl. We identify whether a Drop impl is injecting new predicates by simply looking whether the predicate, after an appropriate substitution, appears on the struct/enum definition.
2015-03-24test: silence a warningErick Tryzelaar-0/+1
2015-03-25Change lint names to pluralsNick Cameron-5/+5
2015-03-25Add testsNick Cameron-0/+165
2015-03-25Add trivial cast lints.Nick Cameron-143/+50
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-24Test fixes and rebase conflicts, round 4Alex Crichton-2/+0
2015-03-23Test fixes and rebase conflicts, round 3Alex Crichton-1/+2
2015-03-23Test fixes and rebase conflicts, round 2Alex Crichton-10/+15
2015-03-23Fallout from changing fn traits to use inheritance rather than bridgeNiko Matsakis-57/+208
impls. This is a [breaking-change] (for gated code) in that when you implement `Fn` (`FnMut`) you must also implement `FnOnce`. This commit demonstrates how to fix it.
2015-03-23Auto merge of #23536 - pnkfelix:arith-oflo-shifts, r=nikomatsakisbors-1/+283
overflow-checking for rhs of shift operators Subtask of #22020 ([RFC 560](https://github.com/rust-lang/rfcs/blob/master/text/0560-integer-overflow.md))
2015-03-23rollup merge of #23506: alexcrichton/remove-some-deprecated-thingsAlex Crichton-84/+0
Conflicts: src/test/run-pass/deprecated-no-split-stack.rs
2015-03-23rollup merge of #23503: alexcrichton/fix-ptr-docsAlex Crichton-3/+3
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-23rollup merge of #23383: alexcrichton/fs-create-dir-allAlex Crichton-0/+18
Conflicts: src/libstd/fs/mod.rs
2015-03-23rollup merge of #23598: brson/gateAlex Crichton-248/+3763
Conflicts: src/compiletest/compiletest.rs src/libcollections/lib.rs src/librustc_back/lib.rs src/libserialize/lib.rs src/libstd/lib.rs src/libtest/lib.rs src/test/run-make/rustdoc-default-impl/foo.rs src/test/run-pass/env-home-dir.rs
2015-03-23rollup merge of #23601: nikomatsakis/by-value-indexAlex Crichton-68/+154
This is a [breaking-change]. When indexing a generic map (hashmap, etc) using the `[]` operator, it is now necessary to borrow explicitly, so change `map[key]` to `map[&key]` (consistent with the `get` routine). However, indexing of string-valued maps with constant strings can now be written `map["abc"]`. r? @japaric cc @aturon @Gankro
2015-03-23rollup merge of #23580: nikomatsakis/pattern-and-overflowAlex Crichton-11/+1
2015-03-23rollup merge of #23538: aturon/conversionAlex Crichton-4/+6
Conflicts: src/librustc_back/rpath.rs
2015-03-23rollup merge of #23536: pnkfelix/arith-oflo-shiftsAlex Crichton-1/+283
overflow-checking for rhs of shift operators Subtask of #22020 ([RFC 560](https://github.com/rust-lang/rfcs/blob/master/text/0560-integer-overflow.md))
2015-03-23rollup merge of #23515: nikomatsakis/issue-14985-trait-subtypingAlex Crichton-0/+35
Remove incorrect subtyping for `&mut Trait` and introduce coercion for `&mut (Trait+'a)` to `&mut (Trait+'b)` if `'a:'b`. Fixes #14985. r? @nrc
2015-03-23rollup merge of #23211: FlaPer87/oibit-send-and-friendsAlex Crichton-0/+12
Fixes #23225 r? @nikomatsakis
2015-03-23rollup merge of #23119: nikomatsakis/issue-23116-ref-mutAlex Crichton-0/+49
Don't allow upcasting to a supertype in the type of the match discriminant. Fixes #23116. This is a [breaking-change] in that it closes a type hole that previously existed. r? @pnkfelix
2015-03-23Refactor how we handle overflow so that it is a fatal error that abortsNiko Matsakis-11/+1
compilation: this removes all the ungainly code that special cases overflow so that we can ensure it propagates.
2015-03-23Add generic conversion traitsAaron Turon-4/+6
This commit: * Introduces `std::convert`, providing an implementation of RFC 529. * Deprecates the `AsPath`, `AsOsStr`, and `IntoBytes` traits, all in favor of the corresponding generic conversion traits. Consequently, various IO APIs now take `AsRef<Path>` rather than `AsPath`, and so on. Since the types provided by `std` implement both traits, this should cause relatively little breakage. * Deprecates many `from_foo` constructors in favor of `from`. * Changes `PathBuf::new` to take no argument (creating an empty buffer, as per convention). The previous behavior is now available as `PathBuf::from`. * De-stabilizes `IntoCow`. It's not clear whether we need this separate trait. Closes #22751 Closes #14433 [breaking-change]
2015-03-23rustdoc: Replace no-pretty-expanded with pretty-expandedBrian Anderson-2/+3082
Now that features must be declared expanded source often does not compile. This adds 'pretty-expanded' to a bunch of test cases that still work.
2015-03-23Add #![feature] attributes to doctestsBrian Anderson-1/+1
2015-03-23Require feature attributes, and add them where necessaryBrian Anderson-246/+683
2015-03-23Update borrowck tests to test that index is by-move nowNiko Matsakis-8/+82
2015-03-23Fallout in stdlib, rustdoc, rustc, etc. For most maps, converted uses ofNiko Matsakis-60/+72
`[]` on maps to `get` in rustc, since stage0 and stage1+ disagree about how to use `[]`.