Commit Graph

49325 Commits

Author SHA1 Message Date
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
Simonas Kazlauskas
2f86c1605c 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.
2016-01-08 14:40:32 +02: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
Felix S. Klock II
a2960bc7c6 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.)
2016-01-08 00:36:09 +01:00
Simonas Kazlauskas
ea52d9ebda [MIR] Fix translation of ConstVal::{Struct, Tuple}
Fixes #30772
2016-01-08 01:15:59 +02: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
Felix S. Klock II
c032e0c7a7 After RFC amendment 1384, FOLLOW(pat) includes |, so update tests accordingly. 2016-01-07 20:53:33 +01:00
Felix S. Klock II
3e4b7012d0 Updated future-proofing test, removed outdated test, and added
run-pass test for some new functionality.
2016-01-07 20:53:33 +01:00
Felix S. Klock II
3703ef5820 extending FOLLOW(NT) as specified in amendment.
See RFC amendment 1384:

  https://github.com/rust-lang/rfcs/pull/1384
2016-01-07 20:53:33 +01:00
Felix S. Klock II
076e64475a 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).
2016-01-07 20:53:33 +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
Steve Klabnik
ce49e3225e Expand EO308 to mention try!
Fixes #28953
2016-01-07 14:09:20 -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
Simonas Kazlauskas
3692ab673e [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.
2016-01-07 02:12:36 +02: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
Michael F. Lamb
e22ceea1a7 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.
2016-01-06 16:06:55 -08:00
Steven Fackler
022c9c70c4 Add std::panic::propagate 2016-01-06 16:06:11 -08:00
bors
43403b4169 Auto merge of #30750 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #30683, #30698, #30699, #30700, #30716, #30720, #30727, #30729, #30735, #30749
- Failed merges:
2016-01-06 23:35:13 +00:00
Steve Klabnik
6cca775865 Rollup merge of #30749 - andgra2:patch-1, r=steveklabnik 2016-01-06 18:31:58 -05:00
Steve Klabnik
e78de13783 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.
2016-01-06 18:31:58 -05:00
Steve Klabnik
d91518b9c4 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.
2016-01-06 18:31:58 -05:00
Steve Klabnik
fcb1ccf8c0 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.
2016-01-06 18:31:58 -05:00
Steve Klabnik
eb41060ce2 Rollup merge of #30720 - BChip:patch-1, r=steveklabnik
Declare what LIFO stands for
2016-01-06 18:31:57 -05:00
Steve Klabnik
23c88ff013 Rollup merge of #30716 - kraai:fix-hexicdecimal, r=apasel422 2016-01-06 18:31:57 -05:00
Steve Klabnik
48e9d192c0 Rollup merge of #30700 - steveklabnik:gh28581, r=brson
Fixes #28581
2016-01-06 18:31:57 -05:00
Steve Klabnik
ba41e3c292 Rollup merge of #30699 - steveklabnik:gh30254, r=apasel422
Fixes #30254
2016-01-06 18:31:57 -05:00
Steve Klabnik
9239b64cd6 Rollup merge of #30698 - steveklabnik:gh29649, r=brson
Fixes #29649

r? @retep998 @alexcrichton
2016-01-06 18:31:57 -05:00
Steve Klabnik
4c90f5dc9f 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.
2016-01-06 18:31:56 -05:00
Anders Granlund
7205d6b580 Fix error in example code 2016-01-07 00:09:26 +01:00
Simonas Kazlauskas
903908582c Reenable MIR test
Fixes #30674
2016-01-06 23:50:54 +02:00