]> git.lizzy.rs Git - rust.git/log
rust.git
8 years agoRollup merge of #30755 - datagrok:master, r=steveklabnik
Steve Klabnik [Fri, 8 Jan 2016 18:02:31 +0000 (13:02 -0500)]
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.

8 years agoRollup merge of #30747 - nagisa:mir-reenable-test, r=nikomatsakis
Steve Klabnik [Fri, 8 Jan 2016 18:02:30 +0000 (13:02 -0500)]
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.

8 years agoRollup merge of #30584 - GuillaumeGomez:new_handles, r=pnkfelix
Steve Klabnik [Fri, 8 Jan 2016 18:02:30 +0000 (13:02 -0500)]
Rollup merge of #30584 - GuillaumeGomez:new_handles, r=pnkfelix

Last part of #30413.

r? @pnkfelix

8 years agoThe lint warnings are not reported since we report the errors first and then exit.
Felix S. Klock II [Fri, 8 Jan 2016 15:19:13 +0000 (16:19 +0100)]
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.

8 years agoAlso store MIR of closures in crate metadata.
Michael Woerister [Fri, 8 Jan 2016 14:45:26 +0000 (09:45 -0500)]
Also store MIR of closures in crate metadata.

8 years agoChange destination accessor to return references
Simonas Kazlauskas [Thu, 7 Jan 2016 13:08:02 +0000 (15:08 +0200)]
Change destination accessor to return references

Previously it was returning a value, mostly for the two reasons:

* Cloning Lvalue is very cheap most of the time (i.e. when Lvalue is not a Projection);
* There’s users who want &mut lvalue and there’s users who want &lvalue. Returning a value allows
  to make either one easier when pattern matching (i.e. Some(ref dest) or Some(ref mut dest)).

However, I’m now convinced this is an invalid approach. Namely the users which want a mutable
reference may modify the Lvalue in-place, but the changes won’t be reflected in the final MIR,
since the Lvalue modified is merely a clone.

Instead, we have two accessors `destination` and `destination_mut` which return a reference to the
destination in desired mode.

8 years agoAdd new help messages for E0425
Guillaume Gomez [Thu, 24 Dec 2015 19:44:14 +0000 (20:44 +0100)]
Add new help messages for E0425

8 years agoAdded proper lint for the unit variant/struct warning.
Felix S. Klock II [Fri, 8 Jan 2016 01:07:28 +0000 (02:07 +0100)]
Added proper lint for the unit variant/struct warning.

8 years agoupdate test to reflect other sources of brokenness in it under new
Felix S. Klock II [Thu, 7 Jan 2016 23:36:09 +0000 (00:36 +0100)]
update test to reflect other sources of brokenness in it under new
macro future proofing rules.

(We may want to think about what this test was actually testing and
figure out a way to test it without running afoul of macro future
proofing.  I spent some time trying to do this, e.g. by inserting
parenthesis in the macro input pattern, but I could not quickly get it
working, so I took this tack instead.)

8 years ago[MIR] Fix translation of ConstVal::{Struct, Tuple}
Simonas Kazlauskas [Thu, 7 Jan 2016 23:15:59 +0000 (01:15 +0200)]
[MIR] Fix translation of ConstVal::{Struct, Tuple}

Fixes #30772

8 years agoAuto merge of #30757 - michaelwoerister:mir-visitor-cleanup, r=jroesch
bors [Thu, 7 Jan 2016 22:54:22 +0000 (22:54 +0000)]
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

8 years agoFix MIR text output for terminators since they were made optional.
Scott Olson [Thu, 7 Jan 2016 21:16:07 +0000 (15:16 -0600)]
Fix MIR text output for terminators since they were made optional.

8 years agoAuto merge of #30748 - tsion:mir-tuple-fix, r=eddyb
bors [Thu, 7 Jan 2016 21:04:36 +0000 (21:04 +0000)]
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);
     }
 }
```

8 years agoupdated test to reflect loosening of check (for issue #30379).
Felix S. Klock II [Thu, 7 Jan 2016 00:03:36 +0000 (01:03 +0100)]
updated test to reflect loosening of check (for issue #30379).

8 years agoextend warning cycle to cover matching unit-structs via `S(..)`
Felix S. Klock II [Wed, 6 Jan 2016 23:45:13 +0000 (00:45 +0100)]
extend warning cycle to cover matching unit-structs via `S(..)`

(this makes them handled like enum unit-variants.)

8 years agofix broken float methods
Pyfisch [Thu, 7 Jan 2016 20:07:24 +0000 (21:07 +0100)]
fix broken float methods

closes #30657

8 years agoAfter RFC amendment 1384, FOLLOW(pat) includes `|`, so update tests accordingly.
Felix S. Klock II [Wed, 6 Jan 2016 23:22:47 +0000 (00:22 +0100)]
After RFC amendment 1384, FOLLOW(pat) includes `|`, so update tests accordingly.

8 years agoUpdated future-proofing test, removed outdated test, and added
Felix S. Klock II [Tue, 24 Nov 2015 18:46:21 +0000 (19:46 +0100)]
Updated future-proofing test, removed outdated test, and added
run-pass test for some new functionality.

8 years agoextending FOLLOW(NT) as specified in amendment.
Felix S. Klock II [Tue, 17 Nov 2015 23:17:48 +0000 (00:17 +0100)]
extending FOLLOW(NT) as specified in amendment.

See RFC amendment 1384:

  https://github.com/rust-lang/rfcs/pull/1384

8 years agomacro_rules: proper FIRST/FOLLOW computations for checking macro_rules validity.
Felix S. Klock II [Thu, 12 Nov 2015 19:55:28 +0000 (20:55 +0100)]
macro_rules: proper FIRST/FOLLOW computations for checking macro_rules validity.

See RFC amendment 1384 and tracking issue 30450:
  https://github.com/rust-lang/rfcs/pull/1384
  https://github.com/rust-lang/rust/issues/30450

Moved old check_matcher code into check_matcher_old

combined the two checks to enable a warning cycle (where we will
continue to error if the two checks agree to reject, accept if the new
check says accept, and warn if the old check accepts but the new check
rejects).

8 years agoRemove extraneous [], replace accidental removed link to heap section
Michael F. Lamb [Thu, 7 Jan 2016 19:44:03 +0000 (11:44 -0800)]
Remove extraneous [], replace accidental removed link to heap section

8 years agoLink Nomicon in PhantomData's docs
Steve Klabnik [Thu, 7 Jan 2016 19:18:15 +0000 (14:18 -0500)]
Link Nomicon in PhantomData's docs

Fixes #30069

8 years agofix trailing whitespace
Pyfisch [Tue, 5 Jan 2016 20:30:14 +0000 (21:30 +0100)]
fix trailing whitespace

8 years agof32: inline methods with special variant for msvc
Pyfisch [Tue, 5 Jan 2016 20:14:38 +0000 (21:14 +0100)]
f32: inline methods with special variant for msvc

8 years agoExpand EO308 to mention try!
Steve Klabnik [Thu, 7 Jan 2016 19:09:20 +0000 (14:09 -0500)]
Expand EO308 to mention try!

Fixes #28953

8 years agoAuto merge of #30739 - pnkfelix:finish-enable-rpath-by-default, r=dotdash
bors [Thu, 7 Jan 2016 17:46:04 +0000 (17:46 +0000)]
Auto merge of #30739 - pnkfelix:finish-enable-rpath-by-default, r=dotdash

finish enabling `-C rpath` by default in rustc. See #30353.

8 years agoMove os_str docs to OsString in order to be visible in HTML (fixes #30743)
Georg Brandl [Thu, 7 Jan 2016 10:58:08 +0000 (11:58 +0100)]
Move os_str docs to OsString in order to be visible in HTML (fixes #30743)

8 years agoAuto merge of #30734 - tsion:mir-pretty, r=nikomatsakis
bors [Thu, 7 Jan 2016 14:22:49 +0000 (14:22 +0000)]
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;
     }
 }
```

8 years agoAuto merge of #30317 - jseyfried:refactor_type_folder, r=nikomatsakis
bors [Thu, 7 Jan 2016 11:48:35 +0000 (11:48 +0000)]
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.

8 years agolen needs to be prefixed by self for this to work. The final code in this section...
jonastepe [Thu, 7 Jan 2016 11:13:22 +0000 (12:13 +0100)]
len needs to be prefixed by self for this to work. The final code in this section of the book is correct.

8 years agoFactor mir::[Mut]Visitor implementations into a common macro.
Michael Woerister [Thu, 7 Jan 2016 10:49:46 +0000 (05:49 -0500)]
Factor mir::[Mut]Visitor implementations into a common macro.

8 years agoAuto merge of #30728 - athaeryn:mention-warning-lint-group, r=Manishearth
bors [Thu, 7 Jan 2016 08:24:36 +0000 (08:24 +0000)]
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?

8 years agoAuto merge of #30724 - nikomatsakis:feature-gate-defaulted-type-parameters, r=pnkfelix
bors [Thu, 7 Jan 2016 06:32:56 +0000 (06:32 +0000)]
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

8 years agoAuto merge of #30723 - nrc:macro-err-bug, r=Manishearth
bors [Thu, 7 Jan 2016 04:44:14 +0000 (04:44 +0000)]
Auto merge of #30723 - nrc:macro-err-bug, r=Manishearth

Fixes #30715

8 years agoAuto merge of #30557 - sfackler:panic-propagate, r=aturon
bors [Thu, 7 Jan 2016 01:26:45 +0000 (01:26 +0000)]
Auto merge of #30557 - sfackler:panic-propagate, r=aturon

See rust-lang/rfcs#1413.

r? @alexcrichton

8 years agoRename fold_subitems_with to super_fold_with
Jeffrey Seyfried [Wed, 6 Jan 2016 02:01:28 +0000 (02:01 +0000)]
Rename fold_subitems_with to super_fold_with

8 years agoRefactor away extension traits RegionEscape and HasTypeFlags
Jeffrey Seyfried [Fri, 18 Dec 2015 10:07:06 +0000 (10:07 +0000)]
Refactor away extension traits RegionEscape and HasTypeFlags

8 years agoCreate a visitor for `TypeFoldable`s and use it to implement RegionEscape and HasType...
Jeffrey Seyfried [Wed, 18 Nov 2015 09:38:57 +0000 (09:38 +0000)]
Create a visitor for `TypeFoldable`s and use it to implement RegionEscape and HasTypeFlags (fixes #20298)

8 years ago[MIR] Set dest ∀ expr with optional value
Simonas Kazlauskas [Wed, 30 Dec 2015 18:00:26 +0000 (20:00 +0200)]
[MIR] Set dest ∀ expr with optional value

Assign a default unit value to the destinations of block expressions without trailing expression,
return expressions without return value (i.e. `return;`) and conditionals without else clause.

8 years agoBe consistent about what is a "chapter" versus a "section"
Michael F. Lamb [Thu, 7 Jan 2016 00:04:47 +0000 (16:04 -0800)]
Be consistent about what is a "chapter" versus a "section"

8 years agoLink to section on references when we use the term prior to defining it
Michael F. Lamb [Thu, 7 Jan 2016 00:04:01 +0000 (16:04 -0800)]
Link to section on references when we use the term prior to defining it

8 years agoLink to references section when they first appear
Michael F. Lamb [Thu, 7 Jan 2016 00:02:03 +0000 (16:02 -0800)]
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.

8 years agoExplain surprising new syntax appearing in example code
Michael F. Lamb [Wed, 6 Jan 2016 23:46:58 +0000 (15:46 -0800)]
Explain surprising new syntax appearing in example code

In a straight-through read of "Syntax and Semantics," the first time we
meet a generic, and the first time we meet a vector, is when a Vec<T> shows
up in this example. I'm not sure that I could argue that the whole section
should appear later in the book than the ones on vectors and generics, so
instead just give the reader a brief introduction to both and a promise to
follow up later.

8 years agoAdd std::panic::propagate
Steven Fackler [Fri, 25 Dec 2015 19:00:40 +0000 (12:00 -0700)]
Add std::panic::propagate

8 years agoAuto merge of #30750 - steveklabnik:rollup, r=steveklabnik
bors [Wed, 6 Jan 2016 23:35:13 +0000 (23:35 +0000)]
Auto merge of #30750 - steveklabnik:rollup, r=steveklabnik

- Successful merges: #30683, #30698, #30699, #30700, #30716, #30720, #30727, #30729, #30735, #30749
- Failed merges:

8 years agoRollup merge of #30749 - andgra2:patch-1, r=steveklabnik
Steve Klabnik [Wed, 6 Jan 2016 23:31:58 +0000 (18:31 -0500)]
Rollup merge of #30749 - andgra2:patch-1, r=steveklabnik

8 years agoRollup merge of #30735 - jonastepe:nomicon_vec_dealloc_pointer_type, r=steveklabnik
Steve Klabnik [Wed, 6 Jan 2016 23:31:58 +0000 (18:31 -0500)]
Rollup merge of #30735 - jonastepe:nomicon_vec_dealloc_pointer_type, r=steveklabnik

heap::deallocate expects a *mut u8, but here a *mut T is given as the type of the argument. This would not compile. The final code is correct, however.

8 years agoRollup merge of #30729 - huonw:delete-bad-comment, r=sanxiyn
Steve Klabnik [Wed, 6 Jan 2016 23:31:58 +0000 (18:31 -0500)]
Rollup merge of #30729 - huonw:delete-bad-comment, r=sanxiyn

The fundamental problem of duplication was fixed in https://github.com/rust-lang/rust/pull/10891, but the comment was preserved. Closes https://github.com/rust-lang/rust/issues/9762.

8 years agoRollup merge of #30727 - tbu-:pr_doc_escaped_newline, r=steveklabnik
Steve Klabnik [Wed, 6 Jan 2016 23:31:58 +0000 (18:31 -0500)]
Rollup merge of #30727 - tbu-:pr_doc_escaped_newline, r=steveklabnik

Rust differs in that behavior from C: In C, the newline escapes are resolved
before anything else, and in Rust this depends on whether the backslash is
escaped itself.

A difference can be observed in the following two programs:

```c
int main()
{
printf("\\
n\n");
return 0;
}
```

```rust
fn main() {
println!("\\
n");
}
```

The first program prints two newlines, the second one prints a backslash, a
newline, the latin character n and a final newline.

8 years agoRollup merge of #30720 - BChip:patch-1, r=steveklabnik
Steve Klabnik [Wed, 6 Jan 2016 23:31:57 +0000 (18:31 -0500)]
Rollup merge of #30720 - BChip:patch-1, r=steveklabnik

Declare what LIFO stands for

8 years agoRollup merge of #30716 - kraai:fix-hexicdecimal, r=apasel422
Steve Klabnik [Wed, 6 Jan 2016 23:31:57 +0000 (18:31 -0500)]
Rollup merge of #30716 - kraai:fix-hexicdecimal, r=apasel422

8 years agoRollup merge of #30700 - steveklabnik:gh28581, r=brson
Steve Klabnik [Wed, 6 Jan 2016 23:31:57 +0000 (18:31 -0500)]
Rollup merge of #30700 - steveklabnik:gh28581, r=brson

Fixes #28581

8 years agoRollup merge of #30699 - steveklabnik:gh30254, r=apasel422
Steve Klabnik [Wed, 6 Jan 2016 23:31:57 +0000 (18:31 -0500)]
Rollup merge of #30699 - steveklabnik:gh30254, r=apasel422

Fixes #30254

8 years agoRollup merge of #30698 - steveklabnik:gh29649, r=brson
Steve Klabnik [Wed, 6 Jan 2016 23:31:57 +0000 (18:31 -0500)]
Rollup merge of #30698 - steveklabnik:gh29649, r=brson

Fixes #29649

r? @retep998 @alexcrichton

8 years agoRollup merge of #30683 - LawrenceWoodman:patch-1, r=steveklabnik
Steve Klabnik [Wed, 6 Jan 2016 23:31:56 +0000 (18:31 -0500)]
Rollup merge of #30683 - LawrenceWoodman:patch-1, r=steveklabnik

I noticed the alignment was off in the error handling part of the book.  This was caused because two tabs had crept into the file.  I have changed these for spaces.

8 years agoFix error in example code
Anders Granlund [Wed, 6 Jan 2016 23:09:26 +0000 (00:09 +0100)]
Fix error in example code

8 years agoReenable MIR test
Simonas Kazlauskas [Wed, 6 Jan 2016 21:50:54 +0000 (23:50 +0200)]
Reenable MIR test

Fixes #30674

8 years agoAuto merge of #30654 - nrc:panictry, r=brson
bors [Wed, 6 Jan 2016 20:30:55 +0000 (20:30 +0000)]
Auto merge of #30654 - nrc:panictry, r=brson

The motivation (other than removing boilerplate) is that this is a baby step towards a parser with error recovery.

[breaking-change] if you use any of the changed functions, you'll need to remove a try! or panictry!

8 years agoFix pretty-printing for empty tuples in MIR.
Scott Olson [Wed, 6 Jan 2016 20:17:38 +0000 (14:17 -0600)]
Fix pretty-printing for empty tuples in MIR.

8 years ago[MIR] Get rid of that nasty unit_ty temporary lval
Simonas Kazlauskas [Wed, 30 Dec 2015 11:44:13 +0000 (13:44 +0200)]
[MIR] Get rid of that nasty unit_ty temporary lval

8 years agoAuto merge of #30532 - nikomatsakis:cross-item-dependencies, r=mw
bors [Wed, 6 Jan 2016 18:37:57 +0000 (18:37 +0000)]
Auto merge of #30532 - nikomatsakis:cross-item-dependencies, r=mw

This is roughly the same as my previous PR that created a dependency graph, but that:

1. The dependency graph is only optionally constructed, though this doesn't seem to make much of a difference in terms of overhead (see measurements below).
2. The dependency graph is simpler (I combined a lot of nodes).
3. The dependency graph debugging facilities are much better: you can now use `RUST_DEP_GRAPH_FILTER` to filter the dep graph to just the nodes you are interested in, which is super help.
4. The tests are somewhat more elaborate, including a few known bugs I need to fix in a second pass.

This is potentially a `[breaking-change]` for plugin authors. If you are poking about in tcx state or something like that, you probably want to add `let _ignore = tcx.dep_graph.in_ignore();`, which will cause your reads/writes to be ignored and not affect the dep-graph.

After this, or perhaps as an add-on to this PR in some cases, what I would like to do is the following:

- [x] Write-up a little guide to how to use this system, the debugging options available, and what the possible failure modes are.
- [ ] Introduce read-only and perhaps the `Meta` node
- [x] Replace "memoization tasks" with node from the map itself
- [ ] Fix the shortcomings, obviously! Notably, the HIR map needs to register reads, and there is some state that is not yet tracked. (Maybe as a separate PR.)
- [x] Refactor the dep-graph code so that the actual maintenance of the dep-graph occurs in a parallel thread, and the main thread simply throws things into a shared channel (probably a fixed-size channel). There is no reason for dep-graph construction to be on the main thread. (Maybe as a separate PR.)

Regarding performance: adding this tracking does add some overhead, approximately 2% in my measurements (I was comparing the build times for rustdoc). Interestingly, enabling or disabling tracking doesn't seem to do very much. I want to poke at this some more and gather a bit more data -- in some tests I've seen that 2% go away, but on others it comes back. It's not entirely clear to me if that 2% is truly due to constructing the dep-graph at all.

The next big step after this is write some code to dump the dep-graph to disk and reload it.

r? @michaelwoerister

8 years agoDeprecate reflection-based Arena
Piotr Czarnecki [Wed, 6 Jan 2016 17:07:21 +0000 (18:07 +0100)]
Deprecate reflection-based Arena

8 years agoFix dependency graph test cases to have correct commments and use -Z incr-comp
Niko Matsakis [Wed, 6 Jan 2016 16:29:00 +0000 (11:29 -0500)]
Fix dependency graph test cases to have correct commments and use -Z incr-comp

8 years agoFix tidy errors
Niko Matsakis [Wed, 6 Jan 2016 16:28:53 +0000 (11:28 -0500)]
Fix tidy errors

8 years agofinish enabling -C rpath by default in rustc. See #30353.
Felix S. Klock II [Wed, 6 Jan 2016 15:24:18 +0000 (16:24 +0100)]
finish enabling -C rpath by default in rustc. See #30353.

8 years agoUse `memoized` helper more often.
Niko Matsakis [Wed, 6 Jan 2016 15:16:58 +0000 (10:16 -0500)]
Use `memoized` helper more often.

8 years agoAuto merge of #30733 - ubsan:wrapping_op_assign, r=eddyb
bors [Wed, 6 Jan 2016 15:00:17 +0000 (15:00 +0000)]
Auto merge of #30733 - ubsan:wrapping_op_assign, r=eddyb

Fix a breaking change in #30523

While this does fix a breaking change, it is also, technically, a
[breaking-change] to go back to our original way

8 years agoFix numerous typos, renamings, and minor nits raised by mw.
Niko Matsakis [Wed, 6 Jan 2016 14:19:19 +0000 (09:19 -0500)]
Fix numerous typos, renamings, and minor nits raised by mw.

8 years agoAuto merge of #30481 - nagisa:mir-calls-2, r=nikomatsakis
bors [Wed, 6 Jan 2016 13:11:18 +0000 (13:11 +0000)]
Auto merge of #30481 - nagisa:mir-calls-2, r=nikomatsakis

r? @nikomatsakis

This is a pretty big PR conflating changes to a few different block terminators (Call, DivergingCall, Panic, Resume, Diverge), because they are somewhat closely related.

Each commit has a pretty good description on what is being changed in each commit. The end result is greatly simplified CFG and translation for calls (no success branch if the function is diverging, no cleanup branch if there’s nothing to cleanup etc).

Fixes https://github.com/rust-lang/rust/issues/30480
Fixes https://github.com/rust-lang/rust/issues/29767
Partialy solves https://github.com/rust-lang/rust/issues/29575
Fixes https://github.com/rust-lang/rust/issues/29573

8 years agoStop re-exporting MutateMode's variants.
Ms2ger [Wed, 6 Jan 2016 12:16:30 +0000 (13:16 +0100)]
Stop re-exporting MutateMode's variants.

8 years agoCreate personality slot when translating Resume
Simonas Kazlauskas [Fri, 1 Jan 2016 22:45:21 +0000 (00:45 +0200)]
Create personality slot when translating Resume

This considerably simplifies code around calling functions and translation of Resume itself. This
removes requirement that a block containing Resume terminator is always translated after something
which creates a landing pad, thus allowing us to actually translate some valid MIRs we could not
translate before.

However, an assumption is added that translator is correct (in regards to landing pad generation)
and code will never reach the Resume terminator without going through a landing pad first. Breaking
these assumptions would pass an `undef` value into the personality functions.

8 years agopanic/panic_bounds_check to destructure tys
Simonas Kazlauskas [Tue, 22 Dec 2015 16:43:05 +0000 (18:43 +0200)]
panic/panic_bounds_check to destructure tys

Not any more beautiful.

8 years agoMerge Call and DivergingCall diffs into CallKind
Simonas Kazlauskas [Mon, 21 Dec 2015 23:46:56 +0000 (01:46 +0200)]
Merge Call and DivergingCall diffs into CallKind

This merges two separate Call terminators and uses a separate CallKind sub-enum instead.

A little bit unrelatedly, copying into destination value for a certain kind of invoke, is also
implemented here. See the associated comment in code for various details that arise with this
implementation.

8 years agoAdd tests
Simonas Kazlauskas [Mon, 21 Dec 2015 16:58:18 +0000 (18:58 +0200)]
Add tests

8 years agoDon’t generate landing-pads if -Z no-landing-pads
Simonas Kazlauskas [Sun, 20 Dec 2015 13:30:09 +0000 (15:30 +0200)]
Don’t generate landing-pads if -Z no-landing-pads

8 years agoFix ReturnPointer generation for void return types
Simonas Kazlauskas [Sat, 19 Dec 2015 14:51:52 +0000 (16:51 +0200)]
Fix ReturnPointer generation for void return types

Fixes #30480

8 years agoRefine call terminator translation
Simonas Kazlauskas [Sat, 19 Dec 2015 14:48:49 +0000 (16:48 +0200)]
Refine call terminator translation

* Implement landing pads; and
* Implement DivergingCall translation; and
* Modernise previous implementation of Call somewhat.

8 years agoHave a cached unreachable block inside MIR state
Simonas Kazlauskas [Sat, 19 Dec 2015 14:47:52 +0000 (16:47 +0200)]
Have a cached unreachable block inside MIR state

It is useful for various cases where direct unreachable cannot be translated and a separate block
is necessary.

8 years agoRemove diverge terminator
Simonas Kazlauskas [Fri, 18 Dec 2015 22:44:32 +0000 (00:44 +0200)]
Remove diverge terminator

Unreachable terminator can be contained all within the trans.

8 years agoRemove the Panic block terminator
Simonas Kazlauskas [Fri, 18 Dec 2015 21:19:29 +0000 (23:19 +0200)]
Remove the Panic block terminator

8 years agoAdd Resume Terminator which corresponds to resume
Simonas Kazlauskas [Tue, 15 Dec 2015 18:46:39 +0000 (20:46 +0200)]
Add Resume Terminator which corresponds to resume

Diverge should eventually go away

8 years agoGenerate DivergingCall terminator
Simonas Kazlauskas [Tue, 15 Dec 2015 10:20:49 +0000 (12:20 +0200)]
Generate DivergingCall terminator

This simplifies CFG greatly for some cases :)

8 years agoSplit Call into Call and DivergingCall
Simonas Kazlauskas [Mon, 14 Dec 2015 21:27:58 +0000 (23:27 +0200)]
Split Call into Call and DivergingCall

DivergingCall is different enough from the regular converging Call to warrant the split. This also
inlines CallData struct and creates a new CallTargets enum in order to have a way to differentiate
between calls that do not have an associated cleanup block.

Note, that this patch still does not produce DivergingCall terminator anywhere. Look for that in
the next patches.

8 years agoheap::deallocate expects a *mut u8 but here a *mut T is given. The final code is...
jonastepe [Wed, 6 Jan 2016 11:13:47 +0000 (12:13 +0100)]
heap::deallocate expects a *mut u8 but here a *mut T is given. The final code is correct, the example here would not compile without the cast. I used *mut _ instead of *mut u8 to be consistent with the final code.

8 years agoAuto merge of #30692 - michaelwoerister:mir-overloaded-fn-calls, r=nikomatsakis
bors [Wed, 6 Jan 2016 09:00:57 +0000 (09:00 +0000)]
Auto merge of #30692 - michaelwoerister:mir-overloaded-fn-calls, r=nikomatsakis

So far, calls going through `Fn::call`, `FnMut::call_mut`, or `FnOnce::call_once` have not been translated properly into MIR:
The call `f(a, b, c)` where `f: Fn(T1, T2, T3)` would end up in MIR as:
```
call `f` with arguments  `a`, `b`, `c`
```
What we really want is:
```
call `Fn::call` with arguments  `f`, `a`, `b`, `c`
```
This PR transforms these kinds of overloaded calls during `HIR -> HAIR` translation.

What's still a bit funky is that the `Fn` traits expect arguments to be tupled but due to special handling type-checking and trans, we do not actually tuple arguments and everything still checks out fine. So, after this PR we end up with MIR containing calls where function signature and arguments seemingly don't match:
```
call Fn::call(&self, args: (T1, T2, T3)) with arguments `f`, `a`, `b`, `c`
```
instead of
```
call Fn::call(&self, args: (T1, T2, T3)) with arguments `f`, (`a`, `b`, `c`)  //  <- args tupled!
```
It would be nice if the call traits could go without special handling in MIR and later on.

8 years agoFix bug in duplicate checking for extern crates.
Jeffrey Seyfried [Wed, 6 Jan 2016 07:04:48 +0000 (07:04 +0000)]
Fix bug in duplicate checking for extern crates.

8 years agostd::cmp::max -> max
Mike Anderson [Wed, 6 Jan 2016 06:42:19 +0000 (00:42 -0600)]
std::cmp::max -> max

8 years agoFix a breaking change in #30523
Nicholas Mazzuca [Wed, 6 Jan 2016 06:16:03 +0000 (22:16 -0800)]
Fix a breaking change in #30523

While this does fix a breaking change, it is also, technically, a
[breaking-change] to go back to our original way

8 years agoImprove pretty-printing for ConstVals in MIR.
Scott Olson [Wed, 6 Jan 2016 05:06:33 +0000 (23:06 -0600)]
Improve pretty-printing for ConstVals in MIR.

8 years agoWorkaround stage0 bug
Niko Matsakis [Tue, 22 Dec 2015 22:24:26 +0000 (17:24 -0500)]
Workaround stage0 bug

8 years agoAdd assert-dep-graph testing mechanism and tests
Niko Matsakis [Tue, 22 Dec 2015 22:17:27 +0000 (17:17 -0500)]
Add assert-dep-graph testing mechanism and tests

8 years agoRefactor compiler to make use of dep-tracking-maps. Also, in cases where
Niko Matsakis [Tue, 22 Dec 2015 21:39:33 +0000 (16:39 -0500)]
Refactor compiler to make use of dep-tracking-maps. Also, in cases where
we were using interior mutability (RefCells, TyIvar), add some reads/writes.

8 years agoRefactor overlap checker so that it walks the HIR instead of poking into
Niko Matsakis [Tue, 22 Dec 2015 22:17:57 +0000 (17:17 -0500)]
Refactor overlap checker so that it walks the HIR instead of poking into
random tables. The old code was weird anyway because it would
potentially walk traits from other crates etc. The new code fits
seamlessly with the dependency tracking.

8 years agoStrip the trait-def phase from collect, which has no function.
Niko Matsakis [Tue, 22 Dec 2015 22:08:45 +0000 (17:08 -0500)]
Strip the trait-def phase from collect, which has no function.

8 years agoAnnotate the compiler with information about what it is doing when.
Niko Matsakis [Tue, 22 Dec 2015 21:35:02 +0000 (16:35 -0500)]
Annotate the compiler with information about what it is doing when.

8 years agoAdd DepGraph to tcx.
Niko Matsakis [Tue, 5 Jan 2016 18:07:45 +0000 (13:07 -0500)]
Add DepGraph to tcx.

8 years agoIntroduce the DepGraph and DepTracking map abstractions,
Niko Matsakis [Tue, 5 Jan 2016 18:02:57 +0000 (13:02 -0500)]
Introduce the DepGraph and DepTracking map abstractions,
along with a README explaining how they are to be used

8 years agoAuto merge of #30492 - wesleywiser:fix_extra_drops, r=pnkfelix
bors [Wed, 6 Jan 2016 01:55:45 +0000 (01:55 +0000)]
Auto merge of #30492 - wesleywiser:fix_extra_drops, r=pnkfelix

Fixes #28159

8 years agoRemove irrelevant comment
Huon Wilson [Wed, 6 Jan 2016 01:28:34 +0000 (12:28 +1100)]
Remove irrelevant comment

The fundamental problem of duplication was fixed in https://github.com/rust-lang/rust/pull/10891, but the comment was preserved. Closes https://github.com/rust-lang/rust/issues/9762.

8 years agoBoring whitespace cleanup.
Scott Olson [Tue, 5 Jan 2016 23:26:22 +0000 (17:26 -0600)]
Boring whitespace cleanup.