Friendica
Esteban Küber
Esteban Küber

Esteban Küber

ekuber@hachyderm.io

Esteban Küber

ekuber@hachyderm.io

"We spent decades trying to invent a sufficiently smart compiler when we should have been inventing a sufficiently empathetic one." — @benleedom

#Rust Compiler team member. If you have to search for answers when the compiler is talking to you, that's a bug.

There are no bad programmers, only insufficiently advanced compilers.

Cache-locality awareness evangelist. UTF-8 maximalist.

You can't "individual responsibility" your way out of systemic problems.

he/him

Trans rights are human rights

ActivityPub
2024-08-19 19:58:14 2024-08-19 19:54:25 2024-08-19 19:48:36 5346010

Esteban Küber
Esteban Küber
mastodon - Link to source

Esteban Küber

1 year ago • •

Esteban Küber

1 year ago • •


Is this *too much*? Historically, having two crate versions in your dependency tree and accidentally mixing types from them led to horribly obtuse error messages (expected `Foo`, found `Foo`). We've slowly chipped away at them, but somethings I fear I might have gone overboard with detail. 😬

#Rust #RustLang

Rust compiler error output:
error[E0277]: the trait bound `CustomErrorHandler: ErrorHandler` is not satisfied
 --> src/main.rs:5:17
  |
5 |     cnb_runtime(CustomErrorHandler {});
  |     ----------- ^^^^^^^^^^^^^^^^^^^^^ the trait `ErrorHandler` is not implemented for `CustomErrorHandler`
  |     |
  |     required by a bound introduced by this call
  |
help: there are multiple different versions of crate `c` in the dependency graph
 --> src/main.rs:1:5
  |
1 | use b::CustomErrorHandler;
  |     ^ one version of crate `c` is used here, as a dependency of crate `b`
2 | use c::cnb_runtime;
  |     ^ one version of crate `c` is used here, as a direct dependency of the current crate
note: two types coming from two different versions of the same crate are different types even if they look the same
 --> ~/c-v0.2/src/lib.rs:1:1
  |
1 | pub trait ErrorHandler {}
  | ^^^^^^^^^^^^^^^^^^^^^^ this is the required trait
  |
 ::: ~/b/src/lib.rs:1:1
  |
1 | pub struct CustomErrorHandler {}
  | ----------------------------- this type doesn't implement the required trait
  |
 ::: ~/c-v0.1/src/lib.rs:1:1
  |
1 | pub trait ErrorHandler {}
  | ---------------------- this is the found trait
  = help: you can use `cargo tree` to explore your dependency tree
note: required by a bound in `cnb_runtime`
 --> ~/c-v0.2/src/lib.rs:3:41
  |
3 | pub fn cnb_runtime(_error_handler: impl ErrorHandler) {}
  |                                         ^^^^^^^^^^^^ required by this bound in `cnb_runtime`
#rust #RustLang
  •  Languages
  •  Search Text
  •  Share via ...
in reply to Esteban Küber

Matt Campbell
mastodon - Link to source

Matt Campbell

in reply to Esteban Küber • 1 year ago • •
I think it's great. That level of explanation is likely to help less experienced users.
  •  Languages
  •  Search Text
  •  Share via ...
in reply to Matt Campbell

Esteban Küber
mastodon - Link to source

Esteban Küber

in reply to Matt Campbell • 1 year ago • •
@matt My take is that even experienced users are not *homogeneously* experienced in the entire language. We all hit an uncommon corner every now and then, so making errors easier to understand for newcomers helps everyone. :)
@Matt Campbell
  •  Languages
  •  Search Text
  •  Share via ...
⇧