Commit Graph

74523 Commits

Author SHA1 Message Date
kennytm
9d995d2832
Rollup merge of #47942 - estebank:macro-spans, r=nikomatsakis Minimize weird spans involving macro context Sometimes the parser attempts to synthesize spans from within a macro context with the span for the captured argument, leading to non-sensical spans with very bad output. Given that an incorrect span is worse than a partially incomplete span, when detecting this situation return only one of the spans without merging them. Fix #32072, #47778. CC #23480. 2018-02-02 22:48:50 +08:00
kennytm
7c6380cdcf
Rollup merge of #47919 - varkor:to_degrees-precision, r=rkruppe Use constant for 180/π in to_degrees The current f32|f64.to_degrees implementation uses a division to calculate 180/π, which causes a loss of precision. Using a constant is still not perfect (implementing a maximally-precise algorithm would come with a high performance cost), but improves precision with a minimal change. As per the discussion in #29944, this fixes #29944 (the costs of improving the precision further would not outweigh the gains). 2018-02-02 22:48:49 +08:00
kennytm
5edeff3130
Rollup merge of #47916 - vmx:patch-2, r=kennytm Fix lang items box example code The exchange_free lang item is gone in favour of box_free [1]. Some warnings are also fixed by this commit. [1]: https://github.com/rust-lang/rust/commit/ca115dd083a1fe1d2b4892c5e50e49eb83ff1f3 2018-02-02 22:48:47 +08:00
kennytm
b4b73a1d95
Rollup merge of #47914 - etaoins:improve-char-escape-in-lexer-msg, r=petrochenkov Improve char escaping in lexer messages Currently ', " and \ are escaped as \', \" and \\ respectively. This leads to confusing messages such as error: unknown start of token: \\ when encountering a single backslash. Fix by emitting printable ASCII characters directly. This will still escape \r, \n, \t and Unicode characters. Fixes #47902 2018-02-02 22:48:46 +08:00
kennytm
2e3a8f5159
Rollup merge of #47898 - Aaron1011:static-ref-nll, r=nikomatsakis Fix ICE when assigning references to a static mut with NLL is_unsafe_place only filters out statics in the rhs, not the lhs. Since it's possible to reach that 'Place::Static', we handle statics the same way as we do locals. Fixes #47789 2018-02-02 22:48:45 +08:00
kennytm
a6719446c0
Rollup merge of #47842 - Manishearth:dead-code, r=nagisa Remove dead code The Clone impl makes the lint ignore the type. 2018-02-02 22:48:43 +08:00
kennytm
0f36b2cf2e
Rollup merge of #47829 - estebank:break-in-for, r=cramertj Suggest removing value from break when invalid When attempting to use break with a value in a type of loop where it'd be invalid (any non-loop), suggest using break on its own. Close #34359. 2018-02-02 22:48:41 +08:00
kennytm
3600bfb3f0
Rollup merge of #46156 - SimonSapin:patch-14, r=withoutboats
Document the size of bool
2018-02-02 16:29:11 +08:00
Manish Goregaokar
ee737c73a2 Add regression test 2018-02-02 13:36:26 +05:30
Manish Goregaokar
c22d6e2fda Fix rustdoc ICE on macros defined within functions
fixes #47639
2018-02-02 12:13:12 +05:30
bors
616b66dca2 Auto merge of #47465 - estebank:include-space-after-mut, r=nikomatsakis
Include space in suggestion `mut` in bindings

Fix #46614.
2018-02-02 04:19:12 +00:00
Manish Goregaokar
c785013951 Remove dead code 2018-02-02 09:18:49 +05:30
Peter Atashian
259b0329d4
This internal only method is no longer needed. 2018-02-01 20:42:31 -05:00
Peter Atashian
dcf53c1590
Rewrite remove_dir_all to be correct
The fact that this had to be rewritten does not bode well
2018-02-01 20:35:50 -05:00
Peter Atashian
b1b9edf5ae
This is what FileType on Windows should ideally be. 2018-02-01 20:29:19 -05:00
bors
6741e416fe Auto merge of #47102 - Diggsey:wasm-syscall, r=alexcrichton
Implement extensible syscall interface for wasm

Currently it's possible to run tests with the native wasm target, but it's not possible to tell whether they pass or to capture the output, because libstd throws away stdout, stderr and the exit code. While advanced libstd features should probably require more specific targets (eg. wasm-unknown-web) I think even the unknown target should at least support basic I/O.

Any solution is constrained by these factors:
- It must not be javascript specific
- There must not be too strong coupling between libstd and the host environment (because it's an "unknown" target)
- WebAssembly does not allow "optional" imports - all imports *must* be resolved.
- WebAssembly does not support calling the host environment through any channel *other* than imports.

The best solution I could find to these constraints was to give libstd a single required import, and implement a syscall-style interface through that import. Each syscall is designed such that a no-op implementation gives the most reasonable fallback behaviour. This means that the following import table would be perfectly valid:
```javascript
imports.env = { rust_wasm_syscall: function(index, data) {} }
```

Currently I have implemented these system calls:
- Read from stdin
- Write to stdout/stderr
- Set the exit code
- Get command line arguments
- Get environment variable
- Set environment variable
- Get time

It need not be extended beyond this set if being able to run tests for this target is the only goal.

edit:
As part of this PR I had to make a further change. Previously, the rust entry point would be automatically called when the webassembly module was instantiated. This was problematic because from the javascript side it was impossible to call exported functions, access program memory or get a reference to the instance.

To solve this, ~I changed the default behaviour to not automatically call the entry point, and added a crate-level attribute to regain the old behaviour. (`#![wasm_auto_run]`)~ I disabled this behaviour when building tests.
2018-02-02 01:27:14 +00:00
Esteban Küber
fd3f2312a7 Fix test after rebase 2018-02-01 15:16:02 -08:00
Esteban Küber
378e73e6db Remove support for Self in attributes 2018-02-01 15:06:23 -08:00
Esteban Küber
f7c61783e4 Fix tests 2018-02-01 15:06:22 -08:00
Esteban Küber
27a23db660 Rework parse_ident_attr 2018-02-01 15:06:22 -08:00
Esteban Küber
2dee07b12a Remove cast suggestions 2018-02-01 15:06:22 -08:00
Esteban Küber
621e61bff9 Add filter to detect local crates for rustc_on_unimplemented 2018-02-01 15:06:21 -08:00
Esteban Küber
4c92a02b64 Change rustc_on_unimplemented for Iterator and binops 2018-02-01 15:06:21 -08:00
Esteban Küber
c1383e4dc4 Add filtering options to rustc_on_unimplemented
- filter error on the evaluated value of `Self`
 - filter error on the evaluated value of the type arguments
 - add argument to include custom note in diagnostic
 - allow the parser to parse `Self` when processing attributes
 - add custom message to binops
2018-02-01 15:06:20 -08:00
Guillaume Gomez
8b8d044026 Fix ugly hover in sidebar 2018-02-01 23:40:23 +01:00
Badel2
196fad0d00 Turn type_id into a constant intrinsic
Add rustc_const_unstable attribute for `any::TypeId::of`

Add test for `const fn TypeId::of`
2018-02-01 23:03:19 +01:00
dpc
accd997b54 add ellided lifetime 2018-02-02 02:10:10 +05:30
Esteban Küber
df412ce208 Change offset to 0 2018-02-01 12:18:15 -08:00
Esteban Küber
aaec608367 Minimize weird spans involving macro context
Sometimes the parser attempts to synthesize spans from within a macro
context with the span for the captured argument, leading to non-sensical
spans with very bad output. Given that an incorrect span is worse than
a partially incomplete span, when detecting this situation return only
one of the spans without mergin them.
2018-02-01 11:51:49 -08:00
varkor
e34c31bf02 Use constant for 180/π in to_degrees
The current `f32|f64.to_degrees` implementation uses a division to calculate 180/π, which causes a loss of precision. Using a constant is still not perfect (implementing a maximally-precise algorithm would come with a high performance cost), but improves precision with a minimal change.
2018-02-01 18:35:51 +00:00
bors
56733bc9f8 Auto merge of #47738 - nikomatsakis:issue-47139-master, r=arielb1
remove intercrate ambiguity hints

The scheme was causing overflows during coherence checking (e.g. #47139). This is sort of a temporary fix; the proper fix I think involves reworking trait selection in deeper ways.

cc @sgrif -- this *should* fix diesel

cc @qnighy -- I'd like to discuss you with alternative techniques for achieving the same end. =) Actually, it might be good to put some energy into refactoring traits first.

r? @eddyb
2018-02-01 07:33:35 +00:00
Zack M. Davis
e4b1a7971d concerning well-formed suggestions for unused shorthand field patterns
Previously, unused variables would get a note that the warning could be
silenced by prefixing the variable with an underscore, but that doesn't
work for field shorthand patterns, which the liveness analysis didn't
know about.

The "to avoid this warning" verbiage seemed unnecessary.

Resolves #47390.
2018-01-31 21:27:16 -08:00
bors
26792f0607 Auto merge of #47540 - Manishearth:suggestion, r=nrc
Add approximate suggestions for rustfix

This adds `span_approximate_suggestion()` that lets you emit a
suggestion marked as "non-machine applicable" in the JSON output. UI
users see no difference. This is for when rustc and clippy wish to
 emit suggestions which will make sense to the reader (e.g. they may
have placeholders like `<type>`) but are not source-applicable, so that
rustfix/etc can ignore these.

fixes #39254
2018-02-01 04:47:46 +00:00
Zack M. Davis
8f9d91587f in which HirIdMap is introduced as an affordance for using HirIds more
The glossaries in the draft rustc-guide book and librustc/README.md
state that `NodeId` is being gradually phased out in favor of `HirId`;
as such, the present author claims that we ought to have a typedef for
efficient `HirId` maps and sets in the module for such, even if no use
for them has been made as yet (compatibility constraints preventing the
use of it in the author's present unit of work): it is important to
create the psychological "affordance" (in James J. Gibson's sense) that
`HirId`s are a thing that compiler developers can work with.
2018-01-31 20:40:03 -08:00
Aaron Hill
0fd4f37944
Fix overflow when performing drop check calculations in NLL
Clearing out the infcx's region constraints after processing each type
ends up interacting badly with normalizing associated types. This commit
keeps all region constraints intact until the end of
TypeLivenessGenerator.add_drop_live_constraint, ensuring that normalized
types are able to re-use existing inference variables.

Fixes #47589
2018-01-31 22:11:50 -05:00
Manish Goregaokar
8a8f91b89e Generalize tuple_like_shim's code to be useful for enums 2018-02-01 08:05:37 +05:30
Manish Goregaokar
dfd244d952 Eliminate ret_field and ret intermediates in array clone shim 2018-02-01 08:05:37 +05:30
Manish Goregaokar
f97629160f Correctly subst the fn_sig so that we get the correct types
Otherwise we get random TySelfs there, which means operations on
RETURN_PLACE end up breaking down badly.
2018-02-01 08:05:37 +05:30
Volker Mische
cf78ff3913
Fix lang items box example code
The `exchange_free` lang item is gone in favour of `box_free` [1].

Some warnings are also fixed by this commit.

[1]: https://github.com/rust-lang/rust/commit/ca115dd083a1fe1d2b4892c5e50e49eb83ff1f3
2018-02-01 00:21:43 +01:00
Eduard-Mihai Burtescu
9c3dc7e872 rustc: prefer ParamEnvAnd and LayoutCx over tuples for LayoutOf. 2018-02-01 00:01:08 +02:00
Ryan Cumming
b9441f2428 Improve char escaping in lexer messages
Currently ', " and \ are escaped as \', \" and \\ respectively. This
leads to confusing messages such as `error: unknown start of token: \\`
when encountering a single backslash.

Fix by emitting printable ASCII characters directly. This will still
escape \r, \n, \t and Unicode characters.

Fixes #47902
2018-02-01 08:19:22 +11:00
bors
8ccab7eed5 Auto merge of #47900 - kennytm:rollup, r=kennytm
Rollup of 16 pull requests

- Successful merges: #47838, #47840, #47844, #47874, #47875, #47876, #47884, #47886, #47889, #47890, #47891, #47795, #47677, #47893, #47895, #47552
- Failed merges:
2018-01-31 20:51:02 +00:00
Josh Stone
55b54a999b Use a range to identify SIGSEGV in stack guards
Previously, the `guard::init()` and `guard::current()` functions were
returning a `usize` address representing the top of the stack guard,
respectively for the main thread and for spawned threads.  The `SIGSEGV`
handler on `unix` targets checked if a fault was within one page below
that address, if so reporting it as a stack overflow.

Now `unix` targets report a `Range<usize>` representing the guard
memory, so it can cover arbitrary guard sizes.  Non-`unix` targets which
always return `None` for guards now do so with `Option<!>`, so they
don't pay any overhead.

For `linux-gnu` in particular, the previous guard upper-bound was
`stackaddr + guardsize`, as the protected memory was *inside* the stack.
This was a glibc bug, and starting from 2.27 they are moving the guard
*past* the end of the stack.  However, there's no simple way for us to
know where the guard page actually lies, so now we declare it as the
whole range of `stackaddr ± guardsize`, and any fault therein will be
called a stack overflow.  This fixes #47863.
2018-01-31 11:41:29 -08:00
Josh Stone
e2de8deb09 Enable stack-probe tests with system LLVM >= 5.0 2018-01-31 11:41:26 -08:00
kennytm
af95302d3c
Rollup merge of #47552 - oberien:stepby-nth, r=dtolnay
Specialize StepBy::nth

This allows optimizations of implementations of the inner iterator's `.nth` method.
2018-02-01 02:34:15 +08:00
kennytm
86eb725953
Rollup merge of #47895 - varkor:non-utf-stdin, r=estebank
Fix ICE when reading non-UTF-8 input from stdin

Fixes #22387.
2018-02-01 02:32:10 +08:00
kennytm
61972e733d
Rollup merge of #47893 - alexcrichton:move-codegen-backends, r=alexcrichton
rustc: Move location of `codegen-backends` dir

Right now this directory is located under:

```
$sysroot/lib/rustlib/$target/lib/codegen-backends
```

but after seeing what we do in a few other places it seems that a more
appropriate location would be:

```
$sysroot/lib/rustlib/$target/codegen-backends
```

so this commit moves it!
2018-02-01 02:29:38 +08:00
kennytm
68135d1936
Rollup merge of #47677 - etaoins:avoid-underflow-in-rennder-source-line, r=estebank
Avoid underflow in render_source_line

While testing rust-lang/rust#47655 I was able to make the compiler panic when it's compiled with debug assertions:

```shell
> rustc /dev/null --crate-type proc-macro

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.25.0-dev running on x86_64-apple-darwin

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'attempt to subtract with overflow', librustc_errors/emitter.rs:287:49
```

Without debug assertions the following warning is emitted:

```shell
> rustc /dev/null --crate-type proc-macro

warning: unused variable: `registrar`
 --> /dev/null:0:1
  |
  |
  = note: #[warn(unused_variables)] on by default
  = note: to avoid this warning, consider using `_registrar` instead
```

The panic is due to the unused variable warning being spanned to `/dev/null:0:1`. When `render_source_line` subtracts 1 from the line number to look up the source line it panics due to underflow. Without debug assertions this would wrap and cause us to return a blank string instead.

Fix by explicitly testing for 0 and exiting early. I'm unsure how to automatically test this now that rust-lang/rust#46655 has been approved.
2018-02-01 02:26:48 +08:00
Alex Crichton
8ebe542480 rustc: Move location of codegen-backends dir
Right now this directory is located under:

  $sysroot/lib/rustlib/$target/lib/codegen-backends

but after seeing what we do in a few other places it seems that a more
appropriate location would be:

  $sysroot/lib/rustlib/$target/codegen-backends

so this commit moves it!
2018-01-31 10:16:26 -08:00
Pramod Bisht
434bfb17b4 Changed of struct url to #ad448e in rust docs 2018-01-31 21:51:27 +05:30