Skip to content

Conversation

@Nashenas88
Copy link
Contributor

@Nashenas88 Nashenas88 commented May 23, 2020

Addresses #190

@Nashenas88
Copy link
Contributor Author

Nashenas88 commented May 23, 2020

Just realized I'm missing tests for the changes in ra_hir(_ty).

Tests added but are failing on the latest commit.

Copy link
Member

@bjorn3 bjorn3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a syntax error in multiple tests

@Nashenas88
Copy link
Contributor Author

I also realized there was no tracking in place for unsafe blocks. I've started adding support for that by initially just creating an Expr::UnsafeBlock, but I'm not sure how to determine whether an unsafe expr is within an unsafe block or not. Would I have to change the existing iteration in unsafe_expressions to walk the expression tree rather than iterating over every expr in body (currently done with db.body(def).exprs.iter()? I've been assuming the latter doesn't need to be manually walked.

@flodiebold
Copy link
Member

Expr::UnsafeBlock

That should probably just be an Expr::Unsafe with a block inside it.

Would I have to change the existing iteration in unsafe_expressions to walk the expression tree rather than iterating over every expr in body (currently done with db.body(def).exprs.iter()? I've been assuming the latter doesn't need to be manually walked.

I think we'd need a function for walking the expression tree, we don't have that currently.

@Nashenas88
Copy link
Contributor Author

@flodiebold You commented right after a figured out a working solution. Do you think what I came up with is not efficient? Should I still go ahead an work on a walking-based impl?

@Nashenas88
Copy link
Contributor Author

Nashenas88 commented May 24, 2020

I'm not understanding the test failures:

thread 'syntax_highlighting::tests::test_unsafe_highlighting' panicked at 'Forgot to remove debug-print?', crates/ra_ide/src/syntax_highlighting/tests.rs:288:5

But that points to this line:

assert_eq_text!(expected_html, actual_html);

in the new test I added. I can't reproduce this locally.

Somehow the failure revealed itself after rebasing. Not sure if maybe I also needed to run a clean, but it's working now so ¯\_(ツ)_/¯

@Nashenas88 Nashenas88 changed the title Add unsafe diagnostics and unsafe highlighting Add missing unsafe diagnostics and unsafe highlighting May 25, 2020
@Nashenas88 Nashenas88 requested a review from flodiebold May 25, 2020 18:30
Copy link
Contributor

@matklad matklad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like I forgot to hit "submit review" yesterday :-(

@Nashenas88 Nashenas88 requested a review from matklad June 1, 2020 12:05
@Nashenas88 Nashenas88 requested a review from matklad June 2, 2020 23:04
@Nashenas88 Nashenas88 changed the title Add missing unsafe diagnostics and unsafe highlighting Add missing unsafe diagnostics Jun 2, 2020
@Nashenas88 Nashenas88 changed the title Add missing unsafe diagnostics Add "missing unsafe" diagnostics Jun 2, 2020
Move unsafe_expressions to unsafe_validation.rs, replace vec tracking of
child exprs with inline macro, add debug assert to ensure tracked
children match walked children exactly
@matklad
Copy link
Contributor

matklad commented Jun 27, 2020

bors r+

bors bot added a commit that referenced this pull request Jun 27, 2020
4587: Add "missing unsafe" diagnostics r=matklad a=Nashenas88

Addresses #190 

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
@matklad
Copy link
Contributor

matklad commented Jun 27, 2020

bors d+

@bors
Copy link
Contributor

bors bot commented Jun 27, 2020

✌️ Nashenas88 can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@bors
Copy link
Contributor

bors bot commented Jun 27, 2020

Canceled.

@Nashenas88
Copy link
Contributor Author

bors r+

@bors
Copy link
Contributor

bors bot commented Jun 27, 2020

@bors bors bot merged commit 45fc8d5 into rust-lang:master Jun 27, 2020
@Nashenas88 Nashenas88 deleted the highlight-unsafe branch June 27, 2020 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants