-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
E0277 should use short paths when possible #116616
Comments
I created a small repo to reproduce this error message. What was not visible in the tweet but that you will see when you build the repo, is that the types in the error notes are even longer. That's a shame because hidden in that noise the compiler gives the solution to the error (pin). |
@fracek You can just create a gist with the error generating logic line highlighted. Much more helpful? |
I can give more context too. I was implementing a K8s operator using I start by creating a Controller and then running it with type ReconcileItem<K> = Result<(ObjectRef<K>, Action), controller::Error<MyError, watcher::Error>>;
async fn create_controller(
client: Client,
) -> Result<impl Stream<Item = ReconcileItem<Pod>>, MyError> {
let pods = Api::<Pod>::all(client.clone());
let context = Context { client };
let controller = Controller::new(pods, watcher::Config::default()).run(
reconcile,
error_policy,
context.into(),
);
Ok(controller)
} That stream yields an item every time the reconcile loops reconciles an item or returns an error. For testing, I iterate over the stream to check that it reconciles items the way I expect. let mut controller = create_controller(client).await?;
while let Some(_item) = controller.try_next().await? { // <-- this line generates the error
} This is the error I get compiling that piece of code. The solution is to pin the stream returned by |
how would i go about solving this? @rustbot claim |
@Milo123459 you can look at how we do it here rust/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs Lines 3000 to 3001 in 94bc9c7
You have to do the same thing but at the very least in the places we print out types to string here: rust/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs Lines 420 to 478 in 8d92c99
|
You also need to ensure that the type-shortening is conditional, based on whether the user wants verbose output or not (similar to the existing logic for type errors). |
@Vedaant-Rajoo |
This comment was marked as outdated.
This comment was marked as outdated.
…ebank Make `E0277` use short paths Fixes rust-lang#116616
Rollup merge of rust-lang#116739 - Milo123459:milo/short-paths, r=estebank Make `E0277` use short paths Fixes rust-lang#116616
Type errors (and others) use
tcx.short_ty_string
and similar to write types that are too long to disk, so the cli output is easier to read. Trait bound errors do not do that.https://twitter.com/ceccon_me/status/1707741832824734186
The text was updated successfully, but these errors were encountered: