Skip to content

Commit e489fc0

Browse files
lqdcuviper
authored andcommitted
Revert "Remove less relevant info from diagnostic"
This reverts commit 8a568d9. (cherry picked from commit 764e3e2)
1 parent bdaaaf3 commit e489fc0

File tree

3 files changed

+24
-23
lines changed

3 files changed

+24
-23
lines changed

compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,24 +1808,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
18081808
StringPart::highlighted("cargo tree".to_string()),
18091809
StringPart::normal("` to explore your dependency tree".to_string()),
18101810
]);
1811-
1812-
// FIXME: this is a giant hack for the benefit of this specific diagnostic. Because
1813-
// we're so nested in method calls before the error gets emitted, bubbling a single bit
1814-
// flag informing the top level caller to stop adding extra detail to the diagnostic,
1815-
// would actually be harder to follow. So we do something naughty here: we consume the
1816-
// diagnostic, emit it and leave in its place a "delayed bug" that will continue being
1817-
// modified but won't actually be printed to end users. This *is not ideal*, but allows
1818-
// us to reduce the verbosity of an error that is already quite verbose and increase its
1819-
// specificity. Below we modify the main message as well, in a way that *could* break if
1820-
// the implementation of Diagnostics change significantly, but that would be caught with
1821-
// a make test failure when this diagnostic is tested.
1822-
err.primary_message(format!(
1823-
"{} because the trait comes from a different crate version",
1824-
err.messages[0].0.as_str().unwrap(),
1825-
));
1826-
let diag = err.clone();
1827-
err.downgrade_to_delayed_bug();
1828-
self.tcx.dcx().emit_diagnostic(diag);
18291811
return true;
18301812
}
18311813

tests/run-make/crate-loading-crate-depends-on-itself/foo.stderr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0277]: the trait bound `foo::Struct: Trait` is not satisfied because the trait comes from a different crate version
1+
error[E0277]: the trait bound `foo::Struct: Trait` is not satisfied
22
--> foo-current.rs:13:19
33
|
44
13 | check_trait::<foo::Struct>();
@@ -23,6 +23,11 @@ note: there are multiple different versions of crate `foo` in the dependency gra
2323
| --------------- this is the found trait
2424
= note: two types coming from two different versions of the same crate are different types even if they look the same
2525
= help: you can use `cargo tree` to explore your dependency tree
26+
note: required by a bound in `check_trait`
27+
--> foo-current.rs:10:19
28+
|
29+
10 | fn check_trait<T: Trait>() {}
30+
| ^^^^^ required by this bound in `check_trait`
2631

2732
error: aborting due to 1 previous error
2833

tests/run-make/crate-loading/multiple-dep-versions.stderr

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
error[E0277]: the trait bound `dep_2_reexport::Type: Trait` is not satisfied because the trait comes from a different crate version
1+
error[E0277]: the trait bound `dep_2_reexport::Type: Trait` is not satisfied
22
--> replaced
33
|
44
LL | do_something(Type);
5-
| ^^^^ the trait `Trait` is not implemented for `dep_2_reexport::Type`
5+
| ------------ ^^^^ the trait `Trait` is not implemented for `dep_2_reexport::Type`
6+
| |
7+
| required by a bound introduced by this call
68
|
79
note: there are multiple different versions of crate `dependency` in the dependency graph
810
--> replaced
@@ -27,6 +29,11 @@ LL | pub trait Trait {
2729
| --------------- this is the found trait
2830
= note: two types coming from two different versions of the same crate are different types even if they look the same
2931
= help: you can use `cargo tree` to explore your dependency tree
32+
note: required by a bound in `do_something`
33+
--> replaced
34+
|
35+
LL | pub fn do_something<X: Trait>(_: X) {}
36+
| ^^^^^ required by this bound in `do_something`
3037

3138
error[E0599]: no method named `foo` found for struct `dep_2_reexport::Type` in the current scope
3239
--> replaced
@@ -77,11 +84,13 @@ LL | use dependency::{Trait, do_something};
7784
LL | pub trait Trait {
7885
| --------------- this is the trait that was imported
7986

80-
error[E0277]: the trait bound `OtherType: Trait` is not satisfied because the trait comes from a different crate version
87+
error[E0277]: the trait bound `OtherType: Trait` is not satisfied
8188
--> replaced
8289
|
8390
LL | do_something(OtherType);
84-
| ^^^^^^^^^ the trait `Trait` is not implemented for `OtherType`
91+
| ------------ ^^^^^^^^^ the trait `Trait` is not implemented for `OtherType`
92+
| |
93+
| required by a bound introduced by this call
8594
|
8695
note: there are multiple different versions of crate `dependency` in the dependency graph
8796
--> replaced
@@ -106,6 +115,11 @@ LL | pub struct OtherType;
106115
LL | pub trait Trait {
107116
| --------------- this is the found trait
108117
= help: you can use `cargo tree` to explore your dependency tree
118+
note: required by a bound in `do_something`
119+
--> replaced
120+
|
121+
LL | pub fn do_something<X: Trait>(_: X) {}
122+
| ^^^^^ required by this bound in `do_something`
109123

110124
error: aborting due to 4 previous errors
111125

0 commit comments

Comments
 (0)