Commit Graph

43971 Commits

Author SHA1 Message Date
bors fdf219dd42 Auto merge of #26663 - Eljay:fix-repr-attribute, r=sanxiyn
Fixes #26646.

Loops over all `#[repr(..)]` attributes instead of stopping at the first one to make sure they are all marked as used. Previously it stopped after the first `#[repr(C)]` was found causing all other attributes to be skipped by the linter.
2015-06-30 20:07:18 +00:00
bors 7fc0675f35 Auto merge of #26327 - bluss:two-way, r=aturon
Update substring search to use the Two Way algorithm

To improve our substring search performance, revive the two way searcher
and adapt it to the Pattern API.

Fixes #25483, a performance bug: that particular case now completes faster
in optimized rust than in ruby (but they share the same order of magnitude).

Many thanks to @gereeter who helped me understand the reverse case
better and wrote the comment explaining `next_back` in the code.

I had quickcheck to fuzz test forward and reverse searching thoroughly.

The two way searcher implements both forward and reverse search,
but not double ended search. The forward and reverse parts of the two
way searcher are completely independent.

The two way searcher algorithm has very small, constant space overhead,
requiring no dynamic allocation. Our implementation is relatively fast,
especially due to the `byteset` addition to the algorithm, which speeds
up many no-match cases.

A bad case for the two way algorithm is:

```
let haystack = (0..10_000).map(|_| "dac").collect::<String>();
let needle = (0..100).map(|_| "bac").collect::<String>());
```

For this particular case, two way is not much faster than the naive
implementation it replaces.
2015-06-30 18:09:51 +00:00
bors 85361528bc Auto merge of #26669 - frewsxcv:diagnostics-https, r=huonw
None
2015-06-30 15:13:05 +00:00
bors 0b703787ab Auto merge of #26664 - steveklabnik:gh26571, r=alexcrichton
This was pretty misleading, so let's improve.

Fixes #26571
2015-06-30 12:54:16 +00:00
bors f39df49bcd Auto merge of #26662 - steveklabnik:gh26661, r=alexcrichton
This is his own mirror, so it shouldn't go down, unlike the previous one.

Fixes #26661
2015-06-30 10:26:09 +00:00
bors 080d5b74dd Auto merge of #26670 - frewsxcv:regression-test-13902, r=alexcrichton
Closes #13902
2015-06-30 08:04:11 +00:00
bors e6596d0052 Auto merge of #26668 - frewsxcv:regression-test-17756, r=alexcrichton
Closes #17756
2015-06-30 03:18:45 +00:00
bors 27975c49a6 Auto merge of #26667 - arielb1:audit-walk, r=eddyb
This was originally motivated by checking for HRTB hygiene, but I found several other bugs on the way.

This does not fix the biggest user of ty_walk, which is dtorck - I would prefer to coordinate that with @pnkfelix.

r? @eddyb
2015-06-30 01:45:46 +00:00
Corey Farwell 6419acee34 Add regression test for #13902
Closes #13902
2015-06-29 17:28:21 -07:00
Corey Farwell e834c0348f Link to docs from error explanations via HTTPS 2015-06-29 17:23:02 -07:00
bors faa04a8b9c Auto merge of #26666 - huonw:unc-rec, r=alexcrichton
This fixes two false positives for the unconditional recursion lint, when functions use themselves (or almost-themselves) internally, without actually being recursive.

````rust
fn main() { let _ = main; }
```
```rust
trait Bar {
    fn method<T: Bar>(&self, x: &T) {
        x.method(x)
    }
}
```
2015-06-30 00:14:32 +00:00
Corey Farwell d8680f6534 Add regression test for #17756
Closes #17756
2015-06-29 17:10:53 -07:00
Ariel Ben-Yehuda fb5dd398f6 Remove now-useless code 2015-06-30 02:31:07 +03:00
Ariel Ben-Yehuda a5e21daa19 Kill count_late_bound_regions
No, it didn't show up in my profiler. It still needs to die.
2015-06-30 02:24:46 +03:00
Huon Wilson 900af2c6d9 lint: default methods must be called on Self to unconditionally recur.
This catches the case when a trait defines a default method that calls
itself, but on a type that isn't necessarily `Self`, e.g. there's no
reason that `T = Self` in the following, so the call isn't necessarily
recursive (`T` may override the call).

    trait Bar {
        fn method<T: Bar>(&self, x: &T) {
            x.method(x)
        }
    }

Fixes #26333.
2015-06-29 16:00:54 -07:00
Huon Wilson b1931e48a0 lint: only consider actual calls as unconditional recursion.
Specifically, just mentioning the function name as a value is fine, as
long as it isn't called, e.g. `fn main() { let _ = main; }`.

Closes #21705.
2015-06-29 15:59:37 -07:00
Ariel Ben-Yehuda 336f81215e Remove type_needs_unwind_cleanup
After the last @dinosaur went extinct, the check became redundant with
type_needs_drop, except for its bugginess.

Fixes #26655.
2015-06-30 01:34:17 +03:00
Ariel Ben-Yehuda bf164bc6e3 Fix lifetime elision region accounting
This merges accumulate_regions_in_type with ty_fold::collect_regions.
Fixes #26638
2015-06-30 01:33:16 +03:00
bors 9a26e49459 Auto merge of #26660 - steveklabnik:fix_up_pointers, r=alexcrichton
This is a bit outdated.
2015-06-29 22:22:54 +00:00
Steve Klabnik b1907a04e4 Update link to Ousterhout
This is his own mirror, so it shouldn't go down, unlike the previous one.

Fixes #26661
2015-06-29 17:06:23 -04:00
Steve Klabnik f758baa524 Improve doc for std::mem::drop
This was pretty misleading, so let's improve.

Fixes #26571
2015-06-29 17:03:14 -04:00
bors fe283b4067 Auto merge of #26659 - nagisa:cas-docs, r=alexcrichton
Namely:

* Change parameter `old` to read `current` so it is clearer what the argument refers to (originally
   suggested `expected`, but shot down by Steve);
* Add some formatting and fix some mistakes like referring to the method as `swap` rather than
  `compare_and_swap`.
2015-06-29 20:50:41 +00:00
Eljay e8fe55f453 Add missing trailing newline. 2015-06-29 21:49:15 +01:00
Eljay 58ff6cc668 Add test for #26646. 2015-06-29 21:27:10 +01:00
Simonas Kazlauskas 08b21661c3 Refine Atomic*::compare_and_swap documentation
Namely:

* Change parameter `old` to read `current` so it is clearer what the argument refers to (originally
    suggested `expected`, but shot down by Steve);
* Add some formatting and fix some mistakes like referring to the method as `swap` rather than
  `compare_and_swap`.
2015-06-29 23:18:08 +03:00
Lee Jeffery b676e99b60 Fix incorrect warning about unused repr attributes. 2015-06-29 20:40:18 +01:00
bors f9b6929f46 Auto merge of #26623 - Saser:master, r=steveklabnik
In Chapter 5.9 (References and Borrowing), there is an example [at the very end](https://doc.rust-lang.org/stable/book/references-and-borrowing.html#use-after-free) which shows that declaring a reference before declaring the variable that it points to results in a compilation error. The book does not really mention why this happens though -- in the sections before, it has described how different scopes affects the lifetime of resources, but there is no mention of how resources within the same scope work.

This confused me a little, so I asked on #rust and got the answer that the resources are destroyed in the reverse order that they are declared, but the book makes no mention of it (as far as I can find) -- except in Chapter 5.21 (Drop), where it says:

> When `x` goes out of scope at the end of `main()`, the code for `Drop` will run. `Drop` has one method, which is also called `drop()`. It takes a mutable reference to `self`.
> 
> That’s it! The mechanics of `Drop` are very simple, but there are some subtleties. For example, values are dropped in the opposite order they are declared. [...]

---

I feel like Chapter 5.9 (References and Borrowing) is probably the best place to put this information (as I have done in my additions), since it deals with other types of referencing and borrowing. However, since English is not my native language, the wording of my additions perhaps are a little "off" -- any feedback on them is appreciated.
2015-06-29 19:19:31 +00:00
Steve Klabnik 8d6b5689fb Change removal notice for pointer guide.
This is a bit outdated.
2015-06-29 15:18:00 -04:00
Ariel Ben-Yehuda a1110bc3a3 Fix off-by-one error in default-type-parameter checking
Fixes #18183
2015-06-29 21:27:33 +03:00
bors 34f35a535a Auto merge of #26530 - steveklabnik:gh26471, r=alexcrichton
Fixes #26471

r? @alexcrichton
2015-06-29 17:44:56 +00:00
bors 216f6645ef Auto merge of #26462 - brson:stdidx, r=steveklabnik
This is usually the link I want when I come to this page.

r? @steveklabnik
2015-06-29 15:46:35 +00:00
Steve Klabnik b4f3c5878f Hide the Rand trait from docs
Fixes #26471
2015-06-29 08:08:59 -07:00
bors 40db46c6ba Auto merge of #26649 - Manishearth:rollup, r=Manishearth
- Successful merges: #26593, #26644, #26645
- Failed merges:
2015-06-29 08:29:54 +00:00
Manish Goregaokar 08a8ee19fb Rollup merge of #26645 - richo:makefile-typo, r=sfackler 2015-06-29 13:59:34 +05:30
Manish Goregaokar 1659075b4a Rollup merge of #26644 - pelmers:make_stage_tip, r=sfackler
I keep forgetting the command to do partial stage1 compile, so I think it would be helpful to add it into `make tips`.
2015-06-29 13:59:33 +05:30
Manish Goregaokar 4adcc78e00 Rollup merge of #26593 - GuillaumeGomez:patch-2, r=Manishearth
Part of #24407.
cc @michaelsproul
2015-06-29 13:59:33 +05:30
Guillaume Gomez 7f830a874c The come back of the "a" eaten by the void 2015-06-29 10:21:39 +02:00
Guillaume Gomez b442530671 Add more details in error explanation 2015-06-29 10:03:02 +02:00
Guillaume Gomez 14e3d26b8a Add E0110 error explanation 2015-06-29 07:36:59 +02:00
Richo Healey f07b11d07e mk: Fix a typo in the tips 2015-06-28 19:05:09 -07:00
Peter Elmers 9b6fe6ca36 Add tip to do partial compile. 2015-06-28 18:49:22 -07:00
bors a973e4cda5 Auto merge of #26582 - jroesch:infer-ctxt-refactor, r=nikomatsakis
This branch begins the work of unifying our type checking contexts into a single piece of state. The goal is to eventually have a single context that we can pass around instead of the fractured situation we currently have. There are still several things that must be done before beginning to make tables item local:

- [ ] move FulfillmentContext into InferCtxt
- [ ] modify SelectionContext to only take a single context argument
- [ ] remove remaining typer impls 
- [ ] remove the ClosureTyper + Typer trait
- [ ] do some renaming to make these things more applicable to their new roles

r? @nikomatsakis 

As a side note there are a couple oddities that are temporary refactors that will be quickly cleaned up in a follow-up PR.

cc @eddyb @Aatch @arielb1 @nrc
2015-06-29 00:03:37 +00:00
bors 2671e8cee0 Auto merge of #26642 - remram44:doc-openoptions-missing-write, r=alexcrichton
Setting append without write doesn't give you a writeable file. Showing it as an example in the docs is confusing at best ([reddit](https://www.reddit.com/r/rust/comments/3bbz8w/why_is_writing_a_file_not_working_for_me/))

Using truncate (O_TRUNC) on a read-only file is an error on POSIX systems ("unspecified"). Note however that using create (O_CREAT) with read-only flags is fine.

Related: #26103 (which IMHO is wrong; saying "append is different than write" when should simply be "append needs write". My vote is to make append imply write)
2015-06-28 21:37:07 +00:00
Remi Rampin 78ec055a14 Add `.write(true)` to append and truncate examples
Setting append without write doesn't give you a writeable file. Showing
it as an example in the docs is confusing at best.

Using truncate on a read-only file is an error on POSIX systems (note
however that using create with read-only flags is fine).
2015-06-28 17:26:31 -04:00
Jared Roesch 5c3753f6b4 Fix librustc_driver/test.rs 2015-06-28 14:08:50 -07:00
bors c1b8bd2d6f Auto merge of #26631 - richo:comment-updates, r=steveklabnik
I've attempted to lurk these into a few PRs since they're tiny, but those PR's haven't landed so here they are.

r? @steveklabnik
2015-06-28 06:35:30 +00:00
bors 5da0d415b6 Auto merge of #26601 - alexcrichton:xp, r=brson
This series of commits (currently rebased on https://github.com/rust-lang/rust/pull/26569 to avoid conflicts) adds support for the standard library to run on Windows XP. The main motivation behind this PR is that to enable any Rust code in Firefox we need to support Windows XP.

This PR doesn't yet intend to be a move to make Windows XP an officially supported platform, but instead simply get Rust code running on it. APIs like condition variables and RWLocks will immediately panic currently on XP, and it's unclear if that story wants to change much. Additionally, we may bind APIs like IOCP which aren't available on XP and would be *very* difficult to provide a fallback implementation. Essentially this PR enables running Rust on XP, but you still have to be careful to avoid non-XP portions of the standard library.

The major components of this PR are:

* Support for a new `i686-pc-windows-msvc` triple. This primarily involves a lot of build system hackery, but there are also a number of floating point functions which had to get switched up a bit.
* All APIs not available on Windows are now accessed through our dynamic-detection mechanism
* Mutexes on Windows were rewritten to use SRWLOCK as an optimization but can fall back to CRITICAL_SECTION.
2015-06-28 03:57:07 +00:00
Jared Roesch 15bc4a30c3 Address nits 2015-06-27 19:52:25 -07:00
Alex Crichton 10b103af48 std: Fix Windows XP compatibility
This commit enables executables linked against the standard library to run on
Windows XP. There are two main components of this commit:

* APIs not available on XP are shimmed to have a fallback implementation and use
  runtime detection to determine if they are available.
* Mutexes on Windows were reimplemented to use critical sections on XP where
  rwlocks are not available.

The APIs which are not available on XP are:

* SetFileInformationByHandle - this is just used by `File::truncate` and that
  function just returns an error now.
* SetThreadStackGuarantee - this is used by the stack overflow support on
  windows, but if this isn't available then it's just ignored (it seems
  non-critical).
* All condition variable APIs are missing - the shims added for these apis
  simply always panic for now. We may eventually provide a fallback
  implementation, but for now the standard library does not rely on condition
  variables for normal use.
* RWLocks, like condition variables, are missing entirely. The same story for
  condition variables is taken here. These APIs are all now panicking stubs as
  the standard library doesn't rely on RWLocks for normal use.

Currently, as an optimization, we use SRWLOCKs for the standard `sync::Mutex`
implementation on Windows, which is indeed required for normal operation of the
standard library. To allow the standard library to run on XP, this commit
reimplements mutexes on Windows to use SRWLOCK instances *if available* and
otherwise a CriticalSection is used (with some checking for recursive
locking).

With all these changes put together, a 32-bit MSVC-built executable can run on
Windows XP and print "hello world"

Closes #12842
Closes #19992
Closes #24776
2015-06-27 19:45:24 -07:00
Richo Healey 9e58fb85ef rt: Update comment for new location of unwind 2015-06-27 19:25:55 -07:00