diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-08-23 13:07:56 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-08-23 13:07:56 +0100 |
commit | c12dce0073c1766f7d2b10a69f8526a8093e70dc (patch) | |
tree | 3d0df9bf5c25cdf241426901c78c2b7f9bb8e38b /crates/ra_assists/src/ast_editor.rs | |
parent | e055cfacdfe3b3451484dae5d6ed08aefba133ca (diff) | |
parent | bbcca4f735870246c8ed8ce1a29af100e09b0a6f (diff) |
Merge #1716
1716: make ast object safe r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/ast_editor.rs')
-rw-r--r-- | crates/ra_assists/src/ast_editor.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/crates/ra_assists/src/ast_editor.rs b/crates/ra_assists/src/ast_editor.rs index 5b6952426..076df98f2 100644 --- a/crates/ra_assists/src/ast_editor.rs +++ b/crates/ra_assists/src/ast_editor.rs | |||
@@ -19,7 +19,10 @@ pub struct AstEditor<N: AstNode> { | |||
19 | } | 19 | } |
20 | 20 | ||
21 | impl<N: AstNode> AstEditor<N> { | 21 | impl<N: AstNode> AstEditor<N> { |
22 | pub fn new(node: N) -> AstEditor<N> { | 22 | pub fn new(node: N) -> AstEditor<N> |
23 | where | ||
24 | N: Clone, | ||
25 | { | ||
23 | AstEditor { original_ast: node.clone(), ast: node } | 26 | AstEditor { original_ast: node.clone(), ast: node } |
24 | } | 27 | } |
25 | 28 | ||
@@ -379,7 +382,7 @@ impl AstBuilder<ast::MatchArmList> { | |||
379 | 382 | ||
380 | fn ast_node_from_file_text<N: AstNode>(text: &str) -> N { | 383 | fn ast_node_from_file_text<N: AstNode>(text: &str) -> N { |
381 | let parse = SourceFile::parse(text); | 384 | let parse = SourceFile::parse(text); |
382 | let res = parse.tree().syntax().descendants().find_map(N::cast).unwrap().to_owned(); | 385 | let res = parse.tree().syntax().descendants().find_map(N::cast).unwrap(); |
383 | res | 386 | res |
384 | } | 387 | } |
385 | 388 | ||