for the code:
```
use std::io;
#![crate_type="rlib"] // ERROR: an inner attribute is not permitted in this context
fn say_hello() {
println!("hello");
}
```
this PR provides another note to help programmer fixing this error more easily:
```
hello.rs:6:3: 6:4 error: an inner attribute is not permitted in this context
hello.rs:6 #![crate_type="rlib"]
^
hello.rs:6:3: 6:4 note: put inner attribute in top of file or block
hello.rs:6 #![crate_type="rlib"]
^
```
Commit bec2ee77f7 started quoting paths
discovered as part of the `probe` function, which includes git. The
`make` `wildcard` function appears to be incompatible with quoted
paths so this check in the makefile now fails. Employing `wildcard`
here appears to only re-verify that git actually exists, which the
configure script already did, so I've just removed it.
Additionally, with the quoted paths the `subst` function should no
longer be needed, so I've removed it as well.
Closes#18771
I've implemented the new collection views API for TrieMap. I more or less followed the approach set out by @Gankro in BTreeMap, by using a `SearchStack`. There's quite a bit of unsafe code, but I've wrapped it safely where I think is appropriate. I've added tests to ensure everything works, and performance seems quite good.
```
test trie::bench_map::bench_find ... bench: 67879 ns/iter (+/- 4192)
test trie::bench_map::bench_find_entry ... bench: 186814 ns/iter (+/- 18748)
test trie::bench_map::bench_insert_large ... bench: 716612 ns/iter (+/- 160121)
test trie::bench_map::bench_insert_large_entry ... bench: 851219 ns/iter (+/- 20331)
test trie::bench_map::bench_remove ... bench: 838856 ns/iter (+/- 27998)
test trie::bench_map::bench_remove_entry ... bench: 981711 ns/iter (+/- 53046)
```
Using an entry is slow compared to a plain find, but is only ~15% slower for inserts and removes, which is where this API is most useful. I'm tempted to remove the standalone `remove` function in favour of an entry-based approach (to cut down on complexity).
I've added some more comments to the general part of the code-base, which will hopefully help the next person looking over this. I moved the three key structures to the top of the file so that the nesting structure is clearly visible, and renamed `Child<T>` to `TrieNode<T>` and `TrieNode<T>` to `InternalNode<T>` to improve clarity. If these changes are creeping, I'm happy to revert them.
Let me know if my use of `fail!` is ok, I was a little unsure of how specific to be. Some of the data-structures have various invariants that shouldn't be broken, so using `fail!` seemed appropriate.
## Still to do
* Modernise iterators (make them double-ended).
* Make the keys generic, or rename this data-structure (see: https://github.com/rust-lang/rust/issues/14902).
* Possibly move this code out of libcollections. [Searching Github for TrieMap turns up very few real results.][triemap-search]
Related issues: https://github.com/rust-lang/rust/issues/18009 and https://github.com/rust-lang/rust/issues/17320
[triemap-search]: https://github.com/search?utf8=%E2%9C%93&q=TrieMap+language%3ARust&type=Code&ref=searchresults
Previously Int inherited from PartialOrd (via Primitive)
but not Ord. But integers have a total order, so
inheriting from Ord is appropriate. Fixes#18776.
`as` (already for a long time) and `move` (which was only added recently, AFAIK) are not marked as keywords in Vim syntax file, so they are not highlighted as keywords in Rust sources. This PR fixes this.
A most trivial documentation correction. The examples in the intro are all about adding to the end of the array, not the beginning, but this one line says "prepend".
This isn't a very serious problem, it just made me a bit confused when I got to it.
This PR includes a sequence of commits that gradually dismantles the `librustrt` `rtio` system -- the main trait previously used to abstract over green and native io. It also largely dismantles `libnative`, moving much of its code into `libstd` and refactoring as it does so.
TL;DR:
* Before this PR: `rustc hello.rs && wc -c hello` produces 715,996
* After this PR: `rustc hello.rs && wc -c hello` produces 368,100
That is, this PR reduces the footprint of hello world by ~50%.
This is a major step toward #17325 (i.e. toward implementing the [runtime removal RFC](https://github.com/rust-lang/rfcs/pull/230).) What remains is to pull out the scheduling, synchronization and task infrastructure, and to remove `libgreen`. These will be done soon in a follow-up PR.
Part of the work here is eliminating the `rtio` abstraction, which in many cases means bringing the implementation of io closer to the actual API presented in `std::io`.
Another aspect of this PR is the creation of two new, *private* modules within `std` that implement io:
* The `sys` module, which represents a platform-specific implementation of a number of low-level abstractions that are used directly within `std::io` and `std::os`. These "abstractions" are left largely the same as they were in `libnative` (except for the removal of `Arc` in file descriptors), but they are expected to evolve greatly over time. Organizationally, there are `sys/unix/` and `sys/windows/` directories which both implement the entire `sys` module hierarchy; this means that nearly all of the platform-specific code is isolated and you can get a handle on each platform in isolation.
* The `sys_common` module, which is rooted at `sys/common`, and provides a few pieces of private, low-level, but cross-platform functionality.
In the long term, the `sys` modules will provide hooks for exposing high-level platform-specific APIs as part of `libstd`. The first such API will be access to file descriptors from `std::io` abstractions, but a bit of design work remains before that step can be taken.
The `sys_common` module includes some traits (like `AsFileDesc`) which allow communication of private details between modules in disparate locations in the hierarchy; this helps overcome the relatively simple hierarchical privacy system in Rust.
To emphasize: the organization in `sys` is *very preliminary* and the main goal was to migrate away from `rtio` as quickly and simply as possible. The design will certainly evolve over time, and all of the details are currently private.
Along the way, this PR also entirely removes signal handling, since it was only supported on `librustuv` which was removed a while ago.
Because of the removal of APIs from `libnative` and `librustrt`, and the removal of signal handling, this is a:
[breaking-change]
Some of these APIs will return in public from from `std` over time.
r? @alexcrichton
This patch cleans up the remnants of the runtime IO interface.
Because this eliminates APIs in `libnative` and `librustrt`, it is a:
[breaking-change]
This functionality is likely to be available publicly, in some form,
from `std` in the future.
This patch continues runtime removal by moving the tty implementations
into `sys`.
Because this eliminates APIs in `libnative` and `librustrt`, it is a:
[breaking-change]
This functionality is likely to be available publicly, in some form,
from `std` in the future.
This patch continues runtime removal by moving out timer-related code
into `sys`.
Because this eliminates APIs in `libnative` and `librustrt`, it is a:
[breaking-change]
This functionality is likely to be available publicly, in some form,
from `std` in the future.
This patch continues the runtime removal by moving and refactoring the
process implementation into the new `sys` module.
Because this eliminates APIs in `libnative` and `librustrt`, it is a:
[breaking-change]
This functionality is likely to be available publicly, in some form,
from `std` in the future.
This patch continues the runtime removal by moving
libnative::io::helper_thread into sys::helper_signal and
sys_common::helper_thread
Because this eliminates APIs in `libnative` and `librustrt`, it is a:
[breaking-change]
This functionality is likely to be available publicly, in some form,
from `std` in the future.
This patch continues the runtime removal by moving pipe and
networking-related code into `sys`.
Because this eliminates APIs in `libnative` and `librustrt`, it is a:
[breaking-change]
This functionality is likely to be available publicly, in some form,
from `std` in the future.
This moves the filesystem implementation from libnative into the new
`sys` modules, refactoring along the way and hooking into `std::io::fs`.
Because this eliminates APIs in `libnative` and `librustrt`, it is a:
[breaking-change]
This functionality is likely to be available publicly, in some form,
from `std` in the future.
These modules will house the code that used to be part of the runtime system
in libnative. The `sys_common` module contains a few low-level but
cross-platform details. The `sys` module is set up using `#[cfg()]` to
include either a unix or windows implementation of a common API
surface. This API surface is *not* exported directly in `libstd`, but is
instead used to bulid `std::os` and `std::io`.
Ultimately, the low-level details in `sys` will be exposed in a
controlled way through a separate platform-specific surface, but that
setup is not part of this patch.
Various miscellaneous changes pushing towards HRTB support:
1. Update parser and adjust ast to support `for<'a,'b>` syntax, both in closures and trait bounds. Warn on the old syntax (not error, for stage0).
2. Refactor TyTrait representation to include a TraitRef.
3. Purge `once_fns` feature gate and `once` keyword.
r? @pcwalton
This is a [breaking-change]:
- The `once_fns` feature is now officially deprecated. Rewrite using normal closures or unboxed closures.
- The new `for`-based syntax now issues warnings (but not yet errors):
- `fn<'a>(T) -> U` becomes `for<'a> fn(T) -> U`
- `<'a> |T| -> U` becomes `for<'a> |T| -> U`
Previously Int inherited from PartialOrd (via Primitive)
but not Ord. But integers have a total order, so
inheriting from Ord is appropriate. Fixes#18776.
`FnOnce` environments that fit within an `int` are passed to the closure by value. For some reason there was an assert that this would only happen if there were 1 or 0 free variables, but it can also happen if there are multiple variables that happen to fit.
Closes#18652
Ensured that Extend & FromIterator are implemented for the libcollection.
Removed the fact that FromIterator had to be implemented in order to implement Extend, as it did not make sense for LruCache (it needs to be given a size and there are no Default for LruCache).
Changed the name from Extend to Extendable.
Part of #18424
When establishing region links within a pattern, use the mem-cat
of the type the pattern matches against (that is, the result
of `iter.next()`) rather than that of the iterator type.
Closes#17068Closes#18767
This commit implements processing these two attributes at the crate level as
well as at the item level. When #[cfg] is applied at the crate level, then the
entire crate will be omitted if the cfg doesn't match. The #[cfg_attr] attribute
is processed as usual in that the attribute is included or not depending on
whether the cfg matches.
This was spurred on by motivations of #18585 where #[cfg_attr] annotations will
be applied at the crate-level.
cc #18585