Commit Graph

61868 Commits

Author SHA1 Message Date
Daniel Xu
dc53e561a1 Add compile fail test for SIMD 2017-03-02 18:39:39 -06:00
bors
c0b7112ba2 Auto merge of #40216 - frewsxcv:rollup, r=frewsxcv
Rollup of 7 pull requests

- Successful merges: #39832, #40104, #40110, #40117, #40129, #40139, #40166
- Failed merges:
2017-03-02 20:10:40 +00:00
Corey Farwell
ba39e5d905 Rollup merge of #40166 - aidanhs:aphs-index-coerce, r=nikomatsakis
Allow types passed to [] to coerce, like .index()

Fixes #40085

Basically steals the relevant part of [check_argument_types](https://github.com/rust-lang/rust/blob/1.15.1/src/librustc_typeck/check/mod.rs#L2653-L2672).
2017-03-02 14:53:51 -05:00
Corey Farwell
05e0d740a2 Rollup merge of #40139 - tedsta:fuchsia_std_process_fix, r=alexcrichton
std::process for fuchsia: updated to latest liblaunchpad

Our liblaunchpad changed a bit and so fuchsia's std::process impl needs to change a bit.

@raphlinus
2017-03-02 14:53:49 -05:00
Corey Farwell
c883f4f584 Rollup merge of #40129 - abonander:proc_macro_bang, r=jseyfried
Implement function-like procedural macros ( `#[proc_macro]`)

Adds the `#[proc_macro]` attribute, which expects bare functions of the kind `fn(TokenStream) -> TokenStream`, which can be invoked like `my_macro!()`.

cc rust-lang/rfcs#1913, #38356

r? @jseyfried
cc @nrc
2017-03-02 14:53:46 -05:00
Corey Farwell
0536fd6396 Rollup merge of #40117 - SimonSapin:to-err-is-for-the-formatter, r=alexcrichton
Panic on errors in `format!` or `<T: Display>::to_string`

… instead of silently ignoring a result.

`fmt::Write for String` never returns `Err`, so implementations of `Display` (or other traits of that family) never should either.

Fixes #40103
2017-03-02 14:53:44 -05:00
Corey Farwell
aef07cd991 Rollup merge of #40110 - benschreiber:nostackcheck, r=brson
Made no_stack_check a stable_removed attribute

r? @brson
2017-03-02 14:53:43 -05:00
Corey Farwell
4ab162fbf6 Rollup merge of #40104 - nagisa:mir-the-shiny, r=eddyb
[MIR] Rvalue::ty infallible + remove TypedConstVal

Feel free to r+ whenever there aren't any big bit-rot sensitive PRs in the queue.

r? @eddyb
2017-03-02 14:53:42 -05:00
Corey Farwell
c3ada00316 Rollup merge of #39832 - phil-opp:x86-interrupt-calling-convention, r=nagisa
Add support for the x86-interrupt calling convention

This calling convention can be used for definining interrupt handlers on 32-bit and 64-bit x86 targets. The compiler then uses `iret` instead of `ret` for returning and ensures that all registers are restored to their
original values.

Usage:

```rust
extern "x86-interrupt" fn handler(stack_frame: &ExceptionStackFrame) {…}
```

for interrupts and exceptions without error code and

```rust
extern "x86-interrupt" fn handler_with_err_code(stack_frame: &ExceptionStackFrame,
                                                error_code: u64) {…}
```

for exceptions that push an error code (e.g., page faults or general protection faults). The programmer must ensure that the correct version is used for each interrupt.

For more details see the [LLVM PR][1] and the corresponding [proposal][2].

[1]: https://reviews.llvm.org/D15567
[2]: http://lists.llvm.org/pipermail/cfe-dev/2015-September/045171.html

It is also possible to implement interrupt handlers on x86 through [naked functions](https://github.com/rust-lang/rfcs/blob/master/text/1201-naked-fns.md). In fact, almost all existing Rust OS projects for x86 use naked functions for this, including [Redox](b9793deb59/arch/x86_64/src/lib.rs (L109-L147)), [IntermezzOS](f959cc18c7/interrupts/src/lib.rs (L28-L72)), and [blog_os](844d739379/src/interrupts/mod.rs (L49-L64)). So support for the `x86-interrupt` calling convention isn't absolutely needed.

However, it has a number of benefits to naked functions:

- **No inline assembly needed**: [Inline assembly](https://doc.rust-lang.org/book/inline-assembly.html) is highly unstable and dangerous. It's pretty easy to mess things up. Also, it uses an arcane syntax and requires that the programmer knows x86 assembly.
- **Higher performance**: A naked wrapper function always saves _all_ registers before calling the Rust function. This isn't needed for a compiler supported calling convention, since the compiler knows which registers are clobbered by the interrupt handler. Thus, only these registers need to be saved and restored.
- **Safer interfaces**: We can write a `set_handler` function that takes a `extern "x86-interrupt" fn(&ExceptionStackFrame)` and the compiler ensures that we always use the right function type for all handler functions. This isn't possible with the `#[naked]` attribute.
- **More convenient**: Instead of writing [tons of assembly boilerplate](b9793deb59/arch/x86_64/src/lib.rs (L109-L147)) and desperately trying to improve things [through macros](844d739379/src/interrupts/mod.rs (L17-L92)), we can just write [code like this](e6a61f9507/src/interrupts/mod.rs (L85-L89)).
- **Naked functions are unreliable**: It is allowed to use Rust code inside a naked function, which sometimes works and sometimes not. For example, [calling a function](b9793deb59/arch/x86_64/src/lib.rs (L132)) through Rust code seems to work fine without function prologue, but [code declaring a variable](https://is.gd/NQYXqE) silently adds a prologue even though the function is naked (look at the generated assembly, there is a `movl` instruction before the `nop`).

**Edit**: See the [tracking issue](https://github.com/rust-lang/rust/issues/40180) for an updated list of issues.

Unfortunately, the implementation of the `x86-interrupt` calling convention in LLVM has some issues that make it unsuitable for 64-bit kernels at the moment:

- LLVM always tries to backup the `xmm` registers on 64-bit platforms even if the target doesn't support SSE. This leads to invalid opcode exceptions whenever an interrupt handler is invoked. I submitted a fix to LLVM in [D29959](https://reviews.llvm.org/D29959). The fix is really small (<10 lines), so maybe we could backport it to [Rust's LLVM fork](https://github.com/rust-lang/llvm)?. **Edit**: The fix was merged to LLVM trunk in [rL295347](https://reviews.llvm.org/rL295347). Backported in https://github.com/rust-lang/llvm/pull/63.

- On targets with SSE support, LLVM uses the `movaps` instruction for saving the `xmm` registers, which requires an alignment of 16. For handlers with error codes, however, the stack alignment is only 8, so a alignment exception occurs. This issue is tracked in [bug 26413](https://bugs.llvm.org/show_bug.cgi?id=26413). ~~Unfortunately, I don't know enough about LLVM to fix this.~~ **Edit**: Fix submitted in [D30049](https://reviews.llvm.org/D30049).

This PR adds experimental support for this calling convention under the `abi_x86_interrupt` feature gate. The implementation is very similar to #38465 and was surprisingly simple :).

There is no accepted RFC for this change. In fact, the [RFC for interrupt calling convention](https://github.com/rust-lang/rfcs/pull/1275) from 2015 was closed in favor of naked functions. However, the reactions to the recent [PR](https://github.com/rust-lang/rust/pull/38465) for a MSP430 interrupt calling convention were [in favor of experimental interrupt ABIs](https://github.com/rust-lang/rust/pull/38465#issuecomment-270015470).

- [x] Add compile-fail tests for the feature gate.
- [x] Create tracking issue for the `abi_x86_interrupt` feature (and link it in code). **Edit**: Tracking issue: #40180
- [x] Backport [rL295347](https://reviews.llvm.org/rL295347) to Rust's LLVM fork. **Edit**: Done in https://github.com/rust-lang/llvm/pull/63

@tari @steveklabnik @jackpot51 @ticki @hawkw @thepowersgang, you might be interested in this.
2017-03-02 14:53:41 -05:00
Philipp Oppermann
b44805875e Add support for x86-interrupt calling convention
Tracking issue: https://github.com/rust-lang/rust/issues/40180

This calling convention can be used for definining interrupt handlers on
32-bit and 64-bit x86 targets. The compiler then uses `iret` instead of
`ret` for returning and ensures that all registers are restored to their
original values.

Usage:

```
extern "x86-interrupt" fn handler(stack_frame: &ExceptionStackFrame) {…}
```

for interrupts and exceptions without error code and

```
extern "x86-interrupt" fn page_fault_handler(stack_frame: &ExceptionStackFrame,
                                             error_code: u64) {…}
```

for exceptions that push an error code (e.g., page faults or general
protection faults). The programmer must ensure that the correct version
is used for each interrupt.

For more details see the [LLVM PR][1] and the corresponding [proposal][2].

[1]: https://reviews.llvm.org/D15567
[2]: http://lists.llvm.org/pipermail/cfe-dev/2015-September/045171.html
2017-03-02 19:01:15 +01:00
bors
5907ed63d3 Auto merge of #39655 - durka:recursion-limit-suggestion, r=nikomatsakis
suggest doubling recursion limit in more situations

Fixes #38852.

r? @bluss
2017-03-02 17:44:17 +00:00
bors
8ae411e1b3 Auto merge of #40206 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 9 pull requests

- Successful merges: #40081, #40144, #40168, #40169, #40170, #40173, #40175, #40191, #40194
- Failed merges:
2017-03-02 14:38:12 +00:00
Guillaume Gomez
ad0a3567f8 Rollup merge of #40194 - letmaik:patch-1, r=steveklabnik
Fix wrong word used in book page "const and static"
2017-03-02 11:29:43 +01:00
Guillaume Gomez
a7126e1132 Rollup merge of #40191 - topecongiro:x86-interrupt, r=steveklabnik
Add abi_x86_interrupt to the unstable book

This PR closes #40181.
2017-03-02 11:29:42 +01:00
Guillaume Gomez
f10adcc279 Rollup merge of #40175 - d-e-s-o:fix-inconsistency-in-guessing-game-readme, r=steveklabnik
doc: fix inconsistency in error output in guessing-game.md

The line '.expect("failed to read line");' is partly started with a
lower case 'f' and partly with an uppercase one, adding additional
spurious changes to otherwise clean diffs if each sample is
copy-and-pasted over the previous.
This change starts the string with an uppercase everywhere which is in
line with the style of the other strings.
2017-03-02 11:29:41 +01:00
Guillaume Gomez
4cf072d480 Rollup merge of #40173 - er-1:master, r=alexcrichton
Add a reference to the dl library to the Makefile of the test issue-2…

…4445.

It prevents the test to fail on ppc64el at least.

Part of #39015
2017-03-02 11:29:40 +01:00
Guillaume Gomez
e583b6a605 Rollup merge of #40170 - iKevinY:if-let-typo, r=frewsxcv
Fix link in `if let` docs

r? @steveklabnik
2017-03-02 11:29:39 +01:00
Guillaume Gomez
216a0ead44 Rollup merge of #40169 - MajorBreakfast:patch-8, r=steveklabnik
String docs: Add "the"

r? @steveklabnik
2017-03-02 11:29:38 +01:00
Guillaume Gomez
418a776651 Rollup merge of #40168 - topecongiro:compile-fail-test-abi-ptx, r=petrochenkov
Add compile fail test for abi_ptx

Issue #39059.
2017-03-02 11:29:37 +01:00
Guillaume Gomez
b1bd60bd7f Rollup merge of #40144 - MajorBreakfast:patch-7, r=frewsxcv
Unit-like structs doc: Improve code sample

r? @steveklabnik

BTW it seems that
```Rust
let p = Proton {};
```
compiles without an error. That's why I didn't add it to the example. It's about consistency anyway.
2017-03-02 11:29:36 +01:00
Guillaume Gomez
5d08775051 Rollup merge of #40081 - GuillaumeGomez:poison-docs, r=frewsxcv
Add missing url in sync structs

r? @frewsxcv
2017-03-02 11:29:35 +01:00
Alex Burka
6e259dc778 note -> help 2017-03-02 07:11:22 +00:00
bors
2be750b243 Auto merge of #40188 - nikomatsakis:issue-40029, r=eddyb
inhibit enum layout optimizations under `#[repr(C)]` or `#[repr(u8)]`

Fixes #40029
2017-03-02 03:34:53 +00:00
topecongiro
0907b9d121 Add abi_x86_interrupt to the unstable book 2017-03-02 08:36:34 +09:00
Maik Riechert
898d010692 fix wrong word used (static vs const) 2017-03-01 23:06:40 +00:00
bors
d0954375e4 Auto merge of #39803 - brson:fpic, r=alexcrichton
Add a test that -fPIC is applied

r? @alexcrichton Can it really be this simple? I've tested it works, but still testing that it used to fail.
2017-03-01 22:48:17 +00:00
Simon Sapin
f2017f4561 Panic on errors in format! or <T: Display>::to_string
… instead of silently ignoring a result.

`fmt::Write for String` never returns `Err`,
so implementations of `Display` (or other traits of that family)
never should either.

Fixes #40103
2017-03-01 23:47:59 +01:00
Niko Matsakis
2b07d0d853 inhibit enum layout optimizations under #[repr(C)] or #[repr(u8)]
Fixes #40029
2017-03-01 15:44:27 -05:00
Alex Crichton
55dab70f7a Don't run test on darwin 2017-03-01 08:08:53 -08:00
deso
471e65571b
doc: fix inconsistency in error output in guessing-game.md
The line '.expect("failed to read line");' is partly started with a
lower case 'f' and partly with an uppercase one, adding additional
spurious changes to otherwise clean diffs if each sample is
copy-and-pasted over the previous.
This change starts the string with an uppercase everywhere which is in
line with the style of the other strings.
2017-03-01 05:52:41 -08:00
er-1
05aadd2933 Add a reference to the dl library to the Makefile of the test issue-24445.
It prevents the test to fail on ppc64el at least.

Part of #39015
2017-03-01 12:17:27 +01:00
bors
691eba1358 Auto merge of #34198 - eddyb:you're-a-bad-transmute-and-you-should-feel-bad, r=nikomatsakis
Make transmuting from fn item types to pointer-sized types a hard error.

Closes #19925 by removing the future compatibility lint and the associated workarounds.
This is a `[breaking-change]` if you `transmute` from a function item without casting first.
For more information on how to fix your code, see https://github.com/rust-lang/rust/issues/19925.
2017-03-01 10:03:44 +00:00
Josef Brandl
8f1a0afee1 Unit-like structs doc: Add compile fail tag 2017-03-01 10:03:07 +01:00
Kevin Yap
9d99e12675 Fix link in if let docs 2017-03-01 01:01:37 -08:00
Josef Brandl
74b6221209 String docs: Add "the" 2017-03-01 09:56:52 +01:00
bors
b671c32ddc Auto merge of #40167 - frewsxcv:rollup, r=frewsxcv
Rollup of 6 pull requests

- Successful merges: #39419, #39936, #39944, #39960, #40028, #40128
- Failed merges:
2017-03-01 07:57:09 +00:00
bors
7ce1fbe1f7 Auto merge of #39419 - jseyfried:simplify_tokentree, r=nrc
Simplify `TokenTree` and fix `macro_rules!` bugs

This PR
 - fixes #39390, fixes #39403, and fixes #39404 (each is a [breaking-change], see issues for examples),
 - fixes #39889,
 - simplifies and optimizes macro invocation parsing,
 - cleans up `ext::tt::transcribe`,
 - removes `tokenstream::TokenTree::Sequence` and `Token::MatchNt`,
   - instead, adds a new type `ext::tt::quoted::TokenTree` for use by `macro_rules!` (`ext::tt`)
 - removes `parser.quote_depth` and `parser.parsing_token_tree`, and
 - removes `quote_matcher!`.
   - Instead, use `quote_tokens!` and `ext::tt::quoted::parse` the result with `expect_matchers=true`.
   - I found no outside uses of `quote_matcher!` when searching Rust code on Github.

r? @nrc
2017-03-01 05:58:09 +00:00
topecongiro
9141b7be70 Add compile fail test for abi_ptx 2017-03-01 13:12:07 +09:00
Corey Farwell
0b5bf67449 Rollup merge of #40128 - cengizIO:master, r=nikomatsakis
Move two large error_reporting fn's to a separate file

Hello!

I tried to make `librustc/infer/error_reporting,rs` more readable by modularizing it and moving its two largest functions to a separate file.

If you have any suggestions, please send it right away! 🚀

Thanks goes to @nikomatsakis for supporting.
2017-02-28 22:55:31 -05:00
Corey Farwell
0a008b949e Rollup merge of #40028 - withoutboats:string_from_iter, r=alexcrichton
impl FromIterator<&char> for String
2017-02-28 22:55:30 -05:00
Corey Farwell
06a0233ab3 Rollup merge of #39960 - lukaramu:issue-39925, r=alexcrichton
added Error and Display impl for std::ffi::FromBytesWithNulError

Fixes #39925.

This is my first PR, so I wasn't quite sure about the stability annotation.
2017-02-28 22:55:29 -05:00
Corey Farwell
fda3f98746 Rollup merge of #39944 - GuillaumeGomez:associated-consts, r=frewsxcv
Improve associated constant rendering in rustdoc

Before:

<img width="1440" alt="screen shot 2017-02-19 at 00 30 51" src="https://cloud.githubusercontent.com/assets/3050060/23097697/caeed80e-f63a-11e6-98c2-5d27e4efd76d.png">

After:

<img width="1440" alt="screen shot 2017-02-19 at 00 30 39" src="https://cloud.githubusercontent.com/assets/3050060/23097698/cfb4874e-f63a-11e6-80cf-ffbf5c5c6162.png">

cc @SergioBenitez

r? @rust-lang/docs
2017-02-28 22:55:28 -05:00
Corey Farwell
43df65fb3f Rollup merge of #39936 - djzin:inclusive_rangeargument, r=alexcrichton
impl RangeArgument for RangeInclusive and add appropriate tests

Now that `RangeArgument` returns a `Bound`, the impl for `RangeInclusive` is natural to implement and all that's required are tests around it.
2017-02-28 22:55:27 -05:00
Corey Farwell
4ba49ab39f Rollup merge of #39419 - jseyfried:simplify_tokentree, r=nrc
Simplify `TokenTree` and fix `macro_rules!` bugs

This PR
 - fixes #39390, fixes #39403, and fixes #39404 (each is a [breaking-change], see issues for examples),
 - fixes #39889,
 - simplifies and optimizes macro invocation parsing,
 - cleans up `ext::tt::transcribe`,
 - removes `tokenstream::TokenTree::Sequence` and `Token::MatchNt`,
   - instead, adds a new type `ext::tt::quoted::TokenTree` for use by `macro_rules!` (`ext::tt`)
 - removes `parser.quote_depth` and `parser.parsing_token_tree`, and
 - removes `quote_matcher!`.
   - Instead, use `quote_tokens!` and `ext::tt::quoted::parse` the result with `expect_matchers=true`.
   - I found no outside uses of `quote_matcher!` when searching Rust code on Github.

r? @nrc
2017-02-28 22:55:26 -05:00
Austin Bonander
2fcbb48c72 Implement function-like procedural macros ( #[proc_macro]) 2017-02-28 18:34:22 -08:00
bors
2f52386f10 Auto merge of #40164 - steveklabnik:rollup, r=steveklabnik
Rollup of 5 pull requests

- Successful merges: #40130, #40142, #40150, #40151, #40153
- Failed merges:
2017-03-01 00:58:13 +00:00
Aidan Hobson Sayers
c58fff2bb7 Allow types passed to [] to coerce, like .index()
Fixes #40085
2017-03-01 00:15:13 +00:00
Steve Klabnik
4fd2aeddd4 Rollup merge of #40153 - steveklabnik:alphabetize-unstable-book, r=frewsxcv
sort unstable book alphabetically

I made these the same order as they were in the compiler, but for no good reason. Much easier to find out what you need when they're sorted alphabetically

r? @frewsxcv
2017-02-28 15:38:43 -08:00
Steve Klabnik
2a14d4bb86 Rollup merge of #40151 - steveklabnik:update-mdbook, r=frewsxcv
update mdbook version

This contains two important bugfixes
2017-02-28 15:38:42 -08:00
Steve Klabnik
40069bb9d1 Rollup merge of #40150 - topecongiro:compile-fail-test-cfg-target-has-atomic, r=alexcrichton
Add compile test for cfg_target_has_atomic

Issue #39059.
I am concerned about whether the test is excessive.
2017-02-28 15:38:41 -08:00