Skip to content

Commit 7dad295

Browse files
committed
Review comments
- Fix typo - Add docstring - Remove spurious test output file
1 parent c13a913 commit 7dad295

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

src/librustc/hir/map/mod.rs

+22
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,28 @@ impl<'hir> Map<'hir> {
632632
}
633633
}
634634

635+
/// Retrieve the NodeId for `id`'s enclosing method, unless there's a
636+
/// `while` or `loop` before reacing it, as block tail returns are not
637+
/// available in them.
638+
///
639+
/// ```
640+
/// fn foo(x: usize) -> bool {
641+
/// if x == 1 {
642+
/// true // `get_return_block` gets passed the `id` corresponding
643+
/// } else { // to this, it will return `foo`'s `NodeId`.
644+
/// false
645+
/// }
646+
/// }
647+
/// ```
648+
///
649+
/// ```
650+
/// fn foo(x: usize) -> bool {
651+
/// loop {
652+
/// true // `get_return_block` gets passed the `id` corresponding
653+
/// } // to this, it will return `None`.
654+
/// false
655+
/// }
656+
/// ```
635657
pub fn get_return_block(&self, id: NodeId) -> Option<NodeId> {
636658
let match_fn = |node: &Node| {
637659
match *node {

src/librustc_typeck/check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4214,7 +4214,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
42144214
ty
42154215
}
42164216

4217-
/// Given a `NodeId`, return the `FnDecl` of the method it is enclosed by and wether it is
4217+
/// Given a `NodeId`, return the `FnDecl` of the method it is enclosed by and whether it is
42184218
/// `fn main` if it is a method, `None` otherwise.
42194219
pub fn get_fn_decl(&self, blk_id: ast::NodeId) -> Option<(hir::FnDecl, bool)> {
42204220
// Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or
@@ -4227,7 +4227,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
42274227
}) = parent {
42284228
decl.clone().and_then(|decl| {
42294229
// This is less than ideal, it will not present the return type span on any
4230-
// method called `main`, regardless of wether it is actually the entry point.
4230+
// method called `main`, regardless of whether it is actually the entry point.
42314231
Some((decl, name == Symbol::intern("main")))
42324232
})
42334233
} else if let Node::NodeTraitItem(&hir::TraitItem {

src/test/ui/block-result/expected-return-on-unit.stderr

-4
This file was deleted.

0 commit comments

Comments
 (0)