-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Only report Self: Sized violation once. #26027
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
Conversation
r? @Aatch (rust_highfive has picked a reviewer for you, use r? to override) |
@@ -104,9 +110,6 @@ fn object_safety_violations_for_trait<'tcx>(tcx: &ty::ctxt<'tcx>, | |||
.collect(); | |||
|
|||
// Check the trait itself. | |||
if trait_has_sized_self(tcx, trait_def_id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this perhaps be left in the same place but check that the violations array doesn't already contain SizedSelf
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I also thought about that, but it doesn't seem to work. This is the violations
vector inside object_safety_violations_for_trait
. This one will only ever have one SizedSelf
in it.
Hm I think that compiletest does indeed check that all error messages are accounted for, but it must be using the same pattern to match the error message more than once. Some possibilities for adding a test could be:
|
@alexcrichton Thanks for the suggestion. The problem seems to be that it only ensures that the initial compiler errors match all existing error patterns in the test file. After the error patterns are all matched, any remaining compiler errors get ignored. I believe I have a fix for this bug, but fixing it revealed over 100 broken tests! I am now going through the tests and trying to fix them. Edit: or rather, not broken, but tests that relied on not having to match every single error |
Oh thanks for the cleanup @nham! Looks like there's a tidy error here but once that's fixed r=me |
@alexcrichton Sorry for being unclear. The tests are not fixed yet, there are still 17 compile-fail test failures. Also, when is it acceptable to ignore a test? I've tried to fix each of the remaining 17 but have not yet been able to figure out how to do so For reference, here's what's left in compile-fail:
|
68feaac
to
9ea922d
Compare
@nham oh wow this has a lot more fallout than I would have initially anticipated, thanks for doing this! What's the error message associated with these failing tests? I would have expected some extra |
☔ The latest upstream changes (presumably #26087) made this pull request unmergeable. Please resolve the merge conflicts. |
@alexcrichton Many of the test failures were because of missing error messages, but you're right that some of these test failures are unexpected. A common example of such a failure is a test looking like this: // error-pattern: mismatched types
fn f(x: isize) { }
fn main() { let i: (); i = f(()); } This test began failing after the change, but it works if I remove the "error-pattern" comment and add a |
Yeah I'm not sure why those would suddenly start failing, but at least it's good cleanup to go from |
deffb5b
to
c824e0d
Compare
@alexcrichton This passes
Do I need to try to fix these or can I ignore them for now? The other test that I ignored is |
It looks like What's the error message you're getting from |
Here's a more complete example. It makes sense to me why // run-fail/test-panic.rs
// check-stdout
// error-pattern:thread 'test_foo' panicked at
// compile-flags: --test
// ignore-pretty: does not work well with `--test`
#[test]
fn test_foo() {
panic!()
} It's verifying that this test panics. Currently the test fails with "no more error patterns to match against", but to be honest I don't see any other error messages in the "test_foo stdout" section (I tried adding
Removing the |
issue-21146 looks like this: // error-pattern: expected item, found `parse_error`
include!("../auxiliary/issue-21146-inc.rs");
fn main() {} and ../auxiliary/issue-21146-inc.rs looks like this: parse_error Trying to compile issue-21146 results in exactly one error:
Which seems like it should match the error-pattern in the file. But for some reason it doesn't:
|
Perhaps lines of the output are being considered a compilation error that need to be matched against by accident? It may be useful to instrument compiletest to print out what addition errors are expected to be matched but weren't. |
Thanks. I did this and I managed to make all the tests pass without ignoring any. |
⌛ Testing commit c41b947 with merge ea41672... |
I ran |
r? @alexcrichton . This passes |
@bors: r+ a55d310 No worries! |
⌛ Testing commit a55d310 with merge 4d3bded... |
💔 Test failed - auto-mac-64-opt |
☔ The latest upstream changes (presumably #26190) made this pull request unmergeable. Please resolve the merge conflicts. |
Also fixes tests to pass.
Fallout from the change to compiletest that makes it not ignore compiler errors that don't have an error pattern.
Rebased. This passes |
⌛ Testing commit 5c0fb26 with merge 4cca4f9... |
💔 Test failed - auto-mac-64-opt |
Closing due to inactivity, but feel free to reopen with tests fixed! |
Unfortunately I'm not sure how to investigate a mac-only test failure. That test passes on my system :\ |
Background
The cause of #20692 seems to be in middle::trait::object_safety::object_safety_violations. The
supertrait_def_ids
call returns an iterator that iterates over trait definition ids. The iteration seems to start at the current trait and then traverse supertraits in order. For example, in the following block of code, it goesBar
->Foo
->Sized
:However for each trait in the hierarchy,
object_safety_violations_in_trait
gets called (in the.flat_map()
call). Each call (all 3 of them) results in aSelf : Sized
violation since each trait in the hierarchy hasSized
as a supertrait. That is why the above code compiles with 2 extra notes today:The fix
The fix I've submitted is to move the
trait_has_sized_self
check out ofobject_safety_violations_in_trait
toobject_safety_violations
so it's only called once, and not for each supertrait.How to test?
I need help here. I don't see how to test it. This doesn't work:
Putting this in compile-fail passes without the fix. It seems that this doesn't try to match the number of notes exactly, so even though compilation results in 3 notes emitted today, it matches the one that is expected in the test and ignores the extra error output.
Any advice on how to test this fix?
Fixes #20692.