Skip to content

Column offset should be 1-based instead of 0-based. #11183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jhasse opened this issue Dec 28, 2013 · 1 comment
Closed

Column offset should be 1-based instead of 0-based. #11183

jhasse opened this issue Dec 28, 2013 · 1 comment

Comments

@jhasse
Copy link
Contributor

jhasse commented Dec 28, 2013

Other compilers (gcc) and editors (Sublime Text, vim) start columns at 1, but the rust compiler starts at 0:

~ echo "int main() { foo }" > tmp.c
~ echo " fn main() { foo }" > tmp.rs
~ gcc tmp.c
tmp.c:1:14: error: 'foo' undeclared (first use in this function)
~ rustc tmp.rs
tmp.rs:1:13: 1:16 error: unresolved name `foo`.

I'm not sure how to fix this properly. My patch simply adds 1 whenever col is displayed, but maybe it should be changed here? https://github.com/mozilla/rust/blob/master/src/libsyntax/codemap.rs#L148

@huonw
Copy link
Member

huonw commented Dec 28, 2013

Dupe of #10848. (I'm not sure which is the proper fix, storing them 0-based makes indexing/slicing the strings by adding to the start-of-column offset more natural.)

@huonw huonw closed this as completed Dec 28, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 31, 2023
Remove `#![allow(unused)]` and `--crate-name` from `cargo dev new_lint` generated tests

changelog: none

Also removes some unused flags from `ui-cargo` tests because the entrypoint is now the `Cargo.toml`, not the `.rs` files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants