Commit Graph

69156 Commits

Author SHA1 Message Date
Wonwoo Choi
272c2faa1d Display spans correctly when there are non-half-width characters 2017-11-03 03:15:39 +09:00
bors
2be4cc0402 Auto merge of #45538 - nikomatsakis:nll-liveness, r=pnkfelix
enable non-lexical lifetimes in the MIR borrow checker

This PR, joint work with @spastorino, fills out the NLL infrastructure and integrates it with the borrow checker. **Don't get too excited:** it includes still a number of hacks (the subtyping code is particularly hacky). However, it *does* kinda' work. =)

The final commit demonstrates this by including a test that -- with both the AST borrowck and MIR borrowck -- reports an error by default. But if you pass `-Znll`, you only get an error from the AST borrowck, demonstrating that the integration succeeds:

```
struct MyStruct {
    field: String
}

fn main() {
    let mut my_struct = MyStruct { field: format!("Hello") };

    let value = &my_struct.field;
    if value.is_empty() {
        my_struct.field.push_str("Hello, world!");
        //~^ ERROR cannot borrow (Ast)
    }
}
```
2017-11-01 18:14:13 +00:00
bors
a3f990dc08 Auto merge of #45472 - michaelwoerister:incr-comp-caching-base, r=nikomatsakis
incr.comp.: Implement compiler diagnostic persistence.

This PR implements storing and loading diagnostics that the compiler generates and thus allows for emitting warnings during incremental compilation without actually re-evaluating the thing the warning originally came from. It also lays some groundwork for storing and loading type information and MIR in the incr. comp. cache.

~~It is still work in progress:~~
- ~~There's still some documentation to be added.~~
- ~~The way anonymous queries are handled might lead to duplicated emissions of warnings. Not sure if there is a better way or how frequent such duplication would be in practice.~~

Diagnostic message duplication is addressed separately in #45519.

r? @nikomatsakis
2017-11-01 14:28:11 +00:00
bors
2f581cf9d6 Auto merge of #45435 - eddyb:binop-subtype-lhs, r=nikomatsakis
rustc_typeck: use subtyping on the LHS of binops.

Fixes #45425.

r? @nikomatsakis
2017-11-01 09:40:15 +00:00
bors
740286657a Auto merge of #45674 - kennytm:rollup, r=kennytm
Rollup of 14 pull requests

- Successful merges: #45450, #45579, #45602, #45619, #45624, #45644, #45646, #45648, #45649, #45650, #45652, #45660, #45664, #45671
- Failed merges:
2017-11-01 07:04:17 +00:00
kennytm
028455082e Rollup merge of #45671 - est31:master, r=alexcrichton
Tidy: track rustc_const_unstable feature gates as well

This is important for the unstable book stub generation.
2017-11-01 13:32:21 +08:00
kennytm
e2554b36fc Rollup merge of #45664 - mbrubeck:docs, r=estebank
Fix incorrect error type in Read::byte docs

None
2017-11-01 13:32:20 +08:00
kennytm
0ec40c1704 Rollup merge of #45660 - Cldfire:suggest-rename-import, r=estebank
Suggest renaming import if names clash

Closes https://github.com/rust-lang/rust/issues/32354.

The output for the example in the issue looks like this:

```
~/p/local-rust-dev-testing ❯❯❯ cargo +local-s1 build
   Compiling local-rust-dev-testing v0.1.0 (file:///home/cldfire/programming_projects/local-rust-dev-testing)
error[E0252]: the name `ConstructorExtension` is defined multiple times
  --> src/main.rs:49:5
   |
48 | use extension1::ConstructorExtension;
   |     -------------------------------- previous import of the trait `ConstructorExtension` here
49 | use extension2::ConstructorExtension;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ConstructorExtension` reimported here
   |
   = note: `ConstructorExtension` must be defined only once in the type namespace of this module
help: You can use `as` to change the binding name of the import
   |
49 | use extension2::ConstructorExtension as OtherConstructorExtension;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

...
```

This is my first PR that touches the compiler in any way, so if there's something else I need to do here (e.g. add a test), please let me know :).
2017-11-01 13:32:19 +08:00
kennytm
63ad1293cc Rollup merge of #45652 - malbarbo:x32-2, r=alexcrichton
More fixes for x86_64-unknown-linux-gnux32

This update libc (all libc testing are passing) and fixes NR_GETRANDOM.

Fix all but one run-pass test (lto-unwind.rs, see https://github.com/rust-lang/rust/issues/45416)
2017-11-01 13:32:18 +08:00
kennytm
2d53d94c3b Rollup merge of #45650 - michaelwoerister:per-crate-type-symbol-threshold, r=alexcrichton
Take crate-type into account when generating symbol export lists (linker version scripts)

r? @alexcrichton
cc https://github.com/rust-lang/rust/issues/45613
2017-11-01 13:32:17 +08:00
kennytm
57b4658a2b Rollup merge of #45649 - tbu-:pr_doc_bufread_eof, r=estebank
Add a hint what `BufRead` functions do on EOF
2017-11-01 13:32:16 +08:00
kennytm
e9b5c86c03 Rollup merge of #45648 - tbu-:pr_doc_unix_ext, r=estebank
Update doc comment for the Unix extension module

It was a bit outdated, claimed to be able to do less than it actually
could.
2017-11-01 13:32:15 +08:00
kennytm
cf0fe06bb9 Rollup merge of #45646 - sinkuu:dead-code-alias-in-pat, r=arielb1
Count type aliases used in patterns as usage by dead_code lint

Fixes #45614.
2017-11-01 13:32:14 +08:00
kennytm
26af3e1c4e Rollup merge of #45644 - zackmdavis:edit_disallowed_inner_attr_note, r=estebank
edit and fix bad spacing of inner-attribute-not-allowed note

This multiline string literal was missing a backslash, leaving an awkward
newline and 35 spaces in the middle of the message.

But while we're here, the existing message seems kind of long in comparison to
similar notes: to cut it down, we excise the mentions of doc comments, which
seems sensible because we know that this erroneous attribute is not a doc
comment (notice the `is_sugared_doc: false` at the end of the function; if it
had been a doc comment, that error would get set in the `token::DocComment`
match branch of `parse_outer_attributes`).
2017-11-01 13:32:13 +08:00
kennytm
28b18790f7 Rollup merge of #45624 - glaubitz:bootstrap-sparc64, r=kennytm
bootstrap: Add missing cputype matching for sparc64

Trying to configure rust natively on sparc64-unknown-linux-gnu currently fails with:

```
root@deb4g:/local_scratch/glaubitz/rust/rust# ./configure --host=sparc64-unknown-linux-gnu --enable-local-rust --local-rust-root=/usr/local
configure: processing command line
configure:
configure: build.host           := ['sparc64-unknown-linux-gnu']
configure: build.rustc          := /usr/local/bin/rustc
configure: build.cargo          := /usr/local/bin/cargo
configure: build.rustc          := /usr/local/bin/rustc
configure: build.cargo          := /usr/local/bin/cargo
configure: build.configure-args := ['--host=sparc64-unknown-linux-gnu', '--enable ...
unknown cpu type: sparc64
root@deb4g:/local_scratch/glaubitz/rust/rust#
```

This is trivially fixed by defining sparc64 as a valid cputype.
2017-11-01 13:32:12 +08:00
kennytm
18fa54f835 Rollup merge of #45619 - mneumann:fix-bootstrap-dragonfly, r=alexcrichton
Support Dragonfly when building Openssl
2017-11-01 13:32:11 +08:00
kennytm
e01dcf4b75 Rollup merge of #45602 - petrochenkov:ospan, r=michaelwoerister
Optimize some span operations

Do not decode span data twice/thrice/etc unnecessarily.
Applied to stable hashing and all methods in `impl Span`.

Follow up to https://github.com/rust-lang/rust/pull/44646
r? @michaelwoerister
2017-11-01 13:32:10 +08:00
kennytm
59c9d03af8 Rollup merge of #45579 - leodasvacas:document-that-call-can-be-adt-constructor, r=estebank
Document that call expressions also represent ADT constructors.

This is a rather obscure part of the language.
2017-11-01 13:32:09 +08:00
kennytm
07df45d363 Rollup merge of #45450 - GuillaumeGomez:overlap-link, r=QuietMisdreavus
Fix title heading overlap in rust doc

Fixes #45158.

To be noted that this margin only appears when a title is the first element.

<img width="1440" alt="screen shot 2017-10-22 at 16 08 44" src="https://user-images.githubusercontent.com/3050060/31862746-6411070e-b743-11e7-9a75-4159e1f7f1d6.png">

r? @rust-lang/docs
2017-11-01 13:32:08 +08:00
bors
31bbe57c79 Auto merge of #45267 - oconnor663:rwlock_send, r=alexcrichton
remove the `T: Sync` requirement for `RwLock<T>: Send`

That requirement makes sense for containers like `Arc` that don't
uniquely own their contents, but `RwLock` is not one of those.

This restriction was added in 380d23b5d4, but it's not clear why. @hniksic
and I [were discussing this on reddit](https://www.reddit.com/r/rust/comments/763o7r/blog_posts_introducing_lockfree_rust_comparing/dobcvbm/). I might be totally wrong about this change being sound, but I'm super curious to find out :)
2017-11-01 04:32:15 +00:00
bors
fc3e12a03c Auto merge of #45187 - GuillaumeGomez:doc-ui-improvement, r=QuietMisdreavus
Improve sidebar rendering and add methods list

I suppose it can be reviewed as is, but this is just the first step of a more global plan.

cc @rust-lang/docs @nical

And a screenshot of course:

<img width="1440" alt="screen shot 2017-10-10 at 23 38 45" src="https://user-images.githubusercontent.com/3050060/31412170-657beaf6-ae14-11e7-9f01-1e562a034595.png">
2017-11-01 01:45:58 +00:00
Cldfire
61396a8286 Add UI test 2017-10-31 19:35:51 -04:00
bors
f3b900cc3b Auto merge of #44764 - nvzqz:master, r=alexcrichton
Implement TryFrom<&[T]> for &[T; N]

There are many cases where a buffer with a static compile-time size is preferred over a slice with a dynamic size. This allows for performing a checked conversion from `&[T]` to `&[T; N]`. This may also lead to compile-time optimizations involving `[T; N]` such as loop unrolling.

This is my first PR to Rust, so I'm not sure if discussion of this change should happen here or does it need its own RFC? I figured these changes would be a subset of #33417.
2017-10-31 23:06:37 +00:00
est31
6a16a7c05b Also support macro generated atomic types
This is kind of a hack but it works...
2017-10-31 21:46:05 +01:00
est31
911e476cbe Tidy: track rustc_const_unstable feature gates as well
This is important for the unstable book stub generation.
2017-10-31 21:39:32 +01:00
Matt Brubeck
351f7b02de Fix incorrect error type in Read::byte docs 2017-10-31 12:30:15 -07:00
John Paul Adrian Glaubitz
d7dec7c8d7 bootstrap: Add missing cputype matching for sparc64 2017-10-31 19:26:41 +01:00
Niko Matsakis
aae3e74e70 patch mir-opt reference files 2017-10-31 14:02:31 -04:00
Cldfire
ff832405d0 Suggest renaming import if names clash 2017-10-31 13:31:48 -04:00
Niko Matsakis
9b3af6ce3c rewrite write_mir_fn_graphviz to cope with non-global tcx 2017-10-31 12:55:54 -04:00
Niko Matsakis
d9fb792d7c treat -Znll as implying -Zborrowck-mir 2017-10-31 12:41:41 -04:00
Niko Matsakis
99aa313636 runtest: fix mir directory and delete outdated MIR files 2017-10-31 12:41:41 -04:00
Niko Matsakis
7675ea997a remove the NLL pass (it is now invoked by mir borrowck) 2017-10-31 12:41:40 -04:00
Niko Matsakis
bf57a230eb WIP patch compile-fail/nll/region-ends-after-if-condition.rs 2017-10-31 12:41:40 -04:00
Niko Matsakis
f27eb1e684 change region display to '_#Nr, update the newtype_index! macro
The macro now takes a format string. It no longer defaults to using the
type name. Didn't seem worth going through contortions to maintain.  I
also changed most of the debug formats to be `foo[N]` instead of `fooN`.
2017-10-31 12:41:40 -04:00
Niko Matsakis
a94b01a0e2 connect MIR borrowck with NLL 2017-10-31 12:41:40 -04:00
Niko Matsakis
81449174f3 make the dataflow / mir-borrowck types carry a 'tcx lifetime
Also, factor out `do_mir_borrowck`, which is the code that actually
performs the MIR borrowck from within the scope of an inference context.

This change should be a pure refactoring.
2017-10-31 12:41:40 -04:00
Niko Matsakis
82b287a8c8 test "needs drop" on region-erased, lifted types
This will be important in next commit, since the input types will be
tagged not with `'gcx` but rather `'tcx`. Also, using the region-erased,
lifted types enables better caching.
2017-10-31 12:41:40 -04:00
Niko Matsakis
b2c248efea reorder 'gcx and 'tcx in BorrowckErrors impl 2017-10-31 12:41:40 -04:00
Niko Matsakis
29cdd73062 make closure_self_ty invokable with 'gcx and 'tcx 2017-10-31 12:41:40 -04:00
Niko Matsakis
5aa1cbf18f make MirSource::from_local_def_id invokable with 'gcx and 'tcx 2017-10-31 12:41:39 -04:00
Niko Matsakis
68c4844a1b make nll separately invokable 2017-10-31 12:41:39 -04:00
Santiago Pastorino
dde61f3855 add basic region subtyping inference 2017-10-31 12:41:39 -04:00
Santiago Pastorino
b8615f3bea add reborrow constraints 2017-10-31 12:41:39 -04:00
Niko Matsakis
f700728a3b make end-point optional in the borrow check 2017-10-31 12:41:39 -04:00
Niko Matsakis
5b2adcce11 factor out NLL invocation interface 2017-10-31 12:41:39 -04:00
Niko Matsakis
7414060344 update the format of liveness debug dumps to be more readable 2017-10-31 12:41:39 -04:00
Niko Matsakis
24442ffa66 add subregion between borrow region and resulting reference 2017-10-31 12:41:39 -04:00
Niko Matsakis
af09f720d6 preliminary support for may-dangle attribute and drop constraints 2017-10-31 12:41:38 -04:00
Niko Matsakis
e02937848b extend liveness to distinguish "drop" and "non-drop" uses 2017-10-31 12:41:38 -04:00