{"action":"opened","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/26273","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/26273/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/26273/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/26273/events","html_url":"https://github.com/rust-lang/rust/issues/26273","id":88003561,"number":26273,"title":"Example code compile failed (macro 'try!')","user":{"login":"supernatural","id":2801700,"avatar_url":"https://avatars.githubusercontent.com/u/2801700?v=3","gravatar_id":"","url":"https://api.github.com/users/supernatural","html_url":"https://github.com/supernatural","followers_url":"https://api.github.com/users/supernatural/followers","following_url":"https://api.github.com/users/supernatural/following{/other_user}","gists_url":"https://api.github.com/users/supernatural/gists{/gist_id}","starred_url":"https://api.github.com/users/supernatural/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/supernatural/subscriptions","organizations_url":"https://api.github.com/users/supernatural/orgs","repos_url":"https://api.github.com/users/supernatural/repos","events_url":"https://api.github.com/users/supernatural/events{/privacy}","received_events_url":"https://api.github.com/users/supernatural/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-13T13:12:17Z","updated_at":"2015-06-13T13:12:17Z","closed_at":null,"body":"Linux x64, rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)\r\n\r\nWhen compiling examples on page http://doc.rust-lang.org/1.0.0/std/fs/struct.File.html , I got following errors:\r\nwork$ cargo build\r\n   Compiling test v0.1.0 \r\n<std macros>:5:8: 6:42 error: mismatched types:\r\n expected `()`,\r\n    found `core::result::Result<_, _>`\r\n(expected (),\r\n    found enum `core::result::Result`) [E0308]\r\n<std macros>:5 return $ crate:: result:: Result:: Err (\r\n<std macros>:6 $ crate:: convert:: From:: from ( err ) ) } } )\r\n<std macros>:1:1: 6:48 note: in expansion of try!\r\nsrc/main.rs:5:17: 5:46 note: expansion site\r\n<std macros>:5:8: 6:42 error: mismatched types:\r\n expected `()`,\r\n    found `core::result::Result<_, _>`\r\n(expected (),\r\n    found enum `core::result::Result`) [E0308]\r\n<std macros>:5 return $ crate:: result:: Result:: Err (\r\n<std macros>:6 $ crate:: convert:: From:: from ( err ) ) } } )\r\n<std macros>:1:1: 6:48 note: in expansion of try!\r\nsrc/main.rs:6:5: 6:41 note: expansion site\r\n<std macros>:5:8: 6:42 error: mismatched types:\r\n expected `()`,\r\n    found `core::result::Result<_, _>`\r\n(expected (),\r\n    found enum `core::result::Result`) [E0308]\r\n<std macros>:5 return $ crate:: result:: Result:: Err (\r\n<std macros>:6 $ crate:: convert:: From:: from ( err ) ) } } )\r\n<std macros>:1:1: 6:48 note: in expansion of try!\r\nsrc/main.rs:8:17: 8:44 note: expansion site\r\n<std macros>:5:8: 6:42 error: mismatched types:\r\n expected `()`,\r\n    found `core::result::Result<_, _>`\r\n(expected (),\r\n    found enum `core::result::Result`) [E0308]\r\n<std macros>:5 return $ crate:: result:: Result:: Err (\r\n<std macros>:6 $ crate:: convert:: From:: from ( err ) ) } } )\r\n<std macros>:1:1: 6:48 note: in expansion of try!\r\nsrc/main.rs:10:5: 10:36 note: expansion site\r\nerror: aborting due to 4 previous errors\r\nCould not compile `test`.\r\n\r\nSource code:\r\n\r\nuse std::io::prelude::*;\r\nuse std::fs::File;\r\n\r\nfn main() {\r\n    let mut f = try!(File::create(\"foo.txt\"));\r\n    try!(f.write_all(b\"Hello, world!\"));\r\n\r\n    let mut f = try!(File::open(\"foo.txt\"));\r\n    let mut s = String::new();\r\n    try!(f.read_to_string(&mut s));\r\n    assert_eq!(s, \"Hello, world!\");\r\n}\r\n\r\nIs the example wrong ?"}}