File tree Expand file tree Collapse file tree 5 files changed +46
-6
lines changed
librustc/middle/typeck/check Expand file tree Collapse file tree 5 files changed +46
-6
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
5
5
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
- refs/heads/try2: 5bb9bd2d346c5921d35da5e743d1f20534b2b4d7
8
+ refs/heads/try2: ffe72e95368aba02d002be0095522548e8f0ee79
9
9
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
10
10
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
11
11
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
Original file line number Diff line number Diff line change @@ -2317,11 +2317,13 @@ fn check_expr_with_unifier(fcx: @FnCtxt,
2317
2317
fcx. type_error_message(
2318
2318
expr. span,
2319
2319
|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 `{}`" ,
2322
2321
token:: get_name( field) , actual)
2323
2322
} ,
2324
2323
expr_t, None ) ;
2324
+
2325
+ tcx. sess. span_note( expr. span,
2326
+ "maybe a missing `()` to call it? If not, try an anonymous function." ) ;
2325
2327
}
2326
2328
2327
2329
None => {
Original file line number Diff line number Diff line change @@ -311,10 +311,10 @@ impl<T> Option<T> {
311
311
/// Fails if the value equals `None`.
312
312
#[ inline]
313
313
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" )
316
317
}
317
- self . take ( ) . unwrap ( )
318
318
}
319
319
320
320
/// Gets an immutable reference to the value inside an option.
Original file line number Diff line number Diff line change
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
+
Original file line number Diff line number Diff line change 13
13
// ignore-android needs extra network permissions
14
14
// exec-env:RUST_LOG=debug
15
15
16
+ #[ feature( phase) ] ;
17
+ #[ phase( syntax, link) ]
18
+ extern crate log;
19
+
16
20
use std:: libc;
17
21
use std:: io:: net:: ip:: { Ipv4Addr , SocketAddr } ;
18
22
use std:: io:: net:: tcp:: { TcpListener , TcpStream } ;
You can’t perform that action at this time.
0 commit comments