Commit Graph

49280 Commits

Author SHA1 Message Date
bors
0672ed4e82 Auto merge of #30800 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #30766, #30771, #30789
- Failed merges:
2016-01-11 17:15:27 +00:00
bors
d01ed8ad8e Auto merge of #30676 - nikomatsakis:issue-29857, r=arielb1
This is an alternative to https://github.com/rust-lang/rust/pull/29954 for fixing #29857 that seems to me to be more inline with the general strategy around `TyError`. It also includes the fix for #30589 -- in fact, just the minimal change of making `ty_is_local` tolerate `TyError` avoids the ICE, but you get a lot of duplicate error reports, so in the case where the impl's trait reference already includes `TyError`, we just ignore the impl altogether.

cc @arielb1 @sanxiyn

Fixes #29857.
Fixes #30589.
2016-01-11 15:26:57 +00:00
bors
5cf69aa951 Auto merge of #30753 - pnkfelix:downgrade-29383-struct-warnings-to-errors, r=nikomatsakis
Downgrade unit struct match via S(..) warnings to errors

The error signalling was introduced in #29383

It was noted as a warning-cycle-less regression in #30379

Fix #30379
2016-01-11 13:39:06 +00:00
bors
d228cd3964 Auto merge of #30490 - ipetkov:unix-spawn, r=alexcrichton
* If the requested descriptors to inherit are stdio descriptors there
  are situations where they will not be set correctly
* Example: parent's stdout --> child's stderr
           parent's stderr --> child's stdout
* Solution: if the requested descriptors for the child are stdio
  descriptors, `dup` them before overwriting the child's stdio

Example of a program which exhibits the bug:
```rust
// stdio.rs
use std::io::Write;
use std::io::{stdout, stderr};
use std::process::{Command, Stdio};
use std::os::unix::io::FromRawFd;

fn main() {
    stdout().write_all("parent stdout\n".as_bytes()).unwrap();
    stderr().write_all("parent stderr\n".as_bytes()).unwrap();

    Command::new("sh")
        .arg("-c")
        .arg("echo 'child stdout'; echo 'child stderr' 1>&2")
        .stdin(Stdio::inherit())
        .stdout(unsafe { FromRawFd::from_raw_fd(2) })
        .stderr(unsafe { FromRawFd::from_raw_fd(1) })
        .status()
        .unwrap_or_else(|e| { panic!("failed to execute process: {}", e) });
}
```

Before:
```
$ rustc --version
rustc 1.7.0-nightly (8ad12c3e2 2015-12-19)
$ rustc stdio.rs && ./stdio >out 2>err
$ cat out
parent stdout
$ cat err
parent stderr
child stdout
child stderr
```

After (expected):
```
$ rustc --version
rustc 1.7.0-dev (712eccee2 2015-12-19)
$ rustc stdio.rs && ./stdio >out 2>err
$ cat out
parent stdout
child stderr
$ cat err
parent stderr
child stdout
```
2016-01-11 10:19:44 +00:00
bors
dfaddb732c Auto merge of #27807 - pczarn:arena-internals, r=bluss
Fixes #18037 "TypedArena cannot handle zero-sized types".
Closes #17931 "improve chunk allocation scheme used by Arena / TypedArena".
Closes #22847 "TypedArena should implement Send". - N.B. Arena cannot implement Send, since it may contain non-Send values.
Closes #18471 "`Arena::alloc_copy_inner` (at least) should be renamed and made public." - Added `Arena::alloc_bytes`.
Closes #18261 "support clearing TypedArena with the chunks preserved". - Only the largest chunk is preserved.
2016-01-11 08:32:46 +00:00
bors
69e1f57dfb Auto merge of #30295 - jseyfried:fix_extern_crate_duplicate, r=nrc
Fix a bug allowing an item and an external crate to collide so long as the external crate is declared after the item. For example,
```rust
mod core { pub fn f() {} } // This would be an error if it followed the `extern crate`
extern crate core; // This declaration is shadowed by the preceding module

fn main() { core::f(); }
```
This is a [breaking-change], but it looks unlikely to cause breakage in practice, and any breakage can be fixed by removing colliding `extern crate` declarations, which are shadowed and hence unused.
2016-01-11 06:40:58 +00:00
Steve Klabnik
b2e670a7f3 Rollup merge of #30789 - D101101:patch-1, r=steveklabnik 2016-01-09 14:04:20 -05:00
Steve Klabnik
c0983cd67e Rollup merge of #30771 - tsion:mir-text-terminator-fix, r=eddyb
This just removes the `Some()` that appeared around terminators in MIR text output after https://github.com/rust-lang/rust/pull/30481 (cc @nagisa). The graphviz is already fixed.

r? @eddyb
2016-01-09 14:04:20 -05:00
Steve Klabnik
1345d188b7 Rollup merge of #30766 - steveklabnik:gh28810, r=steveklabnik
Doing so is considered weaker writing. Thanks @Charlotteis!

Fixes #28810
2016-01-09 14:04:20 -05:00
Steve Klabnik
6ba952020f Remove many instances of 'just'
Doing so is considered weaker writing. Thanks @Charlotteis!

Fixes #28810
2016-01-09 14:03:58 -05:00
Sergey Veselkov
31e39cd05c Remove unused link from enums.md 2016-01-09 12:17:44 +03:00
Niko Matsakis
b0f6a47a0f Minor rebase corrections 2016-01-08 21:00:24 -05:00
Niko Matsakis
83710b4471 permit coercions if [error] is found in either type 2016-01-08 20:20:02 -05:00
Ariel Ben-Yehuda
a3cbfa58be improve cast handling - this fixes test failures
the problem is that now "type_is_known_to_be_sized" now returns
false when called on a type with ty_err inside - this prevents
spurious errors (we may want to move the check to check::cast
anyway - see #12894).
2016-01-08 20:20:02 -05:00
Niko Matsakis
77756cb12a Change error scheme so that if projection fails we generate A::B instead of TyError 2016-01-08 20:20:02 -05:00
Niko Matsakis
64b720229c Remove ErrorCandidate in favor of just generating an ambiguous result 2016-01-08 20:20:02 -05:00
Niko Matsakis
b4f5ddba67 Make coherence more tolerant of error types.
Fixes #29857.
Fixes #30589.
2016-01-08 20:20:01 -05:00
bors
d70ab2bdf1 Auto merge of #30782 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #30584, #30747, #30755, #30758, #30760, #30769
- Failed merges: #30766
2016-01-08 22:42:10 +00:00
Steve Klabnik
926eb83e78 Rollup merge of #30769 - steveklabnik:gh30069, r=apasel422
Fixes #30069
2016-01-08 13:02:31 -05:00
Steve Klabnik
2908385fc7 Rollup merge of #30760 - jonastepe:nomicon_vec_insert_remove_len, r=apasel422
len needs to be prefixed by self for this to work. That is something which trips me up all the time. It's reassuring to see that happening to seasoned Rust programmers.
2016-01-08 13:02:31 -05:00
Steve Klabnik
3836578be2 Rollup merge of #30758 - birkenfeld:fix-30743, r=steveklabnik
(fixes #30743)

Not sure if the "Note" should be kept.
2016-01-08 13:02:31 -05:00
Steve Klabnik
0b5f7946d8 Rollup merge of #30755 - datagrok:master, r=steveklabnik
I'm working my way through TRPL beginning at "Syntax and Semantics" as was recommended in a previous version.

I'm expecting the chapter to incrementally build up my knowledge of the language section by section, assuming no prior Rust experience. So it was a bit of a speed-bump to encounter references and the vector type in a code example long before they had been defined and explained.

Another commit in this PR tries to make consistent what is a "chapter" of TRPL versus a "section." Just a nit-pick, but not thinking about that stuff keeps my focus on the important material.

My background: Python programmer since ~2000, with moderate exposure to C, C++, assembly, operating systems, and system architecture in university several years ago.

For your kind consideration, feel welcome to use or drop or rework any part of this.
2016-01-08 13:02:31 -05:00
Steve Klabnik
27df1ec010 Rollup merge of #30747 - nagisa:mir-reenable-test, r=nikomatsakis
Fixes #30674

The test seems to work fine and assertion passes. The test seems to also be generated from MIR (LLVM IR has footprint of MIR translator), thus I’m reenabling it.
2016-01-08 13:02:30 -05:00
Steve Klabnik
c518664ea5 Rollup merge of #30584 - GuillaumeGomez:new_handles, r=pnkfelix
Last part of #30413.

r? @pnkfelix
2016-01-08 13:02:30 -05:00
Felix S. Klock II
fa027d1417 The lint warnings are not reported since we report the errors first and then exit.
I think that behavior is fine, so I am removing the expected warnings from these tests.
2016-01-08 16:19:13 +01:00
Guillaume Gomez
c07876951b Add new help messages for E0425 2016-01-08 13:33:44 +01:00
Felix S. Klock II
40e2ac28e4 Added proper lint for the unit variant/struct warning. 2016-01-08 02:07:28 +01:00
bors
64a8ffeffa Auto merge of #30757 - michaelwoerister:mir-visitor-cleanup, r=jroesch
After a call to `visit_def_id()` missing in `mir::visit::Visitor` but not `mir::visit::MutVisitor` has caused me a couple hours of error hunting, I decided I'd take the time to get rid of the code duplication between the two implementations.

cc @rust-lang/compiler
2016-01-07 22:54:22 +00:00
Scott Olson
8e293676ee Fix MIR text output for terminators since they were made optional. 2016-01-07 15:16:07 -06:00
bors
5c92010d3b Auto merge of #30748 - tsion:mir-tuple-fix, r=eddyb
r? @nikomatsakis

(Related issue about `debug_tuple` at https://github.com/rust-lang/rfcs/issues/1448.)

```rust

fn main() {
    let _x = ();
}
```

```diff
--- empty_tuple-old.mir	2016-01-06 16:04:24.206409186 -0600
+++ empty_tuple-new.mir	2016-01-06 14:26:17.324888585 -0600
@@ -1,13 +1,13 @@
 fn() -> () {
     let var0: (); // _x
     let mut tmp0: ();

     bb0: {
-        var0 = ;
+        var0 = ();
         Some(goto -> bb1);
     }

     bb1: {
         Some(return);
     }
 }
```
2016-01-07 21:04:36 +00:00
Felix S. Klock II
8aed830ee3 updated test to reflect loosening of check (for issue #30379). 2016-01-07 21:56:04 +01:00
Felix S. Klock II
d4039c5d40 extend warning cycle to cover matching unit-structs via S(..)
(this makes them handled like enum unit-variants.)
2016-01-07 21:56:04 +01:00
Michael F. Lamb
fcc356373b Remove extraneous [], replace accidental removed link to heap section 2016-01-07 11:44:03 -08:00
Steve Klabnik
05874de412 Link Nomicon in PhantomData's docs
Fixes #30069
2016-01-07 14:18:15 -05:00
bors
25d1f4bc21 Auto merge of #30739 - pnkfelix:finish-enable-rpath-by-default, r=dotdash
finish enabling `-C rpath` by default in rustc. See #30353.
2016-01-07 17:46:04 +00:00
Georg Brandl
cdbf2d6e36 Move os_str docs to OsString in order to be visible in HTML (fixes #30743) 2016-01-07 16:12:38 +01:00
bors
03f4950239 Auto merge of #30734 - tsion:mir-pretty, r=nikomatsakis
* Put `const` in front of every `ConstVal`.
* Pretty-print bytestrings as they appear in Rust source.
* Pretty-print `ConstVal::{Struct, Tuple, Array, Repeat}` by pretty-printing the `ast::NodeId`. This is a temporary measure, and probably not perfect, but I'm avoiding anything more complex since I hear the const evaluator might not be AST-based in the near future.

```rust

struct Point {
    x: i32,
    y: i32,
}

fn consts() {
    let _float = 3.14159;
    let _non_const_int = -42;
    const INT: i32 = -42;
    let _int = INT;
    let _uint = 42u32;
    let _str = "a string";
    let _bytestr = b"a bytes\xFF\n\ttri\'\"\\ng";
    let _bool = true;
    const STRUCT: Point = Point { x: 42, y: 42 };
    let _struct = STRUCT;
    const EXTERNAL_STRUCT: std::sync::atomic::AtomicUsize = std::sync::atomic::ATOMIC_USIZE_INIT;
    let _external_struct = EXTERNAL_STRUCT;
    const TUPLE: (i32, &'static str, &'static [u8; 5]) = (1, "two", b"three");
    let _tuple = TUPLE;
    const FUNC: fn() = consts;
    let _function = FUNC;
    let _non_const_function = consts;
    const ARRAY: [&'static str; 3] = ["a", "b", "c"];
    let _array = ARRAY;
    const REPEAT: [&'static [u8; 3]; 10] = [b"foo"; 10];
    let _repeat = REPEAT;
}
```

```diff
--- consts-old.mir	2016-01-05 23:23:14.163807017 -0600
+++ consts-new.mir	2016-01-05 23:04:51.121386151 -0600
@@ -1,45 +1,45 @@
 fn() -> () {
     let var0: f64; // _float
     let var1: i32; // _non_const_int
     let var2: i32; // _int
     let var3: u32; // _uint
     let var4: &str; // _str
     let var5: &[u8; 18]; // _bytestr
     let var6: bool; // _bool
     let var7: Point; // _struct
     let var8: core::sync::atomic::AtomicUsize; // _external_struct
     let var9: (i32, &str, &[u8; 5]); // _tuple
     let var10: fn(); // _function
     let var11: fn() {consts}; // _non_const_function
     let var12: [&str; 3]; // _array
     let var13: [&[u8; 3]; 10]; // _repeat
     let mut tmp0: ();

     bb0: {
-        var0 = 3.14159;
-        var1 = Neg(42);
-        var2 = -42;
-        var3 = 42;
-        var4 = Str("a string");
-        var5 = ByteStr[97, 32, 98, 121, 116, 101, 115, 255, 10, 9, 116, 114, 105, 39, 34, 92, 110, 103];
-        var6 = true;
-        var7 = Struct(51);
+        var0 = const 3.14159;
+        var1 = Neg(const 42);
+        var2 = const -42;
+        var3 = const 42;
+        var4 = const "a string";
+        var5 = const b"a bytes\xff\n\ttri\'\"\\ng";
+        var6 = const true;
+        var7 = const expr Point{x: 42, y: 42,};
         var8 = consts::EXTERNAL_STRUCT;
-        var9 = Tuple(78);
-        var10 = Function(DefId { krate: 0, node: DefIndex(7) => consts });
+        var9 = const expr (1, "two", b"three");
+        var10 = const consts;
         var11 = consts;
-        var12 = Array(105, 3);
-        var13 = Repeat(122, 10);
+        var12 = const expr ["a", "b", "c"];
+        var13 = const expr [b"foo"; 10];
         drop var8;
         drop var7;
         goto -> bb1;
     }

     bb1: {
         return;
     }

     bb2: {
         diverge;
     }
 }
```
2016-01-07 14:22:49 +00:00
bors
1e8350387c Auto merge of #30317 - jseyfried:refactor_type_folder, r=nikomatsakis
`TypeFoldable`s can currently be visited inefficiently with an identity folder that is run only for its side effects. This creates a more efficient visitor for `TypeFoldable`s and uses it to implement `RegionEscape` and `HasProjectionTypes`, fixing cleanup issue #20298.
This is a pure refactoring.
2016-01-07 11:48:35 +00:00
jonastepe
a0731008fd len needs to be prefixed by self for this to work. The final code in this section of the book is correct. 2016-01-07 12:13:22 +01:00
Michael Woerister
8f51188a8e Factor mir::[Mut]Visitor implementations into a common macro. 2016-01-07 05:49:46 -05:00
bors
2edb1d9b96 Auto merge of #30728 - athaeryn:mention-warning-lint-group, r=Manishearth
Fixes #30203.

This is my first time writing Rust, and I think this code could be a bit better. Any suggestions?
2016-01-07 08:24:36 +00:00
bors
91b27ec9be Auto merge of #30724 - nikomatsakis:feature-gate-defaulted-type-parameters, r=pnkfelix
It was recently realized that we accept defaulted type parameters everywhere, without feature gate, even though the only place that we really *intended* to accept them were on types. This PR adds a lint warning unless the "type-parameter-defaults" feature is enabled. This should eventually become a hard error.

This is a [breaking-change] in that new feature gates are required (or simply removing the defaults, which is probably a better choice as they have little effect at this time). Results of a [crater run][crater] suggest that approximately 5-15 crates are affected. I didn't do the measurement quite right so that run cannot distinguish "true" regressions from "non-root" regressions, but even the upper bound of 15 affected crates seems relatively minimal.

[crater]: https://gist.github.com/nikomatsakis/760c6a67698bd24253bf

cc @rust-lang/lang
r? @pnkfelix
2016-01-07 06:32:56 +00:00
bors
440671751e Auto merge of #30723 - nrc:macro-err-bug, r=Manishearth
Fixes #30715
2016-01-07 04:44:14 +00:00
bors
3ed6e9e6f0 Auto merge of #30557 - sfackler:panic-propagate, r=aturon
See rust-lang/rfcs#1413.

r? @alexcrichton
2016-01-07 01:26:45 +00:00
Jeffrey Seyfried
6327563963 Rename fold_subitems_with to super_fold_with 2016-01-07 00:42:30 +00:00
Jeffrey Seyfried
76021d84b3 Refactor away extension traits RegionEscape and HasTypeFlags 2016-01-07 00:42:12 +00:00
Jeffrey Seyfried
f9808ea4b4 Create a visitor for TypeFoldables and use it to implement RegionEscape and HasTypeFlags (fixes #20298) 2016-01-07 00:40:18 +00:00
Michael F. Lamb
3a6dbb30a2 Be consistent about what is a "chapter" versus a "section" 2016-01-06 16:06:55 -08:00
Michael F. Lamb
936678adb1 Link to section on references when we use the term prior to defining it 2016-01-06 16:06:55 -08:00
Michael F. Lamb
3557e6941d Link to references section when they first appear
In a straight-through read of "Syntax and Semantics," the concept of a
"reference" is used here before it is explained. Mention that and link to
the section explaining references.
2016-01-06 16:06:55 -08:00