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

Rewrite the UnconditionalRecursion lint to use MIR #54490

Merged
merged 1 commit into from
Oct 25, 2018

Conversation

wesleywiser
Copy link
Member

Part of #51002

r? @eddyb

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 22, 2018
@rust-highfive

This comment has been minimized.

src/librustc_mir/lints.rs Outdated Show resolved Hide resolved
src/librustc_mir/lints.rs Outdated Show resolved Hide resolved

//is this a self call?
let is_self_call =
if let Some(Def::Method(_)) = tcx.describe_def(def_id) {
Copy link
Member

Choose a reason for hiding this comment

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

Do you need this describe_def check? I'd suspect that if you have issues with the substs, you'd rather normalize them somehow. Polymorphic recursion wouldn't compile anyway.

Copy link
Member Author

@wesleywiser wesleywiser Sep 24, 2018

Choose a reason for hiding this comment

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

Just doing the substs check missed a few cases which the old lint caught. For example:

fn test<T: Copy>() {
  test::<usize>();
}

The old lint caught this. With the additional check for "are we in a trait method", all the existing tests pass for the new lint.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, that is unfortunate, since it's not polymorphic recursion, and doesn't involve traits. I don't like describe_def though - can you use some functionality on tcx to check whether the function is a trait-associated item? Inherent methods, or methods in impls, need to behave like ordinary functions, it's only trait impls that care about dispatch.

Furthermore, only the part of the substs that corresponds to the trait, is relevant here, e.g. if the method has generics, they should probably be ignored.

@wesleywiser
Copy link
Member Author

Hey @eddyb, I think I resolved most of your feedback except for this bit:

Furthermore, only the part of the substs that corresponds to the trait, is relevant here, e.g. if the method has generics, they should probably be ignored.

I'm not really sure how to go about doing that. Do you have any pointers?

src/librustc_mir/lints.rs Outdated Show resolved Hide resolved
@eddyb
Copy link
Member

eddyb commented Sep 27, 2018

@wesleywiser You can slice both substs with ..tcx.generics_of(trait_def_id).count().

src/librustc_mir/lints.rs Outdated Show resolved Hide resolved
@wesleywiser
Copy link
Member Author

Thanks @eddyb! I think all of your feedback is resolved now.

src/librustc_mir/lints.rs Outdated Show resolved Hide resolved
@bors

This comment has been minimized.

@wesleywiser
Copy link
Member Author

Rebased and ready for review.

@TimNN
Copy link
Contributor

TimNN commented Oct 16, 2018

Ping from triage @eddyb: This PR requires your review.

@oli-obk
Copy link
Contributor

oli-obk commented Oct 25, 2018

@bors r+

I have nothing more to add, lgtm

@bors
Copy link
Contributor

bors commented Oct 25, 2018

📌 Commit f81d1dd has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 25, 2018
@wesleywiser
Copy link
Member Author

Thanks @oli-obk!

pietroalbini added a commit to pietroalbini/rust that referenced this pull request Oct 25, 2018
…i-obk

Rewrite the `UnconditionalRecursion` lint to use MIR

Part of rust-lang#51002

r? @eddyb
@bors
Copy link
Contributor

bors commented Oct 25, 2018

⌛ Testing commit f81d1dd with merge a4d1ac8e4337a605ee45ae8e706a550ceaa509ae...

@bors
Copy link
Contributor

bors commented Oct 25, 2018

💔 Test failed - status-travis

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-distcheck of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:05:36] Caused by:
[00:05:36]   failed to download package from registry
[00:05:36] 
[00:05:36] Caused by:
[00:05:36]   failed to get 200 response from `https://crates.io/api/v1/crates/openssl-src/111.0.1+1.1.1/download`, got 403
[00:05:36] 
[00:05:36] 
[00:05:36] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "vendor"
[00:05:36] 
[00:05:36] 
[00:05:36] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test distcheck
[00:05:36] Build completed unsuccessfully in 0:02:08
---
travis_time:end:044c5b6a:start=1540499353942303725,finish=1540499353951328642,duration=9024917
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:19d56c28
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:05e00bc0
travis_time:start:05e00bc0
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:07ccdffe
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 25, 2018
@wesleywiser
Copy link
Member Author

Looks like a spurious crates.io download failure?

@wesleywiser
Copy link
Member Author

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 25, 2018
@bors
Copy link
Contributor

bors commented Oct 25, 2018

⌛ Testing commit f81d1dd with merge 4bd4e41...

bors added a commit that referenced this pull request Oct 25, 2018
Rewrite the `UnconditionalRecursion` lint to use MIR

Part of #51002

r? @eddyb
@oli-obk
Copy link
Contributor

oli-obk commented Oct 25, 2018

yea this has been going around, I think most of the queue has been hit by it

@wesleywiser
Copy link
Member Author

Should we open a tracking issue for that?

@oli-obk
Copy link
Contributor

oli-obk commented Oct 25, 2018

nah, infra is already ahead of it on discord

@bors
Copy link
Contributor

bors commented Oct 25, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: oli-obk
Pushing 4bd4e41 to master...

@bors bors merged commit f81d1dd into rust-lang:master Oct 25, 2018
arielb1 added a commit to arielb1/rust that referenced this pull request Dec 2, 2018
dropping the param-env on the floor is obviously the wrong thing to do.

The ICE was probably exposed by rust-lang#54490 adding the problem-exposing use of
`traits::find_associated_item`.

Fixes rust-lang#55380.
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Dec 5, 2018
…=nikomatsakis

pass the parameter environment to `traits::find_associated_item`

dropping the param-env on the floor is obviously the wrong thing to do.

The ICE was probably exposed by rust-lang#54490 adding the problem-exposing use of
`traits::find_associated_item`.

Fixes rust-lang#55380.

r? @nikomatsakis
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Dec 6, 2018
…=nikomatsakis

pass the parameter environment to `traits::find_associated_item`

dropping the param-env on the floor is obviously the wrong thing to do.

The ICE was probably exposed by rust-lang#54490 adding the problem-exposing use of
`traits::find_associated_item`.

Fixes rust-lang#55380.

r? @nikomatsakis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants