rustc span format seems broken: file:line:line:column
repro:
git clone https://github.com/matthiaskrgr/cargo-cache
cd cargo-cache
git checkout rustfmt_bug
cargo fmt
error[internal]: left behind trailing whitespace
--> /home/matthias/vcs/github/cargo-cache/src/library.rs:147:147:0
|
147 |
| ^^^^
|
warning: rustfmt has failed to format. See previous 1 errors.
This "147:147:0 seems super suspicious, why is printing the column twice in the span location??
rustfmt gets its span information from rustc afaik thus I opened this ticket against rustc.
rustfmt 1.4.29-nightly (70ce182 2020-12-04)
rustc 1.50.0-nightly (f0f68778f 2020-12-09)
binary: rustc
commit-hash: f0f68778f798d6d34649745b41770829b17ba5b8
commit-date: 2020-12-09
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly
@matthiaskrgr I tried looking at the branch on GitHub, but it doesn't seem to exist. https://github.com/matthiaskrgr/cargo-cache/tree/rustfmt_bug returns a 404.
Noah Lev at 2020-12-11 22:13:01
Oh sorry, I forgot to push it :sweat_smile: . It should be online now!
Matthias Krüger at 2020-12-11 22:15:12
I was able to reproduce this on the playground.
Noah Lev at 2020-12-11 22:16:44
A bug should probably be opened for rustfmt too, right? I don't think this code should make it crash.
Noah Lev at 2020-12-11 22:19:50
The
error[internal]: left behind trailing whitespaceis a rustfmt bug, I agree. This ticket is about the fact that it says/home/matthias/vcs/github/cargo-cache/src/library.rs:147:147:0instead of/home/matthias/vcs/github/cargo-cache/src/library.rs:147:0which I suspect to be a bug somewhere in arustc_ap.*crate that rustfmt is using as dependency.Matthias Krüger at 2020-12-11 22:31:21
It's weird that it only seems to be happening in this one instance.
Noah Lev at 2020-12-11 22:45:58
Bumping the topic due to the similar error popping on URLO; minimized example:
fn next() { let _ = // This comment causes rustfmt inernal error { if true { // whitespace symbol at the end of next line is significant } }; }Cerber-Ursi at 2023-12-20 07:05:44
Similar problem:
use async_graphql::{Context, EmptyMutation, EmptySubscription, Object, Schema, SimpleObject, ID}; use async_graphql_axum::GraphQL; use axum::{routing::post_service, Router, Server}; #[derive(SimpleObject, Clone)] struct Collectible { id: ID, name: String, collection: Collection, } #[derive(SimpleObject, Clone)] #[graphql(unresolvable)] struct Collection { id: String, } struct Query; #[Object] impl Query { #[graphql(entity)] async fn collectible_by_id<'a>(&self, ctx: &'a Context<'_>, id: ID) -> Collectible { ctx.data_unchecked::<Vec<Collectible>>() .iter() .find(|collectible| collectible.id == id) .unwrap() .clone() } } #[tokio::main] async fn main() { Server::bind(&"0.0.0.0:4003".parse().unwrap()) .serve( Router::new() .route("/", post_service(GraphQL::new(Schema::build(Query, EmptyMutation, EmptySubscription) .enable_federation() .data(vec![ Collectible { id: "ethereum.0xAd2EB4808b817403005ae020B0662825eE021B0F.51".into(), name: "A highly effective form of birth control.".into(), collection: Collection { id: "ethereum.0xAd2EB4808b817403005ae020B0662825eE021B0F".to_string(), }, }, Collectible { id: "ethereum.0x7d256d82b32d8003d1ca1a1526ed211e6e0da9e2.11417".into(), name: "Fedoras are one of the most fashionable hats around and can look great with a variety of outfits.".into(), collection: Collection { id: "ethereum.0x7d256d82b32d8003d1ca1a1526ed211e6e0da9e2".to_string(), }, }, Collectible { id: "ethereum.0xa58b5224e2fd94020cb2837231b2b0e4247301a6.970".into(), name: "This is the last straw. Hat you will wear. 11/10".into(), collection: Collection { id: "ethereum.0xa58b5224e2fd94020cb2837231b2b0e4247301a6".to_string(), }, }, ]) .finish().clone()))) .into_make_service(), ) .await .unwrap(); }error[internal]: left behind trailing whitespace --> /Users/bshn/workspace/collections_federation/collectibles/src/main.rs:52:52:15 | 52 | }, | ^^^ | error[internal]: left behind trailing whitespace --> /Users/bshn/workspace/collections_federation/collectibles/src/main.rs:59:59:15 | 59 | }, | ^^^^^^^^ | warning: rustfmt has failed to format. See previous 2 errors.cargo 1.77.0-nightly (363a2d113 2023-12-22)Nikita Bishonen at 2023-12-27 19:46:02