Commit Graph

101691 Commits

Author SHA1 Message Date
Pietro Albini
54c57a2f21
Rollup merge of #65948 - danielhenrymantilla:doc/maybe_uninit_ref_mut, r=RalfJung
Improve MaybeUninit::get_{ref,mut} documentation

As mentioned in https://github.com/rust-lang/rust/issues/63568#issuecomment-544106668, `MaybeUninit`'s `get_{ref,mut}` documentation is lacking, so this PR attempts to fix that.

That being said, and as @RalfJung mentions in that thread,

> In particular, we should clarify that all the UB rules for these methods equally apply when calling the raw ptr methods and creating a reference manually.

these other docs also need to be improved, which I can do in this PR ~~(hence the `[WIP]`)~~.

Finally, since all these documentations are related to clearly establishing when dealing with uninitialized memory which patterns are known to be sound and which patterns are currently UB (that is, until, if ever, the rules around references to unintialized integers get relaxed, this documentation will treat them as UB, and advise against such patterns (_e.g._, it is not possible to use uninitialized buffers with the `Read` API)), I think that adding even more examples to the main documentation of `MaybeUninit` inherent definition wouldn't hurt either.

___

  - [Rendered](http://dreamy-ritchie-99d637.netlify.com/core/mem/union.maybeuninit#method.get_ref)
2019-11-05 14:36:55 +01:00
bors
d1fff4a4b2 Auto merge of #66109 - pietroalbini:rollup-2npidna, r=pietroalbini
Rollup of 10 pull requests

Successful merges:

 - #65136 (Update codegen option documentation.)
 - #65574 (docs: improve disclaimer regarding LinkedList)
 - #65720 (Add FFI bindings for LLVM's Module::getInstructionCount())
 - #65905 ([doc] fixes for unix/vxworks `OpenOptionsExt::mode`)
 - #65962 (Fix logic in example.)
 - #66019 (Improved std::iter::Chain documentation)
 - #66038 (doc(str): show example of chars().count() under len())
 - #66042 (Suggest correct code when encountering an incorrect trait bound referencing the current trait)
 - #66073 (Do not needlessly write-lock)
 - #66096 (Add a failing UI test for multiple loops of all kinds in a `const`)

Failed merges:

r? @ghost
2019-11-05 09:31:36 +00:00
Pietro Albini
1ffa93e5f8
Rollup merge of #66096 - ecstatic-morse:const-loop-test, r=Centril
Add a failing UI test for multiple loops of all kinds in a `const`

This simply demonstrates the current behavior and ensures we don't allow anything by accident.

The new const checker will be able to improve the diagnostics here. While working on it, I didn't see very many tests with non-`while` loops in a `const`, and there were no tests with multiple loops.
2019-11-05 09:50:00 +01:00
Pietro Albini
dc40c9389a
Rollup merge of #66073 - Mark-Simulacrum:no-borrow-mut, r=Centril
Do not needlessly write-lock

Just removes a needless `borrow_mut()` by using `borrow()` instead.
2019-11-05 09:49:59 +01:00
Pietro Albini
1d5cb17ebe
Rollup merge of #66042 - ohadravid:suggest-correct-code-when-ref-current-trait, r=estebank
Suggest correct code when encountering an incorrect trait bound referencing the current trait

Fixes #65985 and also improves the suggestion for code like this:

```
trait Grab {
    type Value;
    fn grab(&self) -> Grab::Value;
}
```

To suggest `<Self as Grab>::Value`.

I wasn't sure which of the syntax versions is better (`<Self as ..>::` vs `Self::`), so I used the former simply because it was less change to the existing code.

r? @estebank
2019-11-05 09:49:58 +01:00
Pietro Albini
d32a262ab8
Rollup merge of #66038 - jdxcode:char-len, r=alexcrichton
doc(str): show example of chars().count() under len()

the docs are great at explaining that .len() isn't like in other
languages but stops short of explaining how to get the character length.
2019-11-05 09:49:56 +01:00
Pietro Albini
c25975d327
Rollup merge of #66019 - olegnn:fixed_std_iter_chain_docs, r=Mark-Simulacrum
Improved std::iter::Chain documentation

Replaces `strings two iterators` by `links two iterators` in `std::iter::Chain` documentation.

I didn't find any meaning of `strings` which can be evaluated as `links` or `joins`.

I don't think that `std::iter:Chain` works as a stringer or plays billiards. (https://www.lexico.com/en/definition/string).
2019-11-05 09:49:55 +01:00
Pietro Albini
370d01aea7
Rollup merge of #65962 - kevincox:patch-1, r=sfackler
Fix logic in example.

The example claims SuperiorThanZero and presumably Zero is not Superior than itself so it should not be allowed.
2019-11-05 09:49:53 +01:00
Pietro Albini
0a284153e9
Rollup merge of #65905 - cuviper:doc-unix-mode, r=Dylan-DPC
[doc] fixes for unix/vxworks `OpenOptionsExt::mode`
2019-11-05 09:49:52 +01:00
Pietro Albini
7976d5720a
Rollup merge of #65720 - icefoxen:LLVMgetInstructionCount, r=rkruppe
Add FFI bindings for LLVM's Module::getInstructionCount()

Just to make it usable for profiling and such inside
rustc itself.  It was vaguely useful in
https://wiki.alopex.li/WhereRustcSpendsItsTime and I figured
I might as well upstream it; I may or may not ever get around
to doing more with it (hopefully I will), but it may be useful
for others.
2019-11-05 09:49:50 +01:00
Pietro Albini
5831e0643e
Rollup merge of #65574 - tshepang:linked-list-disclaimer, r=Centril
docs: improve disclaimer regarding LinkedList
2019-11-05 09:49:48 +01:00
Pietro Albini
a4e91c2986
Rollup merge of #65136 - ehuss:update-codegen-options, r=Dylan-DPC
Update codegen option documentation.

Some documentation updates:

- Add more detail to codegen options.
- Add missing options:
    - `force-frame-pointers`
    - `default-linker-libraries`
    - `linker-plugin-lto`
- Add fragment anchors for all command-line-arguments.
- Add some cross links between options.
2019-11-05 09:49:47 +01:00
bors
2e4da3caad Auto merge of #65938 - eddyb:fn-abi-rename, r=oli-obk
rustc_target: rename {Fn,Arg}Type to {Fn,Arg}Abi.

I was trying to tweak the API of `FnType` (now `FnAbi`) and the name kept bothering me.

`FnAbi` is to a function signature a bit like a layout is to a type, so the name still isn't perfect yet, but at least it doesn't have the misleading `Type` in it anymore.

If this can't land I think I can continue my original refactor without it, so I'm not strongly attached to it.

r? @nagisa cc @oli-obk
2019-11-05 05:47:31 +00:00
bors
d2185f6752 Auto merge of #65911 - mati865:static-libstdcxx-mingw, r=alexcrichton
Statically link libstdc++ on windows-gnu

Fixes https://github.com/rust-lang/rust/issues/61561 by not shipping `libstdc++-6.dll` which can conflict with the GCC.
2019-11-05 00:30:58 +00:00
Dylan MacKenzie
c8ae2819c5 Add tests for loop constructs in consts
These errors are suboptimal, but they will be fixed by the new
`check_consts` pass.
2019-11-04 14:19:51 -08:00
bors
881ebeb776 Auto merge of #65874 - Nadrieril:clarify-usefulness, r=varkor
Clarify pattern-matching usefulness algorithm

This PR clarifies a bit the usefulness algorithm by emphasizing that each row of the matrix can be seen as a sort of stack from which we pop constructors. It also moves code around to increase separation of concerns.

This is part of my splitting of https://github.com/rust-lang/rust/pull/65160 into smaller PRs.
2019-11-04 21:06:50 +00:00
Daniel Henry-Mantilla
67f2200f4a Minor style improvements
Co-Authored-By: Ralf Jung <post@ralfj.de>
2019-11-04 19:47:31 +01:00
bors
2477e2493e Auto merge of #66078 - petrochenkov:gateout, r=Centril
expand: Feature gate out-of-line modules in proc macro input

Extracted from https://github.com/rust-lang/rust/pull/64273.

We are currently gating attributes applied directly to `mod` items because there are unresolved questions about out-of-line modules and their behavior is very likely to change.

However, you can sneak an out-of-line module into an attribute macro input using modules nested into other items like
```rust
#[my_attr]
fn m() {
    #[path = "zzz.rs"]
    mod n; // what tokens does the `my_attr` macro see?
}
```
This PR prevents that and emits a feature gate error for this case as well.

r? @Centril
It would be great to land this before beta.
2019-11-04 12:16:00 +00:00
Vadim Petrochenkov
e7cedc9972 expand: Feature gate out-of-line modules in proc macro input 2019-11-04 14:56:07 +03:00
bors
ab6e47851b Auto merge of #65835 - Mark-Simulacrum:lockless-lintbuffer, r=nikomatsakis
Remove LintBuffer from Session

This moves the `LintBuffer` from `Session` into the `Resolver`, where it is used until lowering is done and then consumed by early lint passes. This also happily removes the failure mode of buffering lints too late where it would have previously lead to ICEs; it is statically no longer possible to do so.

I suspect that with a bit more work a similar move could be done for the lint buffer inside `ParseSess`, but this PR doesn't touch it (in part to keep itself small).

The last commit is the "interesting" commit -- the ones before it don't work (though they compile) as they sort of prepare the various crates for the lint buffer to be passed in rather than accessed through Session.
2019-11-04 09:00:39 +00:00
bors
cba9368537 Auto merge of #64878 - XAMPPRocky:relnotes-1.39.0, r=XAMPPRocky
Updated RELEASES.md for 1.39.0

### [Rendered](https://github.com/XAMPPRocky/rust/blob/relnotes-1.39.0/RELEASES.md)

r? @Mark-Simulacrum
cc @rust-lang/release
2019-11-04 05:42:40 +00:00
Mark Rousskov
c68df7c503 Delete lint buffer from Session 2019-11-03 21:52:42 -05:00
Mark Rousskov
c0fdddcb60 Move crate type checking later
This allows us to directly pass in a lint buffer
2019-11-03 21:52:42 -05:00
Mark Rousskov
ea1ff8c07c Utilize Resolver lint buffer during HIR lowering 2019-11-03 21:52:42 -05:00
Mark Rousskov
bb0c930f82 Migrate resolver over to internal lint buffer 2019-11-03 21:52:42 -05:00
Mark Rousskov
1bd6b48914 Only permit taking buffered lints inside lint internals 2019-11-03 21:51:06 -05:00
Mark Rousskov
f530156ef5 Remove unused get_any method 2019-11-03 21:51:05 -05:00
bors
f49f388713 Auto merge of #65838 - estebank:resilient-recovery, r=Centril
Reduce amount of errors given unclosed delimiter

When in a file with a non-terminated item, catch the error and consume
the block instead of trying to recover it on a more granular way in order to
reduce the amount of unrelated errors that would be fixed after adding
the missing closing brace. Also point out the possible location of the
missing closing brace.

Fix #63690.
2019-11-04 02:30:45 +00:00
bors
0d5264a03c Auto merge of #65780 - GuillaumeGomez:move-help-popup-generation-code, r=Mark-Simulacrum
Move help popup generation code

The first commit is just a small cleanup.

The idea behind this PR is to reduce a bit more the generated HTML files by moving the duplicated code into one place instead.

r? @kinnison
2019-11-03 21:55:48 +00:00
Mark Rousskov
417c09ab27 Do not needlessly write-lock 2019-11-03 16:52:27 -05:00
bors
b520af6fd5 Auto merge of #65646 - Amanieu:foreign-exceptions, r=nikomatsakis
Allow foreign exceptions to unwind through Rust code and Rust panics to unwind through FFI

This PR fixes interactions between Rust panics and foreign (mainly C++) exceptions.

C++ exceptions (and other FFI exceptions) can now safely unwind through Rust code:
- The FFI function causing the unwind must be marked with `#[unwind(allowed)]`. If this is not the case then LLVM may optimize landing pads away with the assumption that they are unreachable.
- Drop code will be executed as the exception unwinds through the stack, as with a Rust panic.
- `catch_unwind` will *not* catch the exception, instead the exception will silently continue unwinding past it.

Rust panics can now safely unwind through C++ code:
- C++ destructors will be called as the stack unwinds.
- The Rust panic can only be caught with `catch (...)`, after which it can be either rethrown or discarded.
- C++ cannot name the type of the Rust exception object used for unwinding, which means that it can't be caught explicitly or have its contents inspected.

Tests have been added to ensure all of the above works correctly.

Some notes about non-C++ exceptions:
- `pthread_cancel` and `pthread_exit` use unwinding on glibc. This has the same behavior as a C++ exception: destructors are run but it cannot be caught by `catch_unwind`.
- `longjmp` on Windows is implemented using unwinding. Destructors are run on MSVC, but not on MinGW. In both cases the unwind cannot be caught by `catch_unwind`.
- As with C++ exceptions, you need to mark the relevant FFI functions with `#[unwind(allowed)]`, otherwise LLVM will optimize out the destructors since they seem unreachable.

I haven't updated any of the documentation, so officially unwinding through FFI is still UB. However this is a step towards making it well-defined.

Fixes #65441

cc @gnzlbg
r? @alexcrichton
2019-11-03 18:36:59 +00:00
bors
b43a682259 Auto merge of #65759 - tmiasko:ui, r=petrochenkov
Validate error patterns and error annotation in ui tests when present

Previously, when compilation succeeded, neither error patterns nor error
annotation would be validated. Additionally, when compilation failed,
only error patterns would be validated if both error patterns and error
annotation were present.

Now both error patterns and error annotation are validated when present,
regardless of compilation status. Furthermore, for test that should run,
the error patterns are matched against executable output, which is what
some of tests already expect to happen, and when #65506 is merged even
more ui tests will.

Fixes #56277
2019-11-03 15:14:09 +00:00
Amanieu d'Antras
f223e0d627 Fix macOS tests 2019-11-03 14:04:15 +00:00
Amanieu d'Antras
76660fde81 Make Emscripten unwinding use a valid type_info
This allows catch_panic to ignore C++ exceptions.
2019-11-03 14:04:15 +00:00
Amanieu d'Antras
ad61c88e72 Make SEH exceptions use a rust_panic type instead of unsigned __int64* 2019-11-03 14:03:21 +00:00
Amanieu d'Antras
83d6bf4929 Hack to make C++ exceptions test work on i686-pc-windows-gnu 2019-11-03 14:03:21 +00:00
Amanieu d'Antras
5f1a0afd22 Allow foreign exceptions to unwind through Rust code 2019-11-03 14:03:21 +00:00
Amanieu d'Antras
9a8bb3a26e Enable C++ exceptions on MSVC when building C++ tests 2019-11-03 14:03:20 +00:00
Amanieu d'Antras
246c606e75 Add -lstdc++ for run-make-fulldeps tests on MinGW 2019-11-03 14:03:20 +00:00
Eric Huss
9b9d651288 Attempt to clarify LTO and codegen-units. 2019-11-03 06:00:58 -08:00
bors
8b07292671 Auto merge of #65827 - AnthonyMikh:out_of_the_loop, r=estebank
Remove a loop which runs exactly once

Though the code seems to work properly, it is worth removing the loop entirely in order to not confuse the reader.

r? @estebank
2019-11-03 11:51:44 +00:00
Tomasz Miąsko
cfa2a2632a Use check-pass for never type tests 2019-11-03 10:20:11 +01:00
Tomasz Miąsko
6be770150b Avoid matching type in huge-struct test error annotation
The concrete type that will be too big is target dependent. Avoid
matching it in error annotation to make test work correctly across
different targets.
2019-11-03 10:20:11 +01:00
Tomasz Miąsko
d200a3f7ec Update error annotations in ui-fulldeps tests that successfully compile 2019-11-03 10:20:11 +01:00
Tomasz Miąsko
2c4862245a Validate error patterns and error annotation in ui tests when present
Previously, when compilation succeeded, neither error patterns nor error
annotation would be validated. Additionally, when compilation failed,
only error patterns would be validated if both error patterns and error
annotation were present.

Now both error patterns and error annotation are validated when present,
regardless of compilation status. Furthermore, for test that should run,
the error patterns are matched against executable output, which is what
some of tests already expect to happen, and when #65506 is merged even
more ui tests will.
2019-11-03 10:20:11 +01:00
Tomasz Miąsko
f6c2c4dc43 Update error annotations positions
Since 8ec9d7242c, in the case of a local
macro expansion, the errors are now matched to macro definition
location. Update test cases accordingly.
2019-11-03 10:20:11 +01:00
Tomasz Miąsko
23ada9495f Avoid mixing error patterns with error annotations
When both error patterns and error annotations are present in an ui
test, only error patterns are validated against the output.

Replace the error pattern with an error annotation to avoid silently
ignoring the other error annotation.
2019-11-03 10:20:11 +01:00
bors
aa51f04073 Auto merge of #65779 - kevgrasso:E0308highlight, r=estebank
Highlight only relevant parts of type path in type errors

Resolves #57413.

Unfortunately the current Rust UI testing setup can't test that the correct colors are being used in a given output, so here's a screenshot of a small test program I wrote:
![image](https://user-images.githubusercontent.com/480789/67530063-f272af00-f68b-11e9-9f96-a211fc7666d4.png)
2019-11-03 08:01:29 +00:00
Eduard-Mihai Burtescu
8b06209c28 rustc_codegen_ssa: rename FnTypeLlvmExt to FnAbiLlvmExt. 2019-11-03 09:23:50 +02:00
Eduard-Mihai Burtescu
0ea40ec76a rustc_codegen_ssa: rename ArgTypeMethods to ArgAbiMethods. 2019-11-03 09:23:50 +02:00