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

Desugar parenthesized generic arguments in HIR #43532

Merged
merged 1 commit into from
Aug 24, 2017

Conversation

petrochenkov
Copy link
Contributor

Fixes ICE in #43431 and maybe some other similar issues.

r? @eddyb

@@ -16,6 +16,7 @@ struct Bar<A> {

fn foo(b: Box<Bar()>) {
//~^ ERROR parenthesized parameters may only be used with a trait
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an annoying little regression, but from what I tried "infer everything" was the least evil (in terms of redundant diagnostics), given the constraints 1) usize() should be a warning and not an error and 2) lifetime resolution has some issues causing ICEs if () in non-traits is kept "parenthesized", I hope to fix this in another PR

@eddyb
Copy link
Member

eddyb commented Jul 29, 2017

cc @nikomatsakis I'll take a look later, but from what I remember is that there were some issues with doing it this way, so we didn't attempt. If only I wrote down the issues...

@carols10cents carols10cents added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 31, 2017
@shepmaster
Copy link
Member

@nikomatsakis is on vacation until about 2017-08-15, @eddyb.

@bors
Copy link
Contributor

bors commented Aug 10, 2017

☔ The latest upstream changes (presumably #43522) made this pull request unmergeable. Please resolve the merge conflicts.

@carols10cents
Copy link
Member

ping @eddyb and/or @nikomatsakis !

/// Were parameters written in parenthesized form `Fn(T) -> U`?
/// This is required mostly for pretty-printing and diagnostics,
/// but also for changing lifetime elision rules to be "function-like".
pub parenthesized: bool,
Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see, with this here it's probably okay.

@eddyb
Copy link
Member

eddyb commented Aug 14, 2017

@carols10cents I still want to defer to @nikomatsakis here.

@petrochenkov
Copy link
Contributor Author

Rebased.
r? @nikomatsakis

@rust-highfive rust-highfive assigned nikomatsakis and unassigned eddyb Aug 18, 2017
@nikomatsakis
Copy link
Contributor

@petrochenkov sorry for delay!

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

Sorry, I am going to have to revisit this PR tomorrow. I don't quite understand why it's ok to remove some of the checks that were removed (presumably they are either impossible or taking place earlier, but I have to take another stab at reading it to be sure).

time(time_passes,
"early lint checks",
|| lint::check_ast_crate(sess, &krate));

Copy link
Contributor

Choose a reason for hiding this comment

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

wait what's this -- was this intentionally moved?

Copy link
Contributor Author

@petrochenkov petrochenkov Aug 21, 2017

Choose a reason for hiding this comment

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

Yes, after #43522 you can't report late lints without tcx, and you can't report early lints after lint::check_ast_crate is run. So you can't report lints during AST -> HIR lowering at all.
Thus, I had to move lint::check_ast_crate slightly further in the pipeline, to after lowering, to report PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES (compatibility lint).

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense, I'd move all the AST validation into HIR lowering itself.

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

Sorry for the delay. This time when I read through it all made sense to me. r=me presuming that my questions are answered in the affirmative -- the one thing is that I'd like to be sure there are tests for the various error cases... do you know @petrochenkov ?

self.prohibit_projection(binding.span);
break;
}
}
}

pub fn prohibit_parenthesized_params(&self, segment: &hir::PathSegment, emit_error: bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

these errors are now reported during lowering? do we have tests for all (or most?) of those cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, everything is reported during lowering now.
There are tests, @qnighy fixed a number of omissions in these checks in #41856 and tested everything.

@@ -2359,21 +2320,6 @@ impl Foo {
"##,
*/

E0214: r##"
Copy link
Contributor

Choose a reason for hiding this comment

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

this is also reported during lowering now?

@petrochenkov
Copy link
Contributor Author

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Aug 23, 2017

📌 Commit 000f87a has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Aug 24, 2017

⌛ Testing commit 000f87a with merge a12e4f8...

bors added a commit that referenced this pull request Aug 24, 2017
Desugar parenthesized generic arguments in HIR

Fixes ICE in #43431 and maybe some other similar issues.

r? @eddyb
@bors
Copy link
Contributor

bors commented Aug 24, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing a12e4f8 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants