Skip to content

Commit 4abfb38

Browse files
committed
---
yaml --- r: 106020 b: refs/heads/auto c: ffe72e9 h: refs/heads/master v: v3
1 parent d9e85ac commit 4abfb38

File tree

5 files changed

+46
-6
lines changed

5 files changed

+46
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 5bb9bd2d346c5921d35da5e743d1f20534b2b4d7
16+
refs/heads/auto: ffe72e95368aba02d002be0095522548e8f0ee79
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc/middle/typeck/check/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2317,11 +2317,13 @@ fn check_expr_with_unifier(fcx: @FnCtxt,
23172317
fcx.type_error_message(
23182318
expr.span,
23192319
|actual| {
2320-
format!("attempted to take value of method `{}` on type `{}` \
2321-
(try writing an anonymous function)",
2320+
format!("attempted to take value of method `{}` on type `{}`",
23222321
token::get_name(field), actual)
23232322
},
23242323
expr_t, None);
2324+
2325+
tcx.sess.span_note(expr.span,
2326+
"maybe a missing `()` to call it? If not, try an anonymous function.");
23252327
}
23262328

23272329
None => {

branches/auto/src/libstd/option.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,10 @@ impl<T> Option<T> {
311311
/// Fails if the value equals `None`.
312312
#[inline]
313313
pub fn take_unwrap(&mut self) -> T {
314-
if self.is_none() {
315-
fail!("called `Option::take_unwrap()` on a `None` value")
314+
match self.take() {
315+
Some(x) => x,
316+
None => fail!("called `Option::take_unwrap()` on a `None` value")
316317
}
317-
self.take().unwrap()
318318
}
319319

320320
/// Gets an immutable reference to the value inside an option.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Tests to make sure that parens are needed for method calls without arguments.
12+
// outputs text to make sure either an anonymous function is provided or
13+
// open-close '()' parens are given
14+
15+
16+
struct Point {
17+
x: int,
18+
y: int
19+
}
20+
impl Point {
21+
fn new() -> Point {
22+
Point{x:0, y:0}
23+
}
24+
fn get_x(&self) -> int {
25+
self.x
26+
}
27+
}
28+
29+
fn main() {
30+
let point: Point = Point::new();
31+
let px: int = point.get_x;//~ ERROR attempted to take value of method `get_x` on type `Point`
32+
//~^ NOTE maybe a missing `()` to call it? If not, try an anonymous function.
33+
}
34+

branches/auto/src/test/run-pass/tcp-stress.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
// ignore-android needs extra network permissions
1414
// exec-env:RUST_LOG=debug
1515

16+
#[feature(phase)];
17+
#[phase(syntax, link)]
18+
extern crate log;
19+
1620
use std::libc;
1721
use std::io::net::ip::{Ipv4Addr, SocketAddr};
1822
use std::io::net::tcp::{TcpListener, TcpStream};

0 commit comments

Comments
 (0)