Commit Graph

97523 Commits

Author SHA1 Message Date
Lzu Tao
30ba4bd8e2 Use Result::unwrap_or_else instead of matching 2019-08-10 17:16:58 +00:00
Lzu Tao
93839c3fb4 Add an example to show how to insert item to a sorted vec 2019-08-10 16:31:38 +00:00
bjorn3
d809d6ee89
Derive Debug for CrateInfo 2019-08-10 16:47:27 +02:00
Ralf Jung
440a5c8100 rename RUST_CTFE_BACKTRACE to RUSTC_CTFE_BACKTRACE 2019-08-10 16:37:40 +02:00
bors
be3fb0cd2c Auto merge of #63437 - Centril:rollup-ryx881p, r=Centril
Rollup of 4 pull requests

Successful merges:

 - #63400 (Try to break resolve into more isolated parts)
 - #63425 (Cleanup historical stability comments)
 - #63429 (.gitignore: Readd `/tmp/`)
 - #63432 (Cleanup & Simplify stuff in lowering)

Failed merges:

r? @ghost
2019-08-10 13:44:09 +00:00
Mazdak Farrokhzad
808f98378e
Rollup merge of #63432 - Centril:simplify-lowering, r=eddyb
Cleanup & Simplify stuff in lowering

Closes https://github.com/rust-lang/rust/issues/60253 as a byproduct.

It turns out that it is in fact necessary to have a `DropTemps(...)` around the `match_expr` and there is a test (https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-13304.rs) which fails without that.

r? @eddyb
2019-08-10 15:27:36 +02:00
Mazdak Farrokhzad
219336a06c
Rollup merge of #63429 - rust-lang:gitignore-readd-tmp, r=Mark-Simulacrum
.gitignore: Readd `/tmp/`

Specifically, `/tmp/partitioning-tests/` it is generated by the incremental tests, https://github.com/rust-lang/rust/search?p=2&q=partitioning-tests&unscoped_q=partitioning-tests. These are cleaned up by compiletest but not if you kill testing prematurely (which I just did to test out a rollup, and it is annoying to `rm -rf tmp/`).

r? @Mark-Simulacrum
cc @RalfJung
2019-08-10 15:27:34 +02:00
Mazdak Farrokhzad
ad8b0a0b8f
Rollup merge of #63425 - Mark-Simulacrum:clean-stability-doc, r=eddyb
Cleanup historical stability comments

These weren't removed by ccbcc720a6 most likely by accident,
let's clean them up now.
2019-08-10 15:27:33 +02:00
Mazdak Farrokhzad
9d76a938de
Rollup merge of #63400 - petrochenkov:resplit, r=eddyb
Try to break resolve into more isolated parts

Some small step towards resolve librarification.

"Late resolution" is the pass that resolves most of names in a crate beside imports and macros.
It runs when the crate is fully expanded and its module structure is fully built.
So we just walk through the crate and resolve all the expressions, types, etc.

This pass is pretty self-contained, but it was previously done by implementing `Visitor` on the whole `Resolver` (which is used for many other tasks), and fields specific to this pass were indiscernible from the global `Resolver` state.

This PR moves the late resolution pass into a separate visitor and a separate file, fields specific to this visitor are moved from `Resolver` as well.

I'm especially happy about `current_module` being removed from `Resolver`.
It was used even for operations not related to visiting and changing the `current_module` position in process.
It was also used as an implicit argument for some functions used in this style
```rust
let orig_current_module = mem::replace(&mut self.current_module, module);
self.resolve_ident_somewhere();
self.current_module = orig_current_module;
```
and having effects on e.g. privacy checking somewhere deeply inside `resolve_ident_somewhere`.
Now we explicitly pass a `ParentScope` to those functions instead, which includes the module and some other data describing our position in the crate relatively to which we resolve names.

Rustdoc was one of the users of `current_module`, it set it for resolving intra-doc links.
Now it passes it explicitly as an argument as well (I also supported resolving paths from rustdoc in unnamed blocks as a drive-by fix).

Visibility resolution is also changed to use early resolution (which is correct because it's used during the work of `BuildReducedGraphVisitor`, i.e. integration of a new AST fragment into the existing partially built module structures.) instead of untimely late resolution (which worked only due to restrictions on paths in visibilities like inability to refer to anything except ancestor modules).
This slightly regresses its diagnostics because late resolution has a more systematic error detection and recovery currently.
Due to changes in `current_module` and visibilities `BuildReducedGraphVisitor` ended up almost as heavily affected by this refactoring as late resolution.

Fixes https://github.com/rust-lang/rust/issues/63223 (due to visibility resolution changes).
2019-08-10 15:27:31 +02:00
Tatsuyuki Ishi
2358e3eff6 Revert "Rollup merge of #62150 - alex:mem-uninit-refactor, r=RalfJung"
This reverts commit 1d45156866, reversing
changes made to 0f92eb8a4a.
2019-08-10 22:16:35 +09:00
Ralf Jung
62f1e8a7f1 fix test 2019-08-10 14:49:11 +02:00
Mark Rousskov
32f144a527 Implement Clean<Crate> on hir::Crate directly 2019-08-10 07:52:07 -04:00
Mark Rousskov
78d9088e77 Replace is_doc_reachable with is_public 2019-08-10 07:52:07 -04:00
Mark Rousskov
c36e0c0424 Remove NodeId from doctree::Module 2019-08-10 07:52:07 -04:00
Mark Rousskov
4beb751575 Gather deprecation information during cleaning 2019-08-10 07:52:07 -04:00
Mark Rousskov
11735b6235 Gather stability information during cleaning 2019-08-10 07:52:07 -04:00
Mark Rousskov
6c5d212f5f Make exact_paths a non-optional field on RustdocVisitor
Also privatizes needlessly public methods to enforce which methods
callers are intended to call, i.e., only `new` and `visit`.
2019-08-10 07:52:07 -04:00
Mark Rousskov
2fadc4524d Represent ownership transfer in RustdocVisitor::visit
Previously visit could be called multiple times, but this is inaccurate,
as it deconstructs Visitor state.
2019-08-10 07:52:07 -04:00
Mark Rousskov
2d18504c27 Remove Option from resolver 2019-08-10 07:52:07 -04:00
Ralf Jung
03e95ae412 Miri shouldn't look at types 2019-08-10 13:09:35 +02:00
Mark Rousskov
37100024de Make fields of RustdocVisitor private 2019-08-10 06:48:59 -04:00
Vadim Petrochenkov
319f0debd4 resolve: Address FIXME from the previous commit
Make the `is_import` flag in `ScopeSet` independent from namespace
Fix rebase
2019-08-10 13:48:17 +03:00
Mazdak Farrokhzad
8758d7f69d Cleanup & Simplify stuff in lowering. 2019-08-10 12:38:54 +02:00
Vadim Petrochenkov
8cc8133973 Fix calls to resolver from rustdoc and HIR lowering
Cleanup some surrounding code.
Support resolution of intra doc links in unnamed block scopes.
(Paths from rustdoc now use early resolution and no longer need results of late resolution like all the built ribs.)

Fix one test hitting file path limits on Windows.
2019-08-10 13:16:06 +03:00
Vadim Petrochenkov
f360d795f1 resolve: Move some more code around
Move methods logically belonging to build-reduced-graph into `impl BuildReducedGraphVisitor` and `build_reduced_graph.rs`
Move types mostly specific to late resolution closer to the late resolution visitor
2019-08-10 13:16:06 +03:00
Vadim Petrochenkov
9c86ce76e5 resolve: Turn resolve_error into a method on Resolver
Rename it to `report_error` and move into `diagnostics.rs`

Also turn `check_unused` into a method on `Resolver`
2019-08-10 13:16:06 +03:00
Vadim Petrochenkov
6a347f3701 resolve: Remove Deref<Target=Resolver> implementations
It's now immediately clear what fields belong to the global resolver state and what are specific to passes/visitors.
2019-08-10 13:16:06 +03:00
Vadim Petrochenkov
df03e420e0 resolve: Track whole parent scope in the visitors
Instead of tracking current module and other components separately.
(`ParentScope` includes the module as a component.)
2019-08-10 13:16:06 +03:00
Vadim Petrochenkov
ff85d1c2d2 resolve: Move late resolution visitor into a separate file 2019-08-10 13:16:06 +03:00
Vadim Petrochenkov
e2e8746acc resolve: Move late resolution into a separate visitor
Move `Resolver` fields specific to late resolution to the new visitor.
The `current_module` field from `Resolver` is replaced with two `current_module`s in `LateResolutionVisitor` and `BuildReducedGraphVisitor`.
Outside of those visitors `current_module` is replaced by passing `parent_scope` to more functions and using the parent module from it.

Visibility resolution no longer have access to later resolution methods and has to use early resolution, so its diagnostics in case of errors regress slightly.
2019-08-10 13:15:15 +03:00
bors
6f70adcb18 Auto merge of #63352 - jgalenson:reproducible-lto, r=alexcrichton
Sort the fat LTO modules to produce deterministic output.

Some projects that use LTO for their release builds are not reproducible.  We can fix this by sorting the fat LTO modules before using them.

It might also be useful to do this for thin LTO, but I couldn't get that to work to test it so I didn't do it.
2019-08-10 10:02:28 +00:00
Andreas Jonson
676953fde9 Revert "Simplify MIR generation for logical ops"
This reverts commit e38e954a0d.

llvm were not able to optimize the code that well with the simplified mir.

Closes: #62993
2019-08-10 10:52:04 +02:00
Mazdak Farrokhzad
83b837a7f9
.gitignore: Explain why /obj/ is ignored 2019-08-10 10:39:40 +02:00
Mazdak Farrokhzad
87a8c5706d
Explain why /tmp/ is ignored 2019-08-10 10:01:03 +02:00
Mazdak Farrokhzad
352c6d036f
.gitignore: Readd /tmp/
It is produced during `./x.py test`
2019-08-10 08:47:22 +02:00
bors
d19a359444 Auto merge of #63428 - Centril:rollup-c2ru1z1, r=Centril
Rollup of 7 pull requests

Successful merges:

 - #63056 (Give built-in macros stable addresses in the standard library)
 - #63337 (Tweak mismatched types error)
 - #63350 (Use associated_type_bounds where applicable - closes #61738)
 - #63394 (Add test for issue 36804)
 - #63399 (More explicit diagnostic when using a `vec![]` in a pattern)
 - #63419 (check against more collisions for TypeId of fn pointer)
 - #63423 (Mention that tuple structs are private if any of their fields are)

Failed merges:

r? @ghost
2019-08-10 06:14:13 +00:00
Mazdak Farrokhzad
019f6fed28
Rollup merge of #63423 - estebank:priv-tuple, r=zackmdavis
Mention that tuple structs are private if any of their fields are

CC #39703
2019-08-10 08:13:25 +02:00
Mazdak Farrokhzad
a029ce80a6
Rollup merge of #63419 - RalfJung:typeid, r=alexcrichton
check against more collisions for TypeId of fn pointer

Cc https://github.com/rust-lang/rfcs/pull/2738#issuecomment-519923318
2019-08-10 08:13:24 +02:00
Mazdak Farrokhzad
9e613c74be
Rollup merge of #63399 - estebank:vec-in-pat, r=Centril
More explicit diagnostic when using a `vec![]` in a pattern

```
error: unexpected `(` after qualified path
  --> $DIR/vec-macro-in-pattern.rs:3:14
   |
LL |         Some(vec![x]) => (),
   |              ^^^^^^^
   |              |
   |              unexpected `(` after qualified path
   |              in this macro invocation
   |              use a slice pattern here instead
   |
   = help: for more information, see https://doc.rust-lang.org/edition-guide/rust-2018/slice-patterns.html
   = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
```

Fix #61933.
2019-08-10 08:13:22 +02:00
Mazdak Farrokhzad
5ed195baaa
Rollup merge of #63394 - jackh726:issue-36804, r=jonas-schievink
Add test for issue 36804

I slightly reduced the repro that ICEs on nightly-2017-01-20.

Closes #36804
2019-08-10 08:13:21 +02:00
Mazdak Farrokhzad
6743ad6726
Rollup merge of #63350 - iluuu1994:use-associated-type-bounds, r=Centril
Use associated_type_bounds where applicable - closes #61738
2019-08-10 08:13:19 +02:00
Mazdak Farrokhzad
52f9e80e5f
Rollup merge of #63337 - estebank:break-ee0308, r=Centril
Tweak mismatched types error

- Change expected/found for type mismatches in `break`
- Be more accurate when talking about diverging match arms
- Tweak wording of function without a return value
- Suggest calling bare functions when their return value can be coerced to the expected type
- Give more parsing errors when encountering `foo(_, _, _)`

Fix #51767, fix #62677, fix #63136, cc #37384, cc #35241, cc #51669.
2019-08-10 08:13:17 +02:00
Mazdak Farrokhzad
eb44561600
Rollup merge of #63056 - petrochenkov:macstd2, r=alexcrichton
Give built-in macros stable addresses in the standard library

Continuation of https://github.com/rust-lang/rust/pull/62086.

Derive macros corresponding to traits from libcore are now available through the same paths as those traits:
- `Clone` - `{core,std}::clone::Clone`
- `PartialEq` - `{core,std}::cmp::PartialEq`
- `Eq` - `{core,std}::cmp::Eq`
- `PartialOrd` - `{core,std}::cmp::PartialOrd`
- `Ord` - `{core,std}::cmp::Ord`
- `Default` - `{core,std}::default::Default`
- `Debug` - `{core,std}::fmt::Debug`
- `Hash` - `{core,std}:#️⃣:Hash`
- `Copy` - `{core,std}::marker::Copy`

Fn-like built-in macros are now available through libcore and libstd's root module, by analogy with non-builtin macros defined by libcore and libstd:
```rust
{core,std}::{
    __rust_unstable_column,
    asm,
    assert,
    cfg,
    column,
    compile_error,
    concat,
    concat_idents,
    env,
    file,
    format_args,
    format_args_nl,
    global_asm,
    include,
    include_bytes,
    include_str,
    line,
    log_syntax,
    module_path,
    option_env,
    stringify,
    trace_macros,
}
```

Derive macros without a corresponding trait in libcore or libstd are still available only through prelude (also see https://github.com/rust-lang/rust/pull/62507).
Attribute macros also keep being available only through prelude, mostly because they don't have an existing practice to follow. An advice from the library team on their eventual placement would be appreciated.
```rust
    RustcDecodable,
    RustcEncodable,
    bench,
    global_allocator,
    test,
    test_case,
```

r? @alexcrichton
2019-08-10 08:13:16 +02:00
bors
be8bbb0697 Auto merge of #62756 - newpavlov:stabilize_dur_float, r=alexcrichton
Stabilize duration_float

Closes: #54361
2019-08-10 01:16:48 +00:00
Mark Rousskov
1ee37cd872 Cleanup historical stability comments
These weren't removed by ccbcc720a6 most likely by accident,
let's clean them up now.
2019-08-09 19:25:34 -04:00
bors
0ff76ad8dd Auto merge of #63415 - nikic:bump-llvm-2, r=alexcrichton
Update LLVM submodule

Fixes #63361.

r? @alexcrichton
2019-08-09 21:20:48 +00:00
Vadim Petrochenkov
cbcc7dd182 Give built-in macros stable addresses in the standard library 2019-08-10 00:05:37 +03:00
Esteban Küber
b9865d9e3f Mention that tuple structs are private if their fields are 2019-08-09 12:52:02 -07:00
Ralf Jung
4dd96d2b0f check against more collisions for TypeId of fn pointer 2019-08-09 20:10:39 +02:00
Nikita Popov
d8ae1dc3a5 Update LLVM submodule 2019-08-09 19:17:18 +02:00