Open matthiaskrgr opened 3 years ago
@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.
Oh sorry, I forgot to push it :sweat_smile: . It should be online now!
I was able to reproduce this on the playground.
A bug should probably be opened for rustfmt too, right? I don't think this code should make it crash.
The error[internal]: left behind trailing whitespace
is 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:0
instead of
/home/matthias/vcs/github/cargo-cache/src/library.rs:147:0
which I suspect to be a bug somewhere in a rustc_ap.*
crate that rustfmt is using as dependency.
It's weird that it only seems to be happening in this one instance.
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
}
};
}
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)
repro:
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)