Skip to content

Commit 83925bb

Browse files
committed
Use clearer variables names in guide test macro.
Also removes latent, unnecessary 'guide' test.
1 parent 336353c commit 83925bb

File tree

2 files changed

+12
-27
lines changed

2 files changed

+12
-27
lines changed

core/codegen/src/bang/test_guide.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,33 @@ use crate::syn_ext::syn_to_diag;
88
use crate::proc_macro2::TokenStream as TokenStream2;
99

1010
pub fn _macro(input: TokenStream) -> Result<TokenStream> {
11-
let root = syn::parse::<LitStr>(input.into()).map_err(syn_to_diag)?;
12-
let modules = entry_to_modules(&root)
13-
.map_err(|e| root.span().unstable().error(format!("failed to read: {}", e)))?;
11+
let root_glob = syn::parse::<LitStr>(input.into()).map_err(syn_to_diag)?;
12+
let modules = entry_to_modules(&root_glob)
13+
.map_err(|e| root_glob.span().unstable().error(format!("failed to read: {}", e)))?;
1414

15-
Ok(quote_spanned!(root.span() =>
15+
Ok(quote_spanned!(root_glob.span() =>
1616
#[allow(dead_code)]
1717
#[allow(non_camel_case_types)]
1818
mod test_site_guide { #(#modules)* }
1919
).into())
2020
}
2121

22-
fn entry_to_modules(pat: &LitStr) -> std::result::Result<Vec<TokenStream2>, Box<dyn Error>> {
22+
fn entry_to_modules(root_glob: &LitStr) -> std::result::Result<Vec<TokenStream2>, Box<dyn Error>> {
2323
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").expect("MANIFEST_DIR");
24-
let full_pat = Path::new(&manifest_dir).join(&pat.value()).display().to_string();
24+
let full_glob = Path::new(&manifest_dir).join(&root_glob.value()).display().to_string();
2525

2626
let mut modules = vec![];
27-
for path in glob::glob(&full_pat).map_err(|e| Box::new(e))? {
28-
let path = path.map_err(|e| Box::new(e))?;
27+
for path in glob::glob(&full_glob).map_err(Box::new)? {
28+
let path = path.map_err(Box::new)?;
2929
let name = path.file_name()
3030
.and_then(|f| f.to_str())
3131
.map(|name| name.trim_matches(|c| char::is_numeric(c) || c == '-')
32-
.replace('-', "_")
33-
.replace('.', "_"))
34-
.ok_or_else(|| "invalid file name".to_string())?;
32+
.replace(|c| c == '-' || c == '.', "_"))
33+
.ok_or_else(|| "invalid file name")?;
3534

36-
let ident = Ident::new(&name, pat.span());
35+
let ident = Ident::new(&name, root_glob.span());
3736
let full_path = Path::new(&manifest_dir).join(&path).display().to_string();
38-
modules.push(quote_spanned!(pat.span() =>
37+
modules.push(quote_spanned!(root_glob.span() =>
3938
#[doc(include = #full_path)]
4039
struct #ident;
4140
))

core/lib/tests/guide.rs

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)