Commit Graph

42907 Commits

Author SHA1 Message Date
Isaac Ge
962816bc29 Update method-syntax.md
Fix wrong radius valve from 0.0 to 1.0 as above
2015-05-08 22:39:25 +08:00
Isaac Ge
544362c9b8 Update method-syntax.md
make the definition of static methods explicit
2015-05-08 22:30:00 +08:00
Felix S. Klock II
0fa1c1662f Fallout to compile-fail tests.
This change is worrisome to me, both because:

1. I thought the rules in RFC 599 imply that the `Box<Trait>` without `'static`
   in the first case would expand to the second case, but their behaviors
   here differ.  And,

2. The explicit handling of `'static` should mean `dropck` has no application
   here and thus we should have seen no change to the expected error messages.
   Nonetheless, the error messages changed.
2015-05-08 16:08:59 +02:00
Felix S. Klock II
d8d4bb4ce3 fallout to run-pass tests. 2015-05-08 15:39:25 +02:00
Felix S. Klock II
ccf12853d8 Regression tests for Issue 25199 (dropck and Box<Trait + 'a>). 2015-05-08 15:22:25 +02:00
Huon Wilson
091ba42d77 Add a reason to the libc & rand instability.
Many many many people ask in #rust about this libraries, having an
explanatory reason will probably help a lot.
2015-05-08 23:20:53 +10:00
Felix S. Klock II
b5b5a17758 dropck: must assume Box<Trait + 'a> has a destructor of interest.
Implements this (previously overlooked) note from [RFC 769]:

> (Note: When encountering a D of the form `Box<Trait+'b>`, we
> conservatively assume that such a type has a Drop implementation
> parametric in 'b.)

Fix #25199.

[breaking-change]

The breakage here falls into both obvious and non-obvious cases.

The obvious case: if you were relying on the unsoundness this exposes
(namely being able to reference dead storage from a destructor, by
doing it via a boxed trait object bounded by the lifetime of the dead
storage), then this change disallows that.

The non-obvious cases: The way dropck works, it causes lifetimes to be
extended to longer extents than they covered before. I.e.  lifetimes
that are attached as trait-bounds may become longer than they were
previously.

* This includes lifetimes that are only *implicitly* attached as
  trait-bounds (due to [RFC 599]). So you may have code that was
  e.g. taking a parameter of type `&'a Box<Trait>` (which expands to
  `&'a Box<Trait+'a>`), that now may need to be assigned type `&'a
  Box<Trait+'static>` to ensure that `'a` is not inadvertantly
  inferred to a region that is actually too long.  (See earlier commit
  in this PR for an example of this.)

[RFC 769]: https://github.com/rust-lang/rfcs/blob/master/text/0769-sound-generic-drop.md#the-drop-check-rule

[RFC 599]: https://github.com/rust-lang/rfcs/blob/master/text/0599-default-object-bound.md
2015-05-08 15:06:16 +02:00
Felix S. Klock II
ee06263f92 Fallout from fixing Issue 25199.
There are two interesting kinds of breakage illustrated here:

1. `Box<Trait>` in many contexts is treated as `Box<Trait + 'static>`,
   due to [RFC 599]. However, in a type like `&'a Box<Trait>`, the
   `Box<Trait>` type will be expanded to `Box<Trait + 'a>`, again due
   to [RFC 599]. This, combined with the fix to Issue 25199, leads to
   a borrowck problem due the combination of this function signature
   (in src/libstd/net/parser.rs):

   ```rust
   fn read_or<T>(&mut self, parsers: &mut [Box<FnMut(&mut Parser) -> Option<T>>]) -> Option<T>;
   ```

   with this call site (again in src/libstd/net/parser.rs):

   ```rust
   fn read_ip_addr(&mut self) -> Option<IpAddr> {
       let ipv4_addr = |p: &mut Parser| p.read_ipv4_addr().map(|v4| IpAddr::V4(v4));
       let ipv6_addr = |p: &mut Parser| p.read_ipv6_addr().map(|v6| IpAddr::V6(v6));
       self.read_or(&mut [Box::new(ipv4_addr), Box::new(ipv6_addr)])
   }
   ```

   yielding borrowck errors like:

   ```
   parser.rs:265:27: 265:69 error: borrowed value does not live long enough
   parser.rs:265         self.read_or(&mut [Box::new(ipv4_addr), Box::new(ipv6_addr)])
                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   ```

   (full log at: https://gist.github.com/pnkfelix/e2e80f1a71580f5d3103 )

   The issue here is perhaps subtle: the `parsers` argument is
   inferred to be taking a slice of boxed objects with the implicit
   lifetime bound attached to the `self` parameter to `read_or`.

   Meanwhile, the fix to Issue 25199 (added in a forth-coming commit)
   is forcing us to assume that each boxed object may have a
   destructor that could refer to state of that lifetime, and
   *therefore* that inferred lifetime is required to outlive the boxed
   object itself.

   In this case, the relevant boxed object here is not going to make
   any such references; I believe it is just an artifact of how the
   expression was built that it is not assigned type:

     `Box<FnMut(&mut Parser) -> Option<T> + 'static>`.

   (i.e., mucking with the expression is probably one way to fix this
   problem).

   But the other way to fix it, adopted here, is to change the
   `read_or` method type to force make the (presumably-intended)
   `'static` bound explicit on the boxed `FnMut` object.

   (Note: this is still just the *first* example of breakage.)

2. In `macro_rules.rs`, the `TTMacroExpander` trait defines a method
   with signature:

   ```rust
   fn expand<'cx>(&self, cx: &'cx mut ExtCtxt, ...) -> Box<MacResult+'cx>;
   ```

   taking a `&'cx mut ExtCtxt` as an argument and returning a
   `Box<MacResult'cx>`.

   The fix to Issue 25199 (added in aforementioned forth-coming
   commit) assumes that a value of type `Box<MacResult+'cx>` may, in
   its destructor, refer to a reference of lifetime `'cx`; thus the
   `'cx` lifetime is forced to outlive the returned value.

   Meanwhile, within `expand.rs`, the old code was doing:

   ```rust
   match expander.expand(fld.cx, ...).make_pat() { ... => immutable borrow of fld.cx ... }
   ```

   The problem is that the `'cx` lifetime, inferred for the
   `expander.expand` call, has now been extended so that it has to
   outlive the temporary R-value returned by `expanded.expand`.  But
   call is also reborrowing `fld.cx` *mutably*, which means that this
   reborrow must end before any immutable borrow of `fld.cx`; but
   there is one of those within the match body. (Note that the
   temporary R-values for the input expression to `match` all live as
   long as the whole `match` expression itself (see Issue #3511 and PR
   #11585).

   To address this, I moved the construction of the pat value into its
   own `let`-statement, so that the `Box<MacResult>` will only live
   for as long as the initializing expression for the `let`-statement,
   and thus allow the subsequent immutable borrow within the `match`.

[RFC 599]: https://github.com/rust-lang/rfcs/blob/master/text/0599-default-object-bound.md
2015-05-08 14:48:26 +02:00
Wei-Ming Yang
a4ec372a1e fixed a mistake 2015-05-08 20:44:11 +08:00
Chris Wong
939c53ea42 configure: display correct version for md5sum
The old code simply scanned for the first digit, then munched anything
after that. This didn't work for md5sum, as it would see the "5" and
treat "5sum" as the version instead.

This patch tweaks the algorithm so that it looks for a second
consecutive digit (or dot) after the first. Since "md5sum" has only one
digit, the new code skips over it as intended.
2015-05-08 22:52:02 +12:00
Chris Wong
535040aab8 Generate CFG_FILENAME_EXTRA from the version
The code takes a prefix of the MD5 hash of the version string.

Since the hash command differs across GNU and BSD platforms, we scan for
the right one in the configure script.

Closes #25007
2015-05-08 22:26:26 +12:00
Wojciech Ogrodowczyk
c65a1838cb Fix sort in AUTHORS.txt
Properly sorted, Ł goes between L and M.
2015-05-08 07:38:18 +02:00
Andrew Straw
391d14802e fix logic when describing kinds of borrows
If you have 0 references (`&T`) to a resource, presumably, you could
have a mutable reference (`&mut T`). So this only start to make sense
at having 1 reference to a resource.
2015-05-08 06:12:59 +02:00
bors
cf76e63745 Auto merge of #25136 - alexcrichton:drop-the-two, r=aturon
* Remove the 2-suffix from some modules
* Remove some unused files
* Remove double-boxing for `ReentrantMutex`
2015-05-08 01:32:59 +00:00
Alex Crichton
dd59b1fb4c std: Mark mem::forget as a safe function
This commit is an implementation of [RFC 1066][rfc] where the conclusion was
that leaking a value is a safe operation in Rust code, so updating the signature
of this function follows suit.

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1066-safe-mem-forget.md

Closes #25186
2015-05-07 17:25:04 -07:00
Simon Kern
60c0e75e74 fixed href for structs 2015-05-08 01:46:26 +02:00
Simon Kern
3e76f2838a v2 gets a copy of the pointer, not a copy of the data 2015-05-08 01:43:18 +02:00
bors
b402c43f08 Auto merge of #25123 - arielb1:self-inhibiting-error, r=nikomatsakis
Fix #25076.

r? @nikomatsakis
2015-05-07 23:40:55 +00:00
Carol Nichols
468cb052b8 Expand OS X versions referenced in configure message
10.10 is out, so it's weird to see a message that says you're on 10.9.
Change the message to be >=10.9.
2015-05-07 19:35:58 -04:00
Simon Kern
84c7dfa48c deleted unnecessary the 2015-05-08 00:59:45 +02:00
Simon Kern
2213898c19 two minor fixes 2015-05-08 00:42:10 +02:00
Tshepang Lekhonkhobe
7ef46e0dde doc: the prevailing convention is to use assert_eq! when 2 values are compared 2015-05-08 00:14:00 +02:00
bors
5ae026e892 Auto merge of #25157 - alexcrichton:remove-vec-add, r=aturon
Ideally this trait implementation would be unstable, requiring crates to opt-in
if they would like the functionality, but that's not currently how stability
works so the implementation needs to be removed entirely.

This may come back at a future date, but for now the conservative option is to
remove it.

[breaking-change]
2015-05-07 21:45:11 +00:00
Nick Hamann
11a7bad97b Add long diagnostic for E0054 2015-05-07 14:34:54 -05:00
Tincan
ae1b2f4bf3 Another typo 2015-05-07 21:31:10 +02:00
Ariel Ben-Yehuda
2a12e51dbd Select projections over impls in case of ambiguity. Fixes #23336. 2015-05-07 22:21:57 +03:00
Tincan
4d1e48e376 Typo in ownership.md 2015-05-07 20:23:47 +02:00
Nick Hamann
11cb5e50ab Add long diagnostic for E0046 2015-05-07 13:08:59 -05:00
bors
f0ac7e04e6 Auto merge of #24973 - roryokane:fix-minus-doc-buttons, r=alexcrichton
My change in #24797 had a bug, described in that issue’s comments, and first discovered in issue #24918. This fixes it.

I tested this new `main.js` by changing the `main.js` content of [a rendered docs page](https://doc.rust-lang.org/std/option/) to this new content. The ‘[−]’ button worked again.

I am also including another related fix, because it would require manual merging if I made a separate pull request for it. The page-global ‘[−]’ button currently adds `#` to the end of the URL whenever it is clicked. I am changing its `href` from `#` to `javascript:void(0)` (the same as the `href` for section-specific ‘[−]’ links) to fix that.
2015-05-07 17:19:33 +00:00
Alex Crichton
7529bd60c3 std: Remove a double-box in ReentrantMutex
Perform unsafe initialization up front and then only afterward the mutex is in
place do we initialize it.
2015-05-07 09:30:00 -07:00
Alex Crichton
a031325e83 std: Remove unused helper_thread.rs file
This module has been removed for quite some time!
2015-05-07 09:30:00 -07:00
Alex Crichton
377b1adc36 std: Rename sys::foo2 modules to sys::foo
Now that `std::old_io` has been removed for quite some time the naming real
estate here has opened up to allow these modules to move back to their proper
names.
2015-05-07 09:30:00 -07:00
bors
a39d4fc684 Auto merge of #25013 - pnkfelix:span_to_lines-oflo, r=huonw
Guard against overflow in `codemap::span_to_lines`.

(Revised/expanded version of PR #24976)

Make `span_to_lines` to return a `Result`.

In `diagnostic`, catch `Err` from `span_to_lines` and print `"(unprintable span)"` instead.

----

There a number of recent issues that report the bug here.  See e.g. #24761 and #24954.

This change *might* fix them. However, that is *not* its main goal. The main goals are:

 1. Make it possible for callers to recover from an error here, and

 2. Insert a more conservative check, in that we are also checking that the files match up.

----

As a drive-by, fix #24997 , which was causing my attempts to `make check-stage1` on an `--enable-debug` build to fail.
2015-05-07 15:25:09 +00:00
Ben Gesoff
888086d959 Undid changes involving misunderstanding of 0.3.x
Didn't realise 0.3.0 referred to all 0.3.x versions! Fixed my mistakes. Should have just updated the Cargo.toml now.
2015-05-07 15:36:47 +01:00
Steve Klabnik
07499918b3 Fix incorrect curly quotes 2015-05-07 10:26:00 -04:00
Ben Gesoff
0bc6fe5ea0 Refactor to keep rand version 0.3.0
changed paragraphs with discussion of Cargo.lock file to agree with rand version 0.3.0 in the Cargo.tom file.
2015-05-07 14:48:44 +01:00
bors
05d5fcaa5b Auto merge of #25161 - jooert:moretests, r=alexcrichton
The last one (at least for the moment 😃).

r? @alexcrichton
2015-05-07 13:33:33 +00:00
Ben Gesoff
7150d3cd9e Change rand version to '*'
Following paragraph says "we've used `*` which..." but code says "rand=\"0.3.0\""
2015-05-07 14:23:05 +01:00
Ariel Ben-Yehuda
ea3747902c fix test 2015-05-07 16:19:43 +03:00
bors
acb3aa0949 Auto merge of #25175 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #24576, #24966, #25052, #25131, #25137, #25138, #25139, #25141, #25142, #25144, #25146, #25148, #25154, #25156, #25160, #25173
- Failed merges:
2015-05-07 10:21:19 +00:00
Steve Klabnik
5ac5203e6e Rollup merge of #25173 - andreastt:guessing_game_syntax_fix, r=steveklabnik 2015-05-07 12:21:05 +02:00
Steve Klabnik
0084ba934d Rollup merge of #25160 - michaelwu:remove-schedule_free_slice, r=cmr
Nothing uses it anymore.
2015-05-07 12:21:05 +02:00
Steve Klabnik
464077d0a7 Rollup merge of #25156 - rydotyosh:patch-4, r=alexcrichton
Remove printing of secret number at final source.
2015-05-07 12:21:04 +02:00
Steve Klabnik
6db57a2dcb Rollup merge of #25154 - rydotyosh:patch-3, r=steveklabnik
Edit version of #25150.
This commit depends on #25148.
2015-05-07 12:21:04 +02:00
Steve Klabnik
414e37f3d4 Rollup merge of #25148 - banks:master, r=steveklabnik
Let me know if I didn't follow correct procedure - seems a trivial change and no one that can be automatically tested.
2015-05-07 12:21:04 +02:00
Steve Klabnik
48b67f04bf Rollup merge of #25146 - piatra:doc-search-patch, r=steveklabnik
I noticed this feature added in https://github.com/rust-lang/rust/pull/23289 was missing from the `Search tricks`. Thanks!

r? @steveklabnik
2015-05-07 12:21:04 +02:00
Steve Klabnik
0d347e1620 Rollup merge of #25144 - killercup:docs/iter-fold-reduce, r=steveklabnik
Enhance Google-ability of `.fold()` by mentioning 'reduce' and 'inject' in the docs.

Motivation: [This thread on users.rust-lang.org](https://users.rust-lang.org/t/find-the-shortest-string-in-a-vector/1247)
2015-05-07 12:21:03 +02:00
Steve Klabnik
1d3183929a Rollup merge of #25142 - rydotyosh:patch-1, r=alexcrichton 2015-05-07 12:21:03 +02:00
Steve Klabnik
0ad94ae126 Rollup merge of #25141 - steveklabnik:fix_guessing_game, r=huonw
https://github.com/rust-lang/rust/pull/25080/files#r29634986

r? @huonw
2015-05-07 12:21:03 +02:00
Steve Klabnik
888c12ccbb Rollup merge of #25139 - hibariya:fix-indentation, r=alexcrichton 2015-05-07 12:21:03 +02:00