Commit Graph

36957 Commits

Author SHA1 Message Date
Niko Matsakis
47424cda1e Normalize bounds that we extract from where clauses. Fixes #20765. 2015-01-12 09:23:50 -05:00
Niko Matsakis
487a4a174a Fix various oversights in enum field treatment in trans and typeck.
Fixes #20996.
2015-01-12 07:51:35 -05:00
bors
a6408fa1d8 auto merge of #20942 : nagisa/rust/shrl-impls, r=nikomatsakis
This is only relevant to the code that uses generics such as

    fn magic<T: Shl>(a: T) { a << 10u8; }

r? @nikomatsakis
2015-01-12 11:05:30 +00:00
bors
b21a6da340 auto merge of #19870 : mdinger/rust/align_error, r=nick29581
#### Updated 1/12/2014

I updated the multi-line testcase to current but didn't modify the others. The spew code was broke by the `matches!` macro no longer working and I'm not interested in fixing the testcase.

I additionally added one testcase below.

Errors will in general look similar to below if the error is either `mismatched types` or a few other types. The rest are ignored.

---

#### Extra testcase:
```rust
pub trait Foo {
    type A;
    fn boo(&self) -> <Self as Foo>::A;
}

struct Bar;

impl Foo for i32 {
    type A = u32;
    fn boo(&self) -> u32 {
        42
    }
}

fn foo1<I: Foo<A=Bar>>(x: I) {
    let _: Bar = x.boo();
}

fn foo2<I: Foo>(x: I) {
    let _: Bar = x.boo();
}


pub fn baz(x: &Foo<A=Bar>) {
    let _: Bar = x.boo();
}


pub fn main() {
    let a = 42i32;
    foo1(a);
    baz(&a);
}
```

#### Multi-line output:
```cmd
$ ./rustc test3.rs
test3.rs:20:18: 20:25 error: mismatched types:
 expected `Bar`,
    found `<I as Foo>::A`
(expected struct `Bar`,
    found associated type)
test3.rs:20     let _: Bar = x.boo();
                             ^~~~~~~
test3.rs:31:5: 31:9 error: type mismatch resolving `<i32 as Foo>::A == Bar`:
 expected u32,
    found struct `Bar`
test3.rs:31     foo1(a);
                ^~~~
test3.rs:31:5: 31:9 note: required by `foo1`
test3.rs:31     foo1(a);
                ^~~~
test3.rs:32:9: 32:11 error: type mismatch resolving `<i32 as Foo>::A == Bar`:
 expected u32,
    found struct `Bar`
test3.rs:32     baz(&a);
                    ^~
test3.rs:32:9: 32:11 note: required for the cast to the object type `Foo`
test3.rs:32     baz(&a);
                    ^~
error: aborting due to 3 previous errors
```

---

This is a continuation of #19203 which I apparently broke by force pushing after it was closed. I'm attempting to add multi-line errors where they are largely beneficial - to help differentiate different types in compiler messages. As before, this is still a simple fix.

#### Testcase:
```rust
struct S;

fn test() -> Option<i32> {
    let s: S;

    s
}

fn test2() -> Option<i32> {
    Ok(7) // Should be Some(7)
}

impl Iterator for S {
    type Item = i32;
    fn next(&mut self) -> Result<i32, i32> { Ok(7) }
}

fn main(){ 
    test();
    test2();

}
```

---

#### Single-line playpen errors:
```cmd
<anon>:6:5: 6:6 error: mismatched types: expected `core::option::Option<int>`, found `S` (expected enum core::option::Option, found struct S)
<anon>:6     s
             ^
<anon>:10:5: 10:10 error: mismatched types: expected `core::option::Option<int>`, found `core::result::Result<_, _>` (expected enum core::option::Option, found enum core::result::Result)
<anon>:10     Ok(7) // Should be Some(7)
              ^~~~~
<anon>:14:5: 14:55 error: method `next` has an incompatible type for trait: expected enum core::option::Option, found enum core::result::Result [E0053]
<anon>:14     fn next(&mut self) -> Result<uint, uint> { Ok(7) }
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to 3 previous errors
playpen: application terminated with error code 101
```

---

#### Multi-line errors:
```cmd
$ ./rustc test.rs
test.rs:6:5: 6:6 error: mismatched types:
 expected `core::option::Option<i32>`,
    found `S`
(expected enum `core::option::Option`,
    found struct `S`)
test.rs:6     s
              ^
test.rs:10:5: 10:10 error: mismatched types:
 expected `core::option::Option<i32>`,
    found `core::result::Result<_, _>`
(expected enum `core::option::Option`,
    found enum `core::result::Result`)
test.rs:10     Ok(7) // Should be Some(7)
               ^~~~~
test.rs:15:5: 15:53 error: method `next` has an incompatible type for trait: expected enum `core::option::Option`, found enum `core::result::Result` [E0053]
test.rs:15     fn next(&mut self) -> Result<i32, i32> { Ok(7) }
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to 3 previous errors
```

---

#### Positive notes
* Vim worked fine with it: https://github.com/rust-lang/rust/pull/19203#issuecomment-66861668
* `make check` didn't find any errors
* Fixed *backtick* placement suggested by @p1start at https://github.com/rust-lang/rust/pull/19203#issuecomment-64062052

#### Negative notes
* Didn't check Emacs support but also wasn't provided a testcase...
* Needs to be tested with macro errors but I don't have a good testcase yet
* I would like to move the `E[0053]` earlier (see https://github.com/rust-lang/rust/issues/19464#issuecomment-65334301) but I don't know how
* It might be better to indent the types slightly like so (but I don't know how):
```cmd
test.rs:6:5: 6:6 error: mismatched types:
          expected `core::option::Option<int>`,
             found `S`
         (expected enum `core::option::Option`,
             found struct `S`)
test.rs:6     s
```
* Deep whitespace indentation may be a bad idea because early wrapping will cause misalignment between lines

#### Other
* I thought that compiler flags or something else (environment variables maybe) might be required because of comments against it but now that seems too much of a burden for users and for too little gain.
* There was concern that it will make large quantities of errors difficult to distinguish but I don't find that an issue. They both look awful and multi-line errors makes the types easier to understand.

---

#### Single lined spew:
```cmd
$ rustc test2.rs 
test2.rs:161:9: 170:10 error: method `next` has an incompatible type for trait: expected enum core::option::Option, found enum core::result::Result [E0053]
test2.rs:161         fn next(&mut self) -> Result<&'a str, int> {
test2.rs:162             self.curr = self.next;
test2.rs:163             
test2.rs:164             if let (Some(open), Some(close)) = Parens::find_parens(self.all, self.next) {
test2.rs:165                 self.next = if self.all.char_at(self.next) == '(' { close }
test2.rs:166                 else { open }
             ...
test2.rs:164:21: 164:31 error: mismatched types: expected `core::result::Result<uint, int>`, found `core::option::Option<_>` (expected enum core::result::Result, found enum core::option::Option)
test2.rs:164             if let (Some(open), Some(close)) = Parens::find_parens(self.all, self.next) {
                                 ^~~~~~~~~~
test2.rs:164:33: 164:44 error: mismatched types: expected `core::result::Result<uint, int>`, found `core::option::Option<_>` (expected enum core::result::Result, found enum core::option::Option)
test2.rs:164             if let (Some(open), Some(close)) = Parens::find_parens(self.all, self.next) {
                                             ^~~~~~~~~~~
test2.rs:169:40: 169:76 error: mismatched types: expected `core::result::Result<&'a str, int>`, found `core::option::Option<&str>` (expected enum core::result::Result, found enum core::option::Option)
test2.rs:169             if self.curr != self.len { Some(self.all[self.curr..self.next]) } else { None }
                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test2.rs:169:86: 169:90 error: mismatched types: expected `core::result::Result<&'a str, int>`, found `core::option::Option<_>` (expected enum core::result::Result, found enum core::option::Option)
test2.rs:169             if self.curr != self.len { Some(self.all[self.curr..self.next]) } else { None }
                                                                                                  ^~~~
test2.rs:205:14: 205:18 error: mismatched types: expected `core::result::Result<uint, int>`, found `core::option::Option<uint>` (expected enum core::result::Result, found enum core::option::Option)
test2.rs:205             (open, close)
                          ^~~~
test2.rs:205:20: 205:25 error: mismatched types: expected `core::result::Result<uint, int>`, found `core::option::Option<uint>` (expected enum core::result::Result, found enum core::option::Option)
test2.rs:205             (open, close)
                                ^~~~~
test2.rs:210:21: 210:31 error: mismatched types: expected `core::result::Result<uint, int>`, found `core::option::Option<_>` (expected enum core::result::Result, found enum core::option::Option)
test2.rs:210             if let (Some(open), _) = Parens::find_parens(self.all, 0) {
                                 ^~~~~~~~~~
test2.rs:210:13: 212:28 error: mismatched types: expected `core::option::Option<&'a int>`, found `core::option::Option<&str>` (expected int, found str)
test2.rs:210             if let (Some(open), _) = Parens::find_parens(self.all, 0) {
test2.rs:211                 Some(self.all[0..open])
test2.rs:212             } else { None }
test2.rs:299:48: 299:58 error: mismatched types: expected `Box<translate::Entity>`, found `collections::vec::Vec<_>` (expected box, found struct collections::vec::Vec)
test2.rs:299         pub fn new() -> Entity { Entity::Group(Vec::new()) }
                                                            ^~~~~~~~~~
test2.rs:359:51: 359:58 error: type `&mut Box<translate::Entity>` does not implement any method in scope named `push`
test2.rs:359                 Entity::Group(ref mut vec) => vec.push(e),
                                                               ^~~~~~~
test2.rs:366:51: 366:85 error: type `&mut Box<translate::Entity>` does not implement any method in scope named `push`
test2.rs:366                 Entity::Group(ref mut vec) => vec.push(Entity::Inner(s.to_string())),
                                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to 12 previous errors
```

---

#### Multi-line spew:

```cmd
$ ./rustc test2.rs 
test2.rs:161:9: 170:10 error: method `next` has an incompatible type for trait:
 expected enum `core::option::Option`,
    found enum `core::result::Result` [E0053]
test2.rs:161         fn next(&mut self) -> Result<&'a str, int> {
test2.rs:162             self.curr = self.next;
test2.rs:163             
test2.rs:164             if let (Some(open), Some(close)) = Parens::find_parens(self.all, self.next) {
test2.rs:165                 self.next = if self.all.char_at(self.next) == '(' { close }
test2.rs:166                 else { open }
             ...
test2.rs:164:21: 164:31 error: mismatched types:
 expected `core::result::Result<uint, int>`,
    found `core::option::Option<_>`
(expected enum `core::result::Result`,
    found enum `core::option::Option`)
test2.rs:164             if let (Some(open), Some(close)) = Parens::find_parens(self.all, self.next) {
                                 ^~~~~~~~~~
test2.rs:164:33: 164:44 error: mismatched types:
 expected `core::result::Result<uint, int>`,
    found `core::option::Option<_>`
(expected enum `core::result::Result`,
    found enum `core::option::Option`)
test2.rs:164             if let (Some(open), Some(close)) = Parens::find_parens(self.all, self.next) {
                                             ^~~~~~~~~~~
test2.rs:169:40: 169:76 error: mismatched types:
 expected `core::result::Result<&'a str, int>`,
    found `core::option::Option<&str>`
(expected enum `core::result::Result`,
    found enum `core::option::Option`)
test2.rs:169             if self.curr != self.len { Some(self.all[self.curr..self.next]) } else { None }
                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test2.rs:169:86: 169:90 error: mismatched types:
 expected `core::result::Result<&'a str, int>`,
    found `core::option::Option<_>`
(expected enum `core::result::Result`,
    found enum `core::option::Option`)
test2.rs:169             if self.curr != self.len { Some(self.all[self.curr..self.next]) } else { None }
                                                                                                  ^~~~
test2.rs:205:14: 205:18 error: mismatched types:
 expected `core::result::Result<uint, int>`,
    found `core::option::Option<uint>`
(expected enum `core::result::Result`,
    found enum `core::option::Option`)
test2.rs:205             (open, close)
                          ^~~~
test2.rs:205:20: 205:25 error: mismatched types:
 expected `core::result::Result<uint, int>`,
    found `core::option::Option<uint>`
(expected enum `core::result::Result`,
    found enum `core::option::Option`)
test2.rs:205             (open, close)
                                ^~~~~
test2.rs:210:21: 210:31 error: mismatched types:
 expected `core::result::Result<uint, int>`,
    found `core::option::Option<_>`
(expected enum `core::result::Result`,
    found enum `core::option::Option`)
test2.rs:210             if let (Some(open), _) = Parens::find_parens(self.all, 0) {
                                 ^~~~~~~~~~
test2.rs:210:13: 212:28 error: mismatched types:
 expected `core::option::Option<&'a int>`,
    found `core::option::Option<&str>`
(expected int,
    found str)
test2.rs:210             if let (Some(open), _) = Parens::find_parens(self.all, 0) {
test2.rs:211                 Some(self.all[0..open])
test2.rs:212             } else { None }
test2.rs:229:57: 229:96 error: the trait `core::ops::Fn<(char,), bool>` is not implemented for the type `|char| -> bool`
test2.rs:229                                              .map(|s| s.trim_chars(|c: char| c.is_whitespace()))
                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test2.rs:238:46: 239:75 error: type `core::str::CharSplits<'_, |char| -> bool>` does not implement any method in scope named `filter_map`
test2.rs:238                                             .filter_map(|s| if !s.is_empty() { Some(s.trim_chars('\'')) }
test2.rs:239                                                             else { None })
test2.rs:237:46: 237:91 error: the trait `core::ops::Fn<(char,), bool>` is not implemented for the type `|char| -> bool`
test2.rs:237                 let vec: Vec<&str> = value[].split(|c: char| matches!(c, '(' | ')' | ','))
                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test2.rs:238:65: 238:77 error: the type of this value must be known in this context
test2.rs:238                                             .filter_map(|s| if !s.is_empty() { Some(s.trim_chars('\'')) }
                                                                             ^~~~~~~~~~~~
test2.rs:299:48: 299:58 error: mismatched types:
 expected `Box<translate::Entity>`,
    found `collections::vec::Vec<_>`
(expected box,
    found struct `collections::vec::Vec`)
test2.rs:299         pub fn new() -> Entity { Entity::Group(Vec::new()) }
                                                            ^~~~~~~~~~
test2.rs:321:36: 322:65 error: type `core::str::CharSplits<'_, |char| -> bool>` does not implement any method in scope named `filter_map`
test2.rs:321                                   .filter_map(|s| if !s.is_empty() { Some(s.trim_chars('\'')) }
test2.rs:322                                                   else { None })
test2.rs:320:36: 320:81 error: the trait `core::ops::Fn<(char,), bool>` is not implemented for the type `|char| -> bool`
test2.rs:320             let vec: Vec<&str> = s.split(|c: char| matches!(c, '(' | ')' | ','))
                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test2.rs:321:55: 321:67 error: the type of this value must be known in this context
test2.rs:321                                   .filter_map(|s| if !s.is_empty() { Some(s.trim_chars('\'')) }
                                                                   ^~~~~~~~~~~~
test2.rs:359:51: 359:58 error: type `&mut Box<translate::Entity>` does not implement any method in scope named `push`
test2.rs:359                 Entity::Group(ref mut vec) => vec.push(e),
                                                               ^~~~~~~
test2.rs:366:51: 366:85 error: type `&mut Box<translate::Entity>` does not implement any method in scope named `push`
test2.rs:366                 Entity::Group(ref mut vec) => vec.push(Entity::Inner(s.to_string())),
                                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to 24 previous errors
```

Closes #18946 #19464
cc @P1start @jakub- @tomjakubowski @kballard @chris-morgan
2015-01-12 08:55:22 +00:00
Valerii Hiora
11737a3e1d iOS: fixed install phase
It was broken as tried to copy dylibs which are actually never been
built for iOS
2015-01-12 10:09:47 +02:00
bors
486f60df87 auto merge of #20917 : nick29581/rust/plugins, r=huonw 2015-01-12 06:50:21 +00:00
mdinger
7b82a93be3 Fix testsuite errors 2015-01-12 01:34:13 -05:00
mdinger
5616b92e4d Implement multi-line errors 2015-01-12 01:34:12 -05:00
mdinger
24ace1665a Backtick nits 2015-01-12 01:34:12 -05:00
Erick Tryzelaar
f7745a9be3 rustc_trans: Fix type projection debuginfo
Closes #20797
2015-01-11 21:39:03 -08:00
Richo Healey
043a4b32d1 powerpc: Fix extraneous include in rt support 2015-01-11 21:15:19 -08:00
Richo Healey
734093674e powerpc: Fix missing include in cabi_powerpc 2015-01-11 21:15:19 -08:00
Richo Healey
7776820a03 powerpc: definition support for libc 2015-01-11 21:15:06 -08:00
Richo Healey
8341ee4075 powerpc: rough platform support 2015-01-11 21:14:58 -08:00
Richo Healey
7a05dc273d powerpc: pthread support 2015-01-11 21:14:58 -08:00
Richo Healey
e9908da0d7 powerpc: Fixup more stack work 2015-01-11 21:14:58 -08:00
Richo Healey
d48fa78694 powerpc: add cdefs for linux
This borrowed entirely from the mips definitions, and should be
revisited after it lands while testing.
2015-01-11 21:14:31 -08:00
Richo Healey
164981042d powerpc: Janky segmented stack support 2015-01-11 21:14:31 -08:00
Richo Healey
f0d6eee499 powerpc: Add unwinder size REVISIT 2015-01-11 21:14:31 -08:00
Richo Healey
a2e3993111 powerpc: Add libstd utils 2015-01-11 21:14:31 -08:00
Richo Healey
c055d99526 powerpc: Teach trans about powerpc 2015-01-11 21:14:31 -08:00
Richo Healey
33cd9cf9f4 powerpc: initialize llvm 2015-01-11 21:14:31 -08:00
Richo Healey
c8442afeb0 powerpc: Add backend support for powerpc 2015-01-11 21:14:30 -08:00
Richo Healey
e5bbe8244b powerpc: Tell liballoc about power alignment 2015-01-11 21:14:30 -08:00
Richo Healey
194ed4f5a0 powerpc: Document the existance of powerpc 2015-01-11 21:14:30 -08:00
Richo Healey
0e0af8ea88 powerpc: Use toolchain assembler on power 2015-01-11 21:14:30 -08:00
Richo Healey
a36a8924b4 powerpc: Build llvm for powerpc 2015-01-11 21:14:30 -08:00
Richo Healey
f512dce713 powerpc: Add platform configuration 2015-01-11 21:14:30 -08:00
Richo Healey
31d232e204 powerpc: Add support to configure 2015-01-11 21:14:23 -08:00
bors
0aec4db1c0 auto merge of #20889 : Manishearth/rust/trait-error, r=nikomatsakis
fixes #20783

r? @nikomatsakis
2015-01-12 04:45:18 +00:00
Joseph Crail
415fc5f0f1 Remove unused import. 2015-01-11 23:08:26 -05:00
bors
15a41380c1 auto merge of #20897 : barosl/rust/no-type-for-node-ice, r=nick29581
If the type of a node cannot be determined due to a previous type error, a `no type for node` ICE occurs. This commit makes it return `ty_err` instead in such a case.

Fixes #20401.
Fixes #20506.
Fixes #20614.
Fixes #20752.
Fixes #20829.
Fixes #20846.
Fixes #20885.
Fixes #20886.
Fixes #20952.
Fixes #20970.
2015-01-12 02:40:20 +00:00
CarVac
9302dc5d9e Replace uint with u32 in trpl/guessing-game.md
uint was recently deprecated, so in following the use of i32 at first,
replace all references to uint with u32.

Also change literals from e.g. 100u to 100, so that they are no longer
usize.
2015-01-11 21:00:42 -05:00
bors
4bed1e8c0a Merge pull request #20968 from estsauver/20762
Fix sentence fragment in librustc README

Reviewed-by: alexcrichton
2015-01-12 00:21:32 +00:00
bors
8d88ac12c1 Merge pull request #20966 from Valloric/ownership-fix
Fixing integer usage in ownership doc

Reviewed-by: steveklabnik
2015-01-12 00:21:31 +00:00
bors
8c824c5b65 Merge pull request #20956 from angst7/docfixes1
replace deprecated uint references with u32 in trpl/looping.md

Reviewed-by: Gankro
2015-01-12 00:21:31 +00:00
bors
53ea263e37 Merge pull request #20934 from tomjakubowski/patch-1
Escape a leading # in a doc comment

Reviewed-by: eddyb
2015-01-12 00:21:30 +00:00
bors
352c81bb4b Merge pull request #20933 from gifnksm/patch-1
TRPL: `cargo build` doesn't run executables

Reviewed-by: alexcrichton
2015-01-12 00:21:30 +00:00
bors
f72c719b71 Merge pull request #20930 from charmeleon/master
Switching out range(0,10) example to 0..10. Tests fine

Reviewed-by: brson
2015-01-12 00:21:29 +00:00
bors
268e2bff97 Merge pull request #20926 from xnil/patch-1
Hepburn romanization of さようなら

Reviewed-by: huonw
2015-01-12 00:21:29 +00:00
bors
1f1e18972e Merge pull request #20920 from piyo/issue-20853
Give mmap a page-aligned stack start address

Reviewed-by: Aatch
2015-01-12 00:21:28 +00:00
bors
a1a34a35b2 Merge pull request #20915 from csouth3/hash-iters
Add ExactSizeIterator impls for Hash{Map, Set, Table}

Reviewed-by: Gankro
2015-01-12 00:21:28 +00:00
bors
79602e24c8 Merge pull request #20905 from akiss77/pr-morestack-plt
Fix: GNU AArch64 assembler does not like @plt symbol suffix

Reviewed-by: alexcrichton
2015-01-12 00:21:27 +00:00
bors
a9679c643b Merge pull request #20903 from XMPPwocky/deadlink1
Fix dead link in documentation (s/task/thread/)

Reviewed-by: Aatch
2015-01-12 00:21:27 +00:00
bors
668325190d Merge pull request #20902 from stevencrockett/master
reference: Small grammar fixes for correctness/consistency and updates for language changes.

Reviewed-by: steveklabnik
2015-01-12 00:21:26 +00:00
bors
67736510ae Merge pull request #20899 from TeXitoi/fix-shootout-threadring
fix shootout-threadring.rs

Reviewed-by: alexcrichton
2015-01-12 00:21:25 +00:00
bors
10305fcfdc Merge pull request #20898 from sebras/trpl
Cosmetic updates to TRPL text

Reviewed-by: steveklabnik
2015-01-12 00:21:25 +00:00
bors
50b0f5c550 Merge pull request #20895 from adregan/master
Updates fixed-size suffix in 30 minute introduction

Reviewed-by: steveklabnik
2015-01-12 00:21:25 +00:00
bors
654877c75f Merge pull request #20883 from apreiml/master
Update 7.2.9 Array expressions

Reviewed-by: steveklabnik
2015-01-12 00:21:24 +00:00
bors
d71a68ae23 Merge pull request #20881 from brookst/master
Add new number literal suffixes to Vim syntax highlighting

Reviewed-by: alexcrichton
2015-01-12 00:21:24 +00:00