diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-04-04 00:47:10 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-04-04 00:47:10 +0100 |
commit | 234ddf34c743924a15cca7480fb3b4db4581308e (patch) | |
tree | 8386a83d383563308a83f4491d313be043dc94d3 /crates/cfg | |
parent | bcf600fc881026ab018d0a8ae09eff7e54af538b (diff) | |
parent | 3abcdc03ba335fb3487c62547f61746e4a199fe6 (diff) |
Merge #8320
8320: Make `ast_to_token_tree` infallible r=jonas-schievink a=jonas-schievink
It could never return `None`, so reflect that in the return type
bors r+
Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/cfg')
-rw-r--r-- | crates/cfg/src/tests.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/cfg/src/tests.rs b/crates/cfg/src/tests.rs index bd0f9ec48..d8736c893 100644 --- a/crates/cfg/src/tests.rs +++ b/crates/cfg/src/tests.rs | |||
@@ -8,7 +8,7 @@ fn assert_parse_result(input: &str, expected: CfgExpr) { | |||
8 | let (tt, _) = { | 8 | let (tt, _) = { |
9 | let source_file = ast::SourceFile::parse(input).ok().unwrap(); | 9 | let source_file = ast::SourceFile::parse(input).ok().unwrap(); |
10 | let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap(); | 10 | let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap(); |
11 | ast_to_token_tree(&tt).unwrap() | 11 | ast_to_token_tree(&tt) |
12 | }; | 12 | }; |
13 | let cfg = CfgExpr::parse(&tt); | 13 | let cfg = CfgExpr::parse(&tt); |
14 | assert_eq!(cfg, expected); | 14 | assert_eq!(cfg, expected); |
@@ -18,7 +18,7 @@ fn check_dnf(input: &str, expect: Expect) { | |||
18 | let (tt, _) = { | 18 | let (tt, _) = { |
19 | let source_file = ast::SourceFile::parse(input).ok().unwrap(); | 19 | let source_file = ast::SourceFile::parse(input).ok().unwrap(); |
20 | let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap(); | 20 | let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap(); |
21 | ast_to_token_tree(&tt).unwrap() | 21 | ast_to_token_tree(&tt) |
22 | }; | 22 | }; |
23 | let cfg = CfgExpr::parse(&tt); | 23 | let cfg = CfgExpr::parse(&tt); |
24 | let actual = format!("#![cfg({})]", DnfExpr::new(cfg)); | 24 | let actual = format!("#![cfg({})]", DnfExpr::new(cfg)); |
@@ -29,7 +29,7 @@ fn check_why_inactive(input: &str, opts: &CfgOptions, expect: Expect) { | |||
29 | let (tt, _) = { | 29 | let (tt, _) = { |
30 | let source_file = ast::SourceFile::parse(input).ok().unwrap(); | 30 | let source_file = ast::SourceFile::parse(input).ok().unwrap(); |
31 | let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap(); | 31 | let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap(); |
32 | ast_to_token_tree(&tt).unwrap() | 32 | ast_to_token_tree(&tt) |
33 | }; | 33 | }; |
34 | let cfg = CfgExpr::parse(&tt); | 34 | let cfg = CfgExpr::parse(&tt); |
35 | let dnf = DnfExpr::new(cfg); | 35 | let dnf = DnfExpr::new(cfg); |
@@ -42,7 +42,7 @@ fn check_enable_hints(input: &str, opts: &CfgOptions, expected_hints: &[&str]) { | |||
42 | let (tt, _) = { | 42 | let (tt, _) = { |
43 | let source_file = ast::SourceFile::parse(input).ok().unwrap(); | 43 | let source_file = ast::SourceFile::parse(input).ok().unwrap(); |
44 | let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap(); | 44 | let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap(); |
45 | ast_to_token_tree(&tt).unwrap() | 45 | ast_to_token_tree(&tt) |
46 | }; | 46 | }; |
47 | let cfg = CfgExpr::parse(&tt); | 47 | let cfg = CfgExpr::parse(&tt); |
48 | let dnf = DnfExpr::new(cfg); | 48 | let dnf = DnfExpr::new(cfg); |