Commit Graph

38010 Commits

Author SHA1 Message Date
Niko Matsakis 47f18659ff Update compile-fail tests to use the expected type to force the
closure kind, thereby detecting what happens if there are
mismatches. Simply removing the `:` annotations caused most of these
tests to pass or produce other errors, because the inference would
convert the closure into a more appropriate kind. (The ability to
override the inference by using the expected type is an important
backdoor partly for this reason.)
2015-02-03 11:55:46 -05:00
Niko Matsakis 498595a3dc Teach project to unify the return type even if a precise match is not
possible.  There is some amount of duplication as a result (similar to
select) -- I am not happy about this but not sure how to fix it
without deeper rewrites.
2015-02-03 11:55:45 -05:00
Niko Matsakis c9e1c445db Allow closure arguments types to unify even if we can't fully resolve
a trait obligation. Partial fix for #16440 -- closure return types are
not handled yet.
2015-02-03 11:55:45 -05:00
Björn Steinbrink 9a17f62947 Optimize rposition
The extra check caused by the expect() call can, in general, not be
optimized away, because the length of the iterator is unknown at compile
time, causing a noticable slow-down. Since the check only triggers if
the element isn't actually found in the iterator, i.e. it isn't
guaranteed to trigger for ill-behaved ExactSizeIterators, it seems
reasonable to switch to an implementation that doesn't need the check
and just always returns None if the value isn't found.

Benchmark:
````rust
let v: Vec<u8> = (0..1024*65).map(|_| 0).collect();
b.iter(|| {
    v.as_slice().iter().rposition(|&c| c == 1)
});
````

Before:
````
test rposition  ... bench:     49939 ns/iter (+/- 23)
````

After:
````
test rposition  ... bench:     33306 ns/iter (+/- 68)
````
2015-02-03 16:54:06 +01:00
bors 3b2ed14906 Auto merge of #21877 - dotdash:less_auto_deref, r=alexcrichton 2015-02-03 14:56:32 +00:00
Alexis 88449a8f79 add naivest entry API to VecMap 2015-02-03 09:36:07 -05:00
Valerii Hiora 3449751ff7 iOS: fixed build 2015-02-03 15:31:31 +02:00
bors 3d072a193b Auto merge of #21675 - huonw:less-false-positives, r=nikomatsakis
That is, when offering suggestions for unresolved method calls, avoid
suggesting traits for which implementing the trait for the receiver type
either makes little sense (e.g. type errors, or sugared unboxed
closures), or violates coherence.

The latter is approximated by ensuring that at least one of `{receiver
type, trait}` is local. This isn't precisely correct due to
multidispatch, but the error messages one encounters in such situation
are useless more often than not; it is better to be conservative and
miss some cases, than have overly many false positives (e.g. writing
`some_slice.map(|x| ...)` uselessly suggested that one should implement
`IteratorExt` for `&[T]`, while the correct fix is to call `.iter()`).

Closes #21420.
2015-02-03 12:49:21 +00:00
P1start d244f09911 Compute widths properly when displaying spans in error messages
Closes #8706.
2015-02-04 00:56:51 +13:00
Huon Wilson e81ae40770 Try to only suggest implementable traits for method calls.
That is, when offering suggestions for unresolved method calls, avoid
suggesting traits for which implementing the trait for the receiver type
either makes little sense (e.g. type errors, or sugared unboxed
closures), or violates coherence.

The latter is approximated by ensuring that at least one of `{receiver
type, trait}` is local. This isn't precisely correct due to
multidispatch, but the error messages one encounters in such situation
are useless more often than not; it is better to be conservative and
miss some cases, than have overly many false positives (e.g. writing
`some_slice.map(|x| ...)` uselessly suggested that one should implement
`IteratorExt` for `&[T]`, while the correct fix is to call `.iter()`).

Closes #21420.
2015-02-03 22:33:54 +11:00
bors cfc91090e9 Auto merge of #21745 - chris-morgan:add-missing-unstable-attributes, r=huonw
I’d kind of like to be able to use HashState in AnyMap, which I can’t do without a stability attribute on it. While I was at it I looked around and found a few more missing.
2015-02-03 10:40:33 +00:00
bors 336c8d2e9c Auto merge of #21613 - alfie:suffix-small, r=alexcrichton 2015-02-03 07:59:04 +00:00
Björn Steinbrink 1a56a1a515 Emit !nonnull metadata for loads of region and unique pointers
These pointers are never null, let's tell LLVM about it.
2015-02-03 08:55:04 +01:00
Alex Crichton b2297fd710 std: Add some missing stability attributes
* Display::fmt is stable
* Debug::fmt is stable
* FromIterator::from_iter is stable
* Peekable::peek is stable
2015-02-02 22:45:37 -08:00
bors 7858cb432d Auto merge of #21872 - alexcrichton:rollup, r=alexcrichton 2015-02-03 03:44:05 +00:00
Alex Crichton 9ece22ee00 Test fixes and rebase conflicts 2015-02-02 18:50:23 -08:00
Björn Steinbrink a3d2d35fcb Avoid extra ref/deref cycles when converting &T to *T 2015-02-03 01:22:09 +01:00
Alfie John 8f4844d58b More deprecating of i/u suffixes 2015-02-02 23:37:01 +00:00
Alex Crichton fea07cfd3f rollup merge of #21869: dotdash/bogus_match
The inner match will always result in `true`, so we can as well replace
it with just that.
2015-02-02 11:01:29 -08:00
Alex Crichton cd47cf906b rollup merge of #21865: steveklabnik/gh21501
Fixes #21501

r? @huonw
2015-02-02 11:01:26 -08:00
Alex Crichton 87eb67f4f0 rollup merge of #21854: alexcrichton/try-borrow
The existence of these two functions is at odds with our current [error
conventions][conventions] which recommend that panicking and `Result`-like
variants should not be provided together.

[conventions]: https://github.com/rust-lang/rfcs/blob/master/text/0236-error-conventions.md#do-not-provide-both-result-and-fail-variants

This commit adds a new `borrow_state` function returning a `BorrowState` enum to
`RefCell` which serves as a replacemnt for the `try_borrow` and `try_borrow_mut`
functions.
2015-02-02 11:01:23 -08:00
Alex Crichton 0a10e32a5e rollup merge of #21852: FreeFull/patch-1
Misspelling fix.
2015-02-02 11:01:21 -08:00
Alex Crichton 02c149deb9 rollup merge of #21849: alexcrichton/warn2note
There [have been reports][issue] of an unconditional warning causing tooling to
go awry. This isn't actually a warning per se, it's more of a note anyway!

[issue]: https://github.com/rust-lang/cargo/issues/1260

Closes rust-lang/cargo#1260
2015-02-02 11:01:19 -08:00
Alex Crichton b9e27433fa rollup merge of #21848: Manishearth/book-link
rollupable

r? @steveklabnik
2015-02-02 11:01:18 -08:00
Alex Crichton 3ef2df9e88 rollup merge of #21845: Potpourri/import-syntax
syntax like `use foo::bar::;` and `use foo:: as bar;` should be rejected, see issue #21629
2015-02-02 11:01:17 -08:00
Alex Crichton 99b2bd4bfa rollup merge of #21842: alexcrichton/issue-21839
Now that associated types are fully implemented the iterator adaptors only need
type parameters which are associated with actual storage. All other type
parameters can either be derived from these (e.g. they are an associated type)
or can be bare on the `impl` block itself.

This is a breaking change due to the removal of type parameters on these
iterator adaptors, but code can fairly easily migrate by just deleting the
relevant type parameters for each adaptor. Other behavior should not be
affected.

Closes #21839
[breaking-change]
2015-02-02 11:01:16 -08:00
Alex Crichton 747e6b53e4 rollup merge of #21832: genbattle/doc-unicode-escapes
Unicode escapes were changed in [this RFC](28aeb3c391/text/0446-es6-unicode-escapes.md) to use the ES6 \u{00FFFF} syntax with a variable number of digits from 1-6, eliminating the need for two different syntaxes for unicode literals.

I have updated The Reference and grammar.md to reflect these changes.
2015-02-02 11:01:15 -08:00
Alex Crichton 7335c7dd63 rollup merge of #21830: japaric/for-cleanup
Conflicts:
	src/librustc/metadata/filesearch.rs
	src/librustc_back/target/mod.rs
	src/libstd/os.rs
	src/libstd/sys/windows/os.rs
	src/libsyntax/ext/tt/macro_parser.rs
	src/libsyntax/print/pprust.rs
	src/test/compile-fail/issue-2149.rs
2015-02-02 11:01:12 -08:00
Alex Crichton 075588a493 rollup merge of #21825: kmcallister/ttdelim-span 2015-02-02 10:58:19 -08:00
Alex Crichton 10de0d9898 rollup merge of #21819: dsyang/doc_fix
as titled.  See issue #21770
2015-02-02 10:58:17 -08:00
Alex Crichton 04213ebd98 rollup merge of #21818: dotdash/llvm_up 2015-02-02 10:58:15 -08:00
Alex Crichton c64b73e520 rollup merge of #21817: edwardw/symmetric-binop
For "symmetric" binary operators, meaning the types of two sides must be
equal, if the type of LHS doesn't know yet but RHS does, use that as an
hint to infer LHS' type.

Closes #21634
2015-02-02 10:58:10 -08:00
Alex Crichton 22fdf97035 rollup merge of #21815: nagisa/overflowing-lints 2015-02-02 10:58:09 -08:00
Alex Crichton b0dee7b52a rollup merge of #21808: jfager/r20454
Closes #20454
2015-02-02 10:58:07 -08:00
Alex Crichton 85aba7575b rollup merge of #21803: madmalik/patch-1
http://doc.rust-lang.org/rustdoc.html states that its content was moved to http://doc.rust-lang.org/book/documentation.html
2015-02-02 10:58:06 -08:00
Alex Crichton 387722b304 rollup merge of #21800: brson/unused_features
When it was un*known*_features it was reasonable to be deny by default.

cc #21798

r? @alexcrichton
2015-02-02 10:58:05 -08:00
Alex Crichton 1641c32d83 rollup merge of #21794: alexcrichton/stabilize-atomic-usize
These methods were intended to be stable as of #16258 but the tags have since
been lost in various refactorings. This commit re-adds the `#[stable]`
attributes to each of these functions.
2015-02-02 10:58:04 -08:00
Alex Crichton 902abab144 rollup merge of #21787: alexcrichton/std-env
Conflicts:
	src/libstd/sys/unix/backtrace.rs
	src/libstd/sys/unix/os.rs
2015-02-02 10:58:01 -08:00
Alex Crichton 7b185f9cda rollup merge of #21782: alexcrichton/issue-21771
Previously if --extern was specified it would not override crates in the
standard distribution, leading to issues like #21771. This commit alters the
behavior such that if --extern is passed then it will always override any other
choice of crates and no previous match will be used (unless it is the same path
as --extern).

Closes #21771
2015-02-02 10:56:59 -08:00
Alex Crichton 425f2328d0 rollup merge of #21754: semarie/openbsd-rebased
Hi.

Here a commit in order to add OpenBSD support to rust.

- tests status:
run-pass: test result: ok. 1879 passed; 0 failed; 24 ignored; 0 measured
run-fail: test result: ok. 81 passed; 0 failed; 5 ignored; 0 measured
compile-fail: test result: ok. 1634 passed; 0 failed; 22 ignored; 0 measured
run-pass-fulldeps: test result: ok. 22 passed; 0 failed; 1 ignored; 0 measured
compile-fail-fulldeps: test result: ok. 13 passed; 0 failed; 0 ignored; 0 measured

- The current implementation of load_self function (src/libstd/sys/unix/os.rs) isn't optimal as under OpenBSD I haven't found a reliable method to get the filename of a running process. The current implementation is enought for bootstrapping purpose.

- I have disable `run-pass/tcp-stress.rs` test under openbsd. When run manually, the test pass, but when run under `compiletest`, it timeout and echo continuoulsy `Too many open files`.

- For building with jemalloc, a more recent version of jemalloc would be mandatory. See https://github.com/jemalloc/jemalloc/pull/188 for more details.
2015-02-02 10:56:57 -08:00
Alex Crichton 9529ab0e7e rollup merge of #21710: alfie/libsyntax
Conflicts:
	src/libsyntax/parse/parser.rs
2015-02-02 10:56:55 -08:00
Alex Crichton 8c468b69ae rollup merge of #21567: steveklabnik/doc_char 2015-02-02 10:56:11 -08:00
Alex Crichton 5e25d11ebf rollup merge of #21509: lucab/lucab/copyright-update
valgrind files moved and modpath.iss deleted. Both entries updated in
COPYRIGHT file.

Signed-off-by: Luca Bruno <lucab@debian.org>
2015-02-02 10:56:10 -08:00
Alex Crichton a392d9131e rollup merge of #21362: aochagavia/copy_rawptr
Fixes #21272 and #21296

r? @cmr
2015-02-02 10:56:07 -08:00
Alex Crichton ddcfb158fd rollup merge of #21223: P1start/expected-token-improvements
Fixes #21153.
2015-02-02 10:56:05 -08:00
Jorge Aparicio 3484706c38 remove unused mut qualifiers 2015-02-02 13:40:18 -05:00
Jorge Aparicio fd702702ee `for x in xs.into_iter()` -> `for x in xs`
Also `for x in option.into_iter()` -> `if let Some(x) = option`
2015-02-02 13:40:18 -05:00
Jorge Aparicio d5f61b4332 `for x in xs.iter_mut()` -> `for x in &mut xs`
Also `for x in option.iter_mut()` -> `if let Some(ref mut x) = option`
2015-02-02 13:40:18 -05:00
Jorge Aparicio d5d7e6565a `for x in xs.iter()` -> `for x in &xs` 2015-02-02 13:40:18 -05:00
Jorge Aparicio 9f90d666e0 impl IntoIterator for HashSet 2015-02-02 13:38:32 -05:00