Commit Graph

101793 Commits

Author SHA1 Message Date
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
Samuel Holland
1943079361 Configure LLVM module PIC level
As of LLVM 9, this is required for 32-bit PowerPC to properly generate
PLT references. Previously, only BigPIC was supported; now LLVM supports
both BigPIC and SmallPIC, and there is no default value provided.
2019-11-03 10:52:00 -06: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
Vadim Petrochenkov
90f891d8ae syntax: Avoid span arithmetics for delimiter tokens 2019-11-03 14:58:12 +03: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
Ralf Jung
a675fd6f2e don't fail manifest creation if the toolstate file is missing or mal-formed 2019-11-03 11:55:05 +01:00
Ralf Jung
9138d3bb80 when Miri tests are not passing, do not add Miri component 2019-11-03 11:47:07 +01:00
Igor Aleksanov
6e350bd999 librustc_lexer: Simplify "raw_double_quoted_string" method 2019-11-03 12:55:50 +03:00
Igor Aleksanov
d6f722d79c librustc_lexer: Simplify "double_quoted_string" method 2019-11-03 12:55:05 +03:00
Igor Aleksanov
649a5247f5 librustc_lexer: Simplify "single_quoted_string" method 2019-11-03 12:54:23 +03: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
Igor Aleksanov
e0c45f7ee7 librustc_lexer: Make "eat_float_exponent" return bool instead of result 2019-11-03 11:43:47 +03:00
Igor Aleksanov
72767a8056 librustc_lexer: Introduce "eat_while" and "eat_identifier" methods 2019-11-03 11:42:08 +03:00
Igor Aleksanov
0825b357d8 librustc_lexer: Add methods "first" and "second" to the "Cursor" 2019-11-03 11:39:39 +03: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
Eduard-Mihai Burtescu
89c8f3abca rustc: rename {Fn,Arg}TypeExt to {Fn,Arg}AbiExt. 2019-11-03 09:23:50 +02:00
Eduard-Mihai Burtescu
6567154ede rustc_target: rename {Fn,Arg}Type to {Fn,Arg}Abi. 2019-11-03 09:23:43 +02:00
bors
6c1b220fd7 Auto merge of #63810 - oli-obk:const_offset_from, r=RalfJung,nikic
Make <*const/mut T>::offset_from `const fn`

This reenables offset_of cc @mjbshaw 	after https://github.com/rust-lang/rust/pull/63075 broke it
2019-11-02 22:26:54 +00:00
Ralf Jung
b93f48f71a adjust for missing spans on x86 test runner 2019-11-02 23:13:00 +01:00
Dylan MacKenzie
981e11e8ce Don't double-count simd_shuffle promotion candidates
The proper attribute was added to `simd_shuffle*` in
rust-lang/stdarch#825. This caused `promote_consts` to double-count its
second argument when recording promotion candidates, which caused
the promotion candidate compatibility check to fail.
2019-11-02 11:26:08 -07:00
bors
91fd6283e6 Auto merge of #65429 - Timmmm:withoptions, r=Mark-Simulacrum
Add File::with_options

This provides a more fluent API to create files with options, and also avoids the need to import OpenOptions.

This implements @aldanor's [suggestion](https://github.com/rust-lang/rfcs/pull/2615#issuecomment-448591304) which was popular.
2019-11-02 18:22:32 +00:00
Simon Heath
567962d220 Add FFI bindings for Module::getInstructionCount()
Just to make it useable 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-02 10:28:05 -04:00
Kevin Cox
e7fd580e7c
Rename SuperiorThanZero -> GreaterThanZero 2019-11-02 13:12:07 +00:00
Ohad Ravid
8c909344ed Suggest more likely code when encountering an incorrect assoc item referencing the current trait 2019-11-02 11:53:38 +01:00
bors
f39205b5d9 Auto merge of #66004 - eddyb:revert-early-gate, r=petrochenkov
Partially revert the early feature-gatings added in #65742.

The intent here is to address #65860 ASAP (in time for beta, ideally), while leaving as much of #65742 around as possible, to make it easier to re-enable later.

Therefore, I've only kept the parts of the revert that re-add the old (i.e. non-early) feature-gating checks that were removed in #65742, and the test reverts.

I've disabled the new early feature-gating checks from #65742 entirely for now, but it would be easy to put them behind a `-Z` flag, or turn them into warnings, which would allow us to keep tests for both the early and late versions of the checks - assuming that's desirable.

cc @nikomatsakis @Mark-Simulacrum @Centril
2019-11-02 10:48:59 +00:00
Tomasz Miąsko
dae4c6e722 Update error annotations in tests that successfully compile
Those annotation are silently ignored rather than begin validated
against compiler output. Update them before validation is enabled,
to avoid test failures.
2019-11-02 10:28:29 +01:00
Tomasz Miąsko
b10f75ca64 Remove erroneous error-pattern from run-pass test 2019-11-02 10:28:28 +01:00
Ohad Ravid
5558fe8a92 Suggest correct code when encountering an incorrect trait bound referencing the current trait 2019-11-02 10:26:17 +01:00
Dmitry Kadashev
774e60b0c1 Prettify mismatched types error message in a special case
Type parameters are referenced in the error message after the previous
few commits (using span label). But when the main error message already
references the very same type parameter it becomes clumsy. Do not show
the additional label in this case as per code review comment by
@estebank.

Also this contains a small style fix.
2019-11-02 14:55:03 +07:00
Dmitry Kadashev
4e10b75951 Update tests
Update the tests to reflect changes to how type mismatch errors are
reported (two previous commits).
2019-11-02 13:23:28 +07:00
Dmitry Kadashev
036f182804 Show type param definitions in type mismatch errors
Fixes #47319.

Shows the type parameter definition(s) on type mismatch errors so the
context is clearer. Pretty much changes the following:

```
LL |     bar1(t);
   |          ^
   |          |
   |          expected enum `std::option::Option`, found type parameter `T`
```

into:

```
LL | fn foo1<T>(t: T) {
   |         - this type parameter
LL |     bar1(t);
   |          ^
   |          |
   |          expected enum `std::option::Option`, found type parameter `T`
```
2019-11-02 12:48:24 +07:00
Dmitry Kadashev
6a30ce639f Add type parameter name to type mismatch error messages
Part of #47319.

This just adds type parameter name to type mismatch error message, so
e.g. the following:

```
expected enum `std::option::Option`, found type parameter
```

becomes

```
expected enum `std::option::Option`, found type parameter `T`
```
2019-11-02 12:48:23 +07:00
Jeff Dickey
d9ec5fa88c 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.

r? @steveklabnik
2019-11-01 20:18:33 -07:00
Mark Rousskov
692ae3d9fb Move has_panic_handler to query 2019-11-01 22:24:43 -04:00