summary refs log tree commit diff
path: root/src/test/run-pass/operator-overloading.rs
AgeCommit message (Collapse)AuthorLines
2014-07-19librustc: Implement lifetime elision.Patrick Walton-1/+1
This implements RFC 39. Omitted lifetimes in return values will now be inferred to more useful defaults, and an error is reported if a lifetime in a return type is omitted and one of the two lifetime elision rules does not specify what it should be. This primarily breaks two uncommon code patterns. The first is this: unsafe fn get_foo_out_of_thin_air() -> &Foo { ... } This should be changed to: unsafe fn get_foo_out_of_thin_air() -> &'static Foo { ... } The second pattern that needs to be changed is this: enum MaybeBorrowed<'a> { Borrowed(&'a str), Owned(String), } fn foo() -> MaybeBorrowed { Owned(format!("hello world")) } Change code like this to: enum MaybeBorrowed<'a> { Borrowed(&'a str), Owned(String), } fn foo() -> MaybeBorrowed<'static> { Owned(format!("hello world")) } Closes #15552. [breaking-change]
2014-07-07librustc (RFC #34): Implement the new `Index` and `IndexMut` traits.Patrick Walton-2/+6
This will break code that used the old `Index` trait. Change this code to use the new `Index` traits. For reference, here are their signatures: pub trait Index<Index,Result> { fn index<'a>(&'a self, index: &Index) -> &'a Result; } pub trait IndexMut<Index,Result> { fn index_mut<'a>(&'a mut self, index: &Index) -> &'a mut Result; } Closes #6515. [breaking-change]
2014-05-30std: Rename {Eq,Ord} to Partial{Eq,Ord}Alex Crichton-1/+1
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-04-06Remove check-fast. Closes #4193, #8844, #6330, #7416Brian Anderson-1/+0
2014-02-28std: Change assert_eq!() to use {} instead of {:?}Alex Crichton-0/+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-11Change `xfail` directives in compiletests to `ignore`, closes #11363Florian Hahn-2/+2
2013-11-26librustc: Make `||` lambdas not infer to `proc`sPatrick Walton-1/+1
2013-11-18librustc: Convert `~fn()` to `proc()` everywhere.Patrick Walton-1/+1
2013-06-28librustc: Remove the broken overloaded assign-ops from the language.Patrick Walton-1/+1
They evaluated the receiver twice. They should be added back with `AddAssign`, `SubAssign`, etc., traits.
2013-05-29librustc: Stop reexporting the standard modules from prelude.Patrick Walton-0/+3
2013-05-19Use assert_eq! rather than assert! where possibleCorey Richardson-6/+6
2013-05-08test: Fix tests.Patrick Walton-1/+1
2013-03-29librustc: Remove `fail_unless!`Patrick Walton-6/+6
2013-03-27Autoref the argument to the index operator (#4920)Niko Matsakis-2/+2
2013-03-22test: Remove `pure` from the test suitePatrick Walton-7/+7
2013-03-07librustc: Convert all uses of `assert` over to `fail_unless!`Patrick Walton-6/+6
2013-03-02test: Remove `fn@`, `fn~`, and `fn&` from the test suite. rs=defunPatrick Walton-1/+2
2013-02-22Remove legacy_modes from test casesBrian Anderson-1/+0
2013-02-14librustc: Replace `impl Type : Trait` with `impl Trait for Type`. ↵Patrick Walton-6/+6
rs=implflipping
2013-02-01check-fast fallout from removing export, r=burningtreeGraydon Hoare-1/+1
2013-01-11test: add test for overloading logical negation operatorAndrew Paseltiner-0/+11
2012-12-10Reliciense makefiles and testsuite. Yup.Graydon Hoare-0/+10
2012-12-05test: More bustage fixes. rs=mePatrick Walton-1/+1
2012-12-05test: More run-pass test fixesPatrick Walton-1/+1
2012-11-26libcore: Add explicit self to all overloaded operators but Add and Index. ↵Patrick Walton-3/+3
r=brson
2012-11-19rustc: Implement explicit self for Eq and Ord. r=graydonPatrick Walton-3/+3
2012-09-25Demode dvecTim Chevalier-1/+1
2012-09-20rustc: De-mode all overloaded operatorsPatrick Walton-7/+7
2012-09-19xfail-fast the legacy_mode run-pass testsBrian Anderson-0/+1
2012-09-18rustc: Remove legacy mode inference, unless #[legacy_modes] is usedPatrick Walton-0/+2
2012-09-07Convert field terminators to commas. Stop parsing semis.Brian Anderson-2/+2
2012-09-07rustc: Add an "ne" method to the Eq trait, and implement it everywherePatrick Walton-0/+1
2012-09-02Camel case core::opsBrian Anderson-4/+4
2012-08-29rustc: Make `<` and `=` into traitsPatrick Walton-0/+6
2012-07-27rustc: Use coherence for operator overloading.Patrick Walton-20/+25
The only use of the old-style impls is now placement new.
2012-07-17rustc: Implement and enforce instance coherencePatrick Walton-1/+8
2012-03-22make --enforce-mut-vars always on, add mut annotations to remaining filesNiko Matsakis-1/+1
2012-02-02Add test case for issue #1733Marijn Haverbeke-0/+2
2012-01-30Alter/remove tests that include/concern ternaryPaul Woolcock-1/+1
3 tests, pretty/block-disambig.rs, run-pass/operator-overloading.rs, and run-pass/weird-exprs.rs, all included the ternary operator. These were changed to use the if-then-else construct instead. 2 tests, run-pass/block-arg-in-ternary.rs and run-pass/ternary.rs, were only there because of the ternary operator, and were removed.
2012-01-27Use the method name 'unary-' for overloading negationMarijn Haverbeke-1/+1
It's less likely to clash with something than 'neg'. Issue #1520
2012-01-26Use operator names for operator methodsMarijn Haverbeke-5/+9
The methods used to implement operators now simply use the name of the operator itself, except for unary -, which is called min to not clash with binary -. Index is called []. Closes #1520
2012-01-26Allow operator overloading of the indexing operatorMarijn Haverbeke-0/+5
The method `op_index` (which takes a single argument) is used for this. Issue #1520
2012-01-26First stab at operator overloadingMarijn Haverbeke-0/+17
When no built-in interpretation is found for one of the operators mentioned below, the typechecker will try to turn it into a method call with the name written next to it. For binary operators, the method will be called on the LHS with the RHS as only parameter. Binary: + op_add - op_sub * op_mul / op_div % op_rem & op_and | op_or ^ op_xor << op_shift_left >> op_shift_right >>> op_ashift_right Unary: - op_neg ! op_not Overloading of the indexing ([]) operator isn't finished yet. Issue #1520