Skip to content
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

Error diagnostics for associated items are different with -Z unstable-options #82637

Open
jyn514 opened this issue Feb 28, 2021 · 1 comment
Open
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jyn514
Copy link
Member

jyn514 commented Feb 28, 2021

I tried this code: https://github.com/rust-lang/rust/blob/573a697a6197abaad5a2d7208dbf1bbc77f4dcf3/src/test/ui/associated-types/defaults-cyclic-fail-1.rs

I expected to see this happen: The error output is the same with and without -Z unstable-options

Instead, this happened: -Z unstable-options reports more errors than without.

diff --git a/src/test/ui/associated-types/defaults-cyclic-fail-1.stderr b/src/test/ui/associated-types/defaults-cyclic-fail-1.stderr
index 5e98520b411..c2887ccac74 100644
--- a/src/test/ui/associated-types/defaults-cyclic-fail-1.stderr
+++ b/src/test/ui/associated-types/defaults-cyclic-fail-1.stderr
@@ -4,12 +4,6 @@ error[E0275]: overflow evaluating the requirement `<bool as Tr>::B == _`
 LL |     type A = Box<Self::B>;
    |     ^^^^^^^^^^^^^^^^^^^^^^
 
-error[E0275]: overflow evaluating the requirement `<usize as Tr>::A == _`
-  --> $DIR/defaults-cyclic-fail-1.rs:32:5
-   |
-LL |     type B = &'static Self::A;
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error

There are similar issues with other errors related to associated items; see 3205303 for details.

cc @matthewjasper - do you have any idea what's going on here?

@jyn514 jyn514 added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. labels Feb 28, 2021
@jyn514
Copy link
Member Author

jyn514 commented Jun 6, 2021

cc @estebank, this also affects the "required by this bound" diagnostic I think you recently added.

diff --git a/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.stderr b/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.stderr
index 919b18632e6..ba5391dd803 100644
--- a/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.stderr
+++ b/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.stderr
@@ -1,13 +1,8 @@
 error[E0277]: `<<Self as Case1>::A as Iterator>::Item` doesn't implement `Debug`
   --> $DIR/bounds-on-assoc-in-trait.rs:18:28
    |
-LL |     type A: Iterator<Item: Debug>;
-   |                            ^^^^^ `<<Self as Case1>::A as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
-   |
-  ::: $SRC_DIR/core/src/fmt/mod.rs:LL:COL
-   |
-LL | pub trait Debug {
-   | --------------- required by this bound in `Debug`
+LL |       type A: Iterator<Item: Debug>;
+   |                              ^^^^^ `<<Self as Case1>::A as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
    |
    = help: the trait `Debug` is not implemented for `<<Self as Case1>::A as Iterator>::Item`
 help: consider further restricting the associated type

bors added a commit to rust-lang-ci/rust that referenced this issue Jun 10, 2021
Don't pass -Z unstable-options by default for UI tests

Unconditionally passing -Z unstable-options makes it impossible to test whether an option requires unstable-options or not.

This uncovered quite a lot of bugs, I'll open issues for each. These don't strictly need to be fixed before this is merged, it just makes the diff much larger because of the changes to diagnostics.

- rust-lang#82636
- rust-lang#82637
- rust-lang#82638
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

1 participant