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

Graph Changes #37535

Merged
merged 4 commits into from
Nov 12, 2016
Merged

Graph Changes #37535

merged 4 commits into from
Nov 12, 2016

Conversation

Havvy
Copy link
Contributor

@Havvy Havvy commented Nov 2, 2016

General cleanup and adding a few methods that I want to use in Clippy.

Need somebody to bikeshed names.

Use where clasues and only where clauses for bounds in the
iterators for Graph.

The rest of the code uses bounds on the generic declarations for
Debug, and we may want to change those to for consistency. I did
not do that here because I don't know whether or not that's a good
idea. But for the iterators, they were inconsistent causing
confusion, at least for me.
Also used those general iterators in other methods.
@rust-highfive
Copy link
Collaborator

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

fn is_node_cyclic_b() {
let graph = create_graph_with_cycle();
assert!(graph.is_node_cyclic(NodeIndex(1)));
}
Copy link
Member

Choose a reason for hiding this comment

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

Missing newline at the end of the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added newline.

@eddyb
Copy link
Member

eddyb commented Nov 2, 2016

cc @nikomatsakis Are we fine with such additions?

@bluss
Copy link
Member

bluss commented Nov 2, 2016

here it comes: Using the convention of naming the iterator struct exactly like the method that creates it would be good. I see that the existing outgoing_edges doesn't do that, but it's not too late for new additions to do so.

@@ -20,10 +20,13 @@ fn create_graph() -> TestGraph {

// Create a simple graph
//
// F
// |
// V
// A -+> B --> C
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably become

     //    A --> B --> C

(i.e. '+' should become '-')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh whoops. I noticed that the comment was wrong in general about the placement of f, so moved it to be correct, but forgot to update the + there. Also fixed in the other comment where I just removed F.

@Havvy
Copy link
Contributor Author

Havvy commented Nov 2, 2016

@bluss So based on that, what names are you thinking? Because I think you're thinking nodes_iter_enumerated or nodes_iter_enumerated_by_index.

@bluss
Copy link
Member

bluss commented Nov 2, 2016

@Havvy Well I didn't propose anything about that, only that the struct should be named like the method or vice versa. So for example AllNodesEnumerated with the current patch.

Spontaneously, maybe fn enumerated_nodes(&self) -> EnumeratedNodes<N> and so on?

@Havvy
Copy link
Contributor Author

Havvy commented Nov 3, 2016

I like those method names better, and went with them, and also made the Iterator structs match the method names.

@nikomatsakis
Copy link
Contributor

I have no objection to extending the graph API, but I would say we have no intention of supporting it. It'd probably be better for clippy to use petgraph or something on crates.io.

@eddyb
Copy link
Member

eddyb commented Nov 4, 2016

@nikomatsakis This is for using rustc::cfg directly. Maybe I should've suggested MIR, but #37400 hadn't landed yet at that time.

@nikomatsakis
Copy link
Contributor

@eddyb it'd probably be better for clippy to recreate the graph in petgraph then =)

@nikomatsakis
Copy link
Contributor

but yeah I'm fine w/ landing these changes, particularly since cfg's time is limited.

@Havvy
Copy link
Contributor Author

Havvy commented Nov 8, 2016

Is rustc_data_structures::graph also going away when cfg goes away? If not, these are still probably useful.

@alexcrichton alexcrichton added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Nov 10, 2016
@alexcrichton
Copy link
Member

@Havvy thoughts about extracting this data structure to crates.io, perhaps build on petgraph? If what @nikomatsakis says is correct then this is soon to be deleted anyway.

@Havvy
Copy link
Contributor Author

Havvy commented Nov 11, 2016

There's a similar lint already in the compiler (infinitely recursive functions) as to what I am attempting to do (though I've put in on hold for a couple days because, yay trying to figure out what's staying and what's changing), so I can just use what that lint uses. I don't need cfg if there's an alternative way and I'd rather not maintain or force to be maintained for clippy a version of cfg outside of the Rust repository.

So my question is, is the Graph structure used outside of cfg. If so, these commits are still probably useful (except probably the last one), but if not, there's no point merging this and it should be closed. So, what is the future of Graph?

@nikomatsakis
Copy link
Contributor

To be clear, I have no objection to landing this PR for the time being. I just want to be clear that there are no promises of backwards compatibility etc.

@eddyb
Copy link
Member

eddyb commented Nov 11, 2016

@bors r+

@bors
Copy link
Contributor

bors commented Nov 11, 2016

📌 Commit 9ddbb91 has been approved by eddyb

eddyb added a commit to eddyb/rust that referenced this pull request Nov 11, 2016
Graph Changes

General cleanup and adding a few methods that I want to use in Clippy.

Need somebody to bikeshed names.
eddyb added a commit to eddyb/rust that referenced this pull request Nov 12, 2016
Graph Changes

General cleanup and adding a few methods that I want to use in Clippy.

Need somebody to bikeshed names.
bors added a commit that referenced this pull request Nov 12, 2016
@bors bors merged commit 9ddbb91 into rust-lang:master Nov 12, 2016
@Havvy Havvy deleted the graph branch September 27, 2017 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants