{"action":"created","issue":{"url":"https://api.github.com/repos/Manishearth/rust-clippy/issues/834","repository_url":"https://api.github.com/repos/Manishearth/rust-clippy","labels_url":"https://api.github.com/repos/Manishearth/rust-clippy/issues/834/labels{/name}","comments_url":"https://api.github.com/repos/Manishearth/rust-clippy/issues/834/comments","events_url":"https://api.github.com/repos/Manishearth/rust-clippy/issues/834/events","html_url":"https://github.com/Manishearth/rust-clippy/issues/834","id":145580903,"number":834,"title":"False positive on let_and_return","user":{"login":"Zoxc","id":25784,"avatar_url":"https://avatars.githubusercontent.com/u/25784?v=3","gravatar_id":"","url":"https://api.github.com/users/Zoxc","html_url":"https://github.com/Zoxc","followers_url":"https://api.github.com/users/Zoxc/followers","following_url":"https://api.github.com/users/Zoxc/following{/other_user}","gists_url":"https://api.github.com/users/Zoxc/gists{/gist_id}","starred_url":"https://api.github.com/users/Zoxc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zoxc/subscriptions","organizations_url":"https://api.github.com/users/Zoxc/orgs","repos_url":"https://api.github.com/users/Zoxc/repos","events_url":"https://api.github.com/users/Zoxc/events{/privacy}","received_events_url":"https://api.github.com/users/Zoxc/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-04T04:27:26Z","updated_at":"2016-04-04T04:44:50Z","closed_at":"2016-04-04T04:44:50Z","body":"In the following function, I allocate some memory and then forget that the allocation happened, making the result `'static`. I cannot forget `view` while `mapped` is around, so I have to use `mapped` to make the result and then forget `view`.\r\n```\r\npub unsafe fn static_map(base: Addr, size: usize) -> &'static mut [u8] {\r\n\tlet mut view = PhysicalView::new();\r\n\tlet mapped = view.map(base, size, memory::RW_DATA_FLAGS);\r\n\tlet result = slice::from_raw_parts_mut(mapped.as_ptr(), mapped.len());\r\n\tmem::forget(view);\r\n\tresult\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/Manishearth/rust-clippy/issues/comments/205134158","html_url":"https://github.com/Manishearth/rust-clippy/issues/834#issuecomment-205134158","issue_url":"https://api.github.com/repos/Manishearth/rust-clippy/issues/834","id":205134158,"user":{"login":"Zoxc","id":25784,"avatar_url":"https://avatars.githubusercontent.com/u/25784?v=3","gravatar_id":"","url":"https://api.github.com/users/Zoxc","html_url":"https://github.com/Zoxc","followers_url":"https://api.github.com/users/Zoxc/followers","following_url":"https://api.github.com/users/Zoxc/following{/other_user}","gists_url":"https://api.github.com/users/Zoxc/gists{/gist_id}","starred_url":"https://api.github.com/users/Zoxc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zoxc/subscriptions","organizations_url":"https://api.github.com/users/Zoxc/orgs","repos_url":"https://api.github.com/users/Zoxc/repos","events_url":"https://api.github.com/users/Zoxc/events{/privacy}","received_events_url":"https://api.github.com/users/Zoxc/received_events","type":"User","site_admin":false},"created_at":"2016-04-04T04:44:50Z","updated_at":"2016-04-04T04:44:50Z","body":"Actually my code didn't compile and I needed to put the `mapped` binding into it's own block, which made the warning go away."}}