Repository: rust
Issue: Line numbers in error messages?
Labels: A-diagnostics,T-compiler,C-bug

(Caveat: Experienced coder, rust novice.)

I tried running `cargo build` on this `lib.rs` file (very slightly modified from what's in the beta version of the book rewrite):

```
mod outermost { // private but parent module can see it
    pub fn middle_function() {} // public, accessed through outmost, so visible

    fn middle_secret_function() {} // private, visible only here or in child mod

    mod inside {		// private
        pub fn inner_function() {
	    // Leading :: means start with root module for this library
	    // msf visible to "child module of module containing the function"
	    ::outermost::middle_secret_function(); // should work
	} 

	mod innermost {
	  pub fn inner_function() {
	    // The rule really does seem to be child, not descendant...?
	    ::outermost::middle_secret_function(); // should err if child only
	  }
	}

        fn secret_function() {}
    }
}

fn try_me() {	// In root module
    outermost::middle_function(); // should work
    
    // compilation error expected; root is neither current or child of outermost
    outermost::middle_secret_function(); // should err

    // error expected; non-public module inside.
    outermost::inside::inner_function(); // should err
    // error expected; non-public module AND function.
    outermost::inside::secret_function(); // should err
}
```

I expected to see errors reported on lines 28, 31, and 33 (the ones marked `// should err`)

Instead, the errors seem to be being reported on lines 17, 20, and 21, assuming I'm understanding your error syntax correctly:
```
Compiling sample_library v0.1.0 (C:\Users\keshlam\rust\sample_library)
error[E0603]: function `middle_secret_function` is private
  --> src\lib.rs:17:16
   |
17 |     outermost::middle_secret_function();
   |                ^^^^^^^^^^^^^^^^^^^^^^ private function
   |
note: the function `middle_secret_function` is defined here
  --> src\lib.rs:4:5
   |
4  |     fn middle_secret_function() {} // private, visible only here or in child mod
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0603]: module `inside` is private
  --> src\lib.rs:20:16
   |
20 |     outermost::inside::inner_function();
   |                ^^^^^^ private module
   |
note: the module `inside` is defined here
  --> src\lib.rs:6:5
   |
6  |     mod inside {        // private
   |     ^^^^^^^^^^

error[E0603]: module `inside` is private
  --> src\lib.rs:21:16
   |
21 |     outermost::inside::secret_function();
   |                ^^^^^^ private module
   |
note: the module `inside` is defined here
  --> src\lib.rs:6:5
   |
6  |     mod inside {        // private
   |     ^^^^^^^^^^

For more information about this error, try `rustc --explain E0603`.
error: could not compile `sample_library` due to 3 previous errors
```

Is the error report not counting blank lines/comment-only lines?  Or is something else going on here?

Haven't yet checked the nightly/beta builds.

### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```
rustc 1.64.0 (a55dd71d5 2022-09-19)
binary: rustc
commit-hash: a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52
commit-date: 2022-09-19
host: x86_64-pc-windows-msvc
release: 1.64.0
LLVM version: 14.0.6
```

Running set `RUST_BACKTRACE=1 && cargo build` doesn't yield any additional information.