Commit Graph

35644 Commits

Author SHA1 Message Date
Michael Woerister
87c5927b79 debuginfo: Add test case for destructured for-loop variable. 2014-12-19 14:46:42 +01:00
bors
bd90b936d7 auto merge of #19884 : nikomatsakis/rust/issue-19730-perfect-forwarding, r=pnkfelix
Rewrite how the HRTB algorithm matches impls against obligations. Instead of impls providing higher-ranked trait-references, impls now once again only have early-bound regions. The skolemization checks are thus moved out into trait matching itself. This allows to implement "perfect forwarding" impls like those described in #19730. This PR builds on a previous PR that was already reviewed by @pnkfelix.

r? @pnkfelix 

Fixes #19730
2014-12-19 13:22:10 +00:00
Michael Woerister
34a6fcf195 debuginfo: Clean the debuginfo module up a bit. 2014-12-19 12:07:17 +01:00
Philip Munksgaard
3bb91aa28f Add a check for uninferred type parameter
This fixes #19978. The bug was introduced by 570325d, where if the type
of an Fn has not been inferred (strs[0] is "_") we slice from 1 to
0. We now explicitly check if `strs[0]` is a single element tuple.
2014-12-19 11:06:38 +01:00
Kevin Ballard
14a5992ef6 Allow marker types to have unsized parameters
Tweak CovariantType, ContravariantType, and InvariantType to allow their
type parameter to be unsized.
2014-12-19 01:12:57 -08:00
Michael Woerister
b048114718 debuginfo: Create debuginfo for for-loop variables again. 2014-12-19 09:48:28 +01:00
Niko Matsakis
ebf1e4f23a Three random test cases that seem to produce more errors now. I've
not dug deeply into what is going on here, although the errors ARE
somewhat surprising.
2014-12-19 03:29:59 -05:00
Niko Matsakis
a04ce71172 Modify the Bytes type so that it remains cloneable even
though it includes a `fn()`. This is really a more general
problem but I wanted to ensures that `bytes` in particular
remains working due to #12677.
2014-12-19 03:29:59 -05:00
Niko Matsakis
89922e52b0 Correct comment on Binder. 2014-12-19 03:29:59 -05:00
Niko Matsakis
1085012cd2 Kill some warnings about shadowed lifetimes 2014-12-19 03:29:59 -05:00
Niko Matsakis
d4f8a5abc5 Work around #19982 by rewriting test impls to not use anonymous
lifetimes. This currently causes an ICE; it should (ideally) work, but
failing that at least give a structured error. For the purposes of
this PR, though, workaround is fine.
2014-12-19 03:29:59 -05:00
Niko Matsakis
aa20e2ff36 Document new algorithm at a high-level. 2014-12-19 03:29:31 -05:00
Niko Matsakis
0b88c5d392 Remove text on method matching, which is now out of date. 2014-12-19 03:29:31 -05:00
Niko Matsakis
dab6e70e03 Convert gigantic comment away from //! form. It is annoying to
read (`//!` is intrusive) and annoying to edit (must maintain a prefix
on every line). Since the only purpose of a `doc.rs` file is to have a
bunch of text, using `/*!` and `*/` without indentations seems
appropriate.
2014-12-19 03:29:31 -05:00
Niko Matsakis
f45c0ef51e Implement "perfect forwarding" for HR impls (#19730). 2014-12-19 03:29:31 -05:00
Niko Matsakis
c2ca1a4b62 Make all predicates higher-ranked, not just trait references. 2014-12-19 03:29:30 -05:00
Niko Matsakis
4f34524fcb Move leak_check into its own method, and ensure that all higher-ranked code is in
`higher_ranked.rs`.
2014-12-19 03:29:30 -05:00
Niko Matsakis
1205fd88df Centralize on using Binder to introduce new binding levels, rather than having FnSig carry an implicit binding level. This means that we be more typesafe in general, since things that instantiate bound regions can drop the Binder to reflect that. 2014-12-19 03:29:30 -05:00
Niko Matsakis
ed4952ef39 Add (currently unused) helper routine for skolemizing bound regions. 2014-12-19 03:29:30 -05:00
Niko Matsakis
416e62924e Rename the code that replaces unbound variables to "freshen" rather than "skolemize" -- strictly speaking, this is not skolemization, because it is not discharging quantifiers. Also, the trait selection code will still be doing true skolemization, so it would be a confusing overlap of names. 2014-12-19 03:29:30 -05:00
Niko Matsakis
3cf0fbeee9 Create distinct types for a PolyTraitRef (with bindings) and a normal TraitRef. 2014-12-19 03:29:30 -05:00
Niko Matsakis
b3dcb85404 Fix a bug in the opt-in-copy work: it was failing to liberate the regions bound in the impl before searching for Copy implements for all fields, leading to problems in the "copyability check". Basically the copyability check would wind up looking for an impl of for<'tcx> Foo<&'tcx T>. The impl that exists however is impl<T> Copy for Foo<T> and the current rules do not consider that a match (something I would like to revise in a later PR). 2014-12-19 03:29:30 -05:00
Niko Matsakis
1b24602ca0 Extract leak check into a distinct subroutine. 2014-12-19 03:29:30 -05:00
Niko Matsakis
885f7ee12e Extract skolemize_regions() helper function. 2014-12-19 03:29:30 -05:00
Niko Matsakis
ff35eeb80a Recycle skolemization counts and add some comments. 2014-12-19 03:29:29 -05:00
Niko Matsakis
7be059ffcd Propagate expected type more widely so that we can rewrite the
issue-14039 test in a more natural way. Previously the "type we will
cast to" was hidden unless it was an integer.
2014-12-19 03:29:29 -05:00
Niko Matsakis
5a6a26acd6 Delete tests that passed in error. We currently do not support a Clone
impl for fn pointer types including bound regions, unfortunately.
2014-12-19 03:29:29 -05:00
Niko Matsakis
eb6ea5d49b Cleanup type resolution to use type folding infrastructure and not
have such a silly over-engineered interface.
2014-12-19 03:29:29 -05:00
Niko Matsakis
3efc9d2c55 Fix bug in higher-ranked code that would sometimes leak skolemized regions and/or cause incorrect results. 2014-12-19 03:29:29 -05:00
Niko Matsakis
514dfdbf12 Add tests for sub relationship on free/bound regions, revealing a bug. 2014-12-19 03:29:29 -05:00
bors
0efafac398 auto merge of #19654 : aturon/rust/merge-rt, r=alexcrichton
This PR substantially narrows the notion of a "runtime" in Rust, and allows calling into Rust code directly without any setup or teardown. 

After this PR, the basic "runtime support" in Rust will consist of:

* Unwinding and backtrace support
* Stack guards

Other support, such as helper threads for timers or the notion of a "current thread" are initialized automatically upon first use.

When using Rust in an embedded context, it should now be possible to call a Rust function directly as a C function with absolutely no setup, though in that case panics will cause the process to abort. In this regard, the C/Rust interface will look much like the C/C++ interface.

In more detail, this PR:

* Merges `librustrt` back into `std::rt`, undoing the facade. While doing so, it removes a substantial amount of redundant functionality (such as mutexes defined in the `rt` module). Code using `librustrt` can now call into `std::rt` to e.g. start executing Rust code with unwinding support.

* Allows all runtime data to be initialized lazily, including the "current thread", the "at_exit" infrastructure, and the "args" storage.

* Deprecates and largely removes `std::task` along with the widespread requirement that there be a "current task" for many APIs in `std`. The entire task infrastructure is replaced with `std::thread`, which provides a more standard API for manipulating and creating native OS threads. In particular, it's possible to join on a created thread, and to get a handle to the currently-running thread. In addition, threads are equipped with some basic blocking support in the form of `park`/`unpark` operations (following a tradition in some OSes as well as the JVM). See the `std::thread` documentation for more details.

* Channels are refactored to use a new internal blocking infrastructure that itself sits on top of `park`/`unpark`.

One important change here is that a Rust program ends when its main thread does, following most threading models. On the other hand, threads will often be created with an RAII-style join handle that will re-institute blocking semantics naturally (and with finer control).

This is very much a:

[breaking-change]

Closes #18000
r? @alexcrichton
2014-12-19 08:28:52 +00:00
Aaron Turon
903c5a8f69 Disable at_exit handlers
The [final step](https://github.com/rust-lang/rust/pull/19654) of
runtime removal changes the threading/process model so that the process
shuts down when the main thread exits. But several shared resources,
like the helper thread for timeouts, are shut down when the main thread
exits (but before the process ends), and they are not prepared to be
used after shut down, but other threads may try to access them during
the shutdown sequence of the main thread.

As an interim solution, the `at_exit` cleanup routine is simply skipped.

Ultimately, these resources should be made to safely handle asynchronous
shutdown, usually by panicking if called from a detached thread when the
main thread is ending.

See issue for details https://github.com/rust-lang/rust/issues/20012

This is a [breaking-change] for anyone relying on `at_exit`.
2014-12-18 23:35:53 -08:00
Aaron Turon
a9e7669cdc Rebasing fixes. 2014-12-18 23:35:53 -08:00
Aaron Turon
f4c0c0ff42 Disable stack overflow test on android, which seems to be failing spuriously.
cc https://github.com/rust-lang/rust/issues/20004
2014-12-18 23:35:53 -08:00
Aaron Turon
0ce5faaa7b Delete rest of rustrt
... and address other rebasing fallout.
2014-12-18 23:35:52 -08:00
Alex Crichton
d08600b189 std: Move the panic flag to its own thread local
This flag is somewhat tied to the `unwind` module rather than the `thread_info`
module, so this commit moves it into that module as well as allowing the same OS
thread to call `unwind::try` multiple times. Previously once a thread panicked
its panic flag was never reset, even after exiting the panic handler.
2014-12-18 23:35:52 -08:00
Alex Crichton
5759cff48e std: Lower abstractions for thread_local/at_exit
The current implementations use `std::sync` primitives, but these primitives
currently end up relying on `thread_info` and a local `Thread` being available
(mainly for checking the panicking flag).

To get around this, this commit lowers the abstractions used by the windows
thread_local implementation as well as the at_exit_imp module. Both of these
modules now use a `sys::Mutex` and a `static mut` and manage the
allocation/locking manually.
2014-12-18 23:35:52 -08:00
Aaron Turon
a27fbac868 Revise std::thread API to join by default
This commit is part of a series that introduces a `std::thread` API to
replace `std::task`.

In the new API, `spawn` returns a `JoinGuard`, which by default will
join the spawned thread when dropped. It can also be used to join
explicitly at any time, returning the thread's result. Alternatively,
the spawned thread can be explicitly detached (so no join takes place).

As part of this change, Rust processes now terminate when the main
thread exits, even if other detached threads are still running, moving
Rust closer to standard threading models. This new behavior may break code
that was relying on the previously implicit join-all.

In addition to the above, the new thread API also offers some built-in
support for building blocking abstractions in user space; see the module
doc for details.

Closes #18000

[breaking-change]
2014-12-18 23:31:52 -08:00
Aaron Turon
13f302d0c5 Update doc comment for std::rt 2014-12-18 23:31:52 -08:00
Alex Crichton
4ffd9f49c3 Avoid .take().unwrap() with FnOnce closures 2014-12-18 23:31:52 -08:00
Alex Crichton
a7061d02e1 Tweak the startup routine to pass on linux
We need to be sure to init thread_info before we init args for example because
args is grabbing locks which may entail looking at the local thread eventually.
2014-12-18 23:31:52 -08:00
Alex Crichton
7a6c54c46e Fix compilation on linux 2014-12-18 23:31:52 -08:00
Alex Crichton
9644d60cc4 Fix the capture_stderr test
There's always a fun time having two sets of standard libraries when testing!
2014-12-18 23:31:52 -08:00
Aaron Turon
ced2239852 Disable capture_stderr test for now 2014-12-18 23:31:51 -08:00
Aaron Turon
43ae4b3301 Fallout from new thread API 2014-12-18 23:31:51 -08:00
Aaron Turon
14c1a103bc Revise rt::unwind 2014-12-18 23:31:51 -08:00
Aaron Turon
d8e4780b0b Remove rt::{mutex, exclusive} 2014-12-18 23:31:51 -08:00
Aaron Turon
7fd7ce682d Add blocking support module for channels 2014-12-18 23:31:51 -08:00
Aaron Turon
84cb6cd938 Remove rt::{local, local_data, thread_local_storage} 2014-12-18 23:31:51 -08:00
Aaron Turon
cac133c9a8 Introduce std::thread
Also removes:

* `std::task`
* `std::rt::task`
* `std::rt::thread`

Notes for the new API are in a follow-up commit.

Closes #18000
2014-12-18 23:31:35 -08:00