Return an error when user provides an exact path
Dependencies
- [2]
VYPJUPPKHandle `GlobError::Build` in proc_macro error reporting - [3]
D652S2N3Rename `parse` module to `parse_fluent` - [4]
5FIVUZYFUnify `fluent_embed` macro API as `localize()` - [5]
5TEX4MNUSplit `fluent_embed` into `group` and `parse` modules - [6]
O77KA6C4Create `fluent_embed` crate - [7]
XGNME3WRMove `Group::derive_enum` to new `crate::parse_macro` module - [8]
UOMQT7LTAdd support for cardinal CLDR plural selectors - [9]
NO3PDO7PRefactor `fluent_embed` to support structs - [10]
V5S5K33AAdd basic error handling for invalid paths in proc_macro attribute - [11]
SHNZZSZGCreate `cli_macros` shim crate - [*]
VNSHGQYNSupport using glob paths in `localize` macro - [*]
UKFEFT6LCreate basic `Output` proc-macro
Change contents
- edit in fluent_embed/src/lib.rs at line 3
use std::path::PathBuf; - edit in fluent_embed/src/lib.rs at line 13
#[derive(thiserror::Error, Debug)]pub enum AttributeError {#[error("{0}")]Build(#[from] wax::BuildError),#[error("{0}")]Walk(#[from] wax::WalkError),#[error(":(")]NoMatches {path: PathBuf,complete_match: String,},} - replacement in fluent_embed/src/lib.rs at line 27
pub fn attribute_groups(path_literal: &syn::LitStr) -> Result<Group, wax::GlobError> {pub fn attribute_groups(path_literal: &syn::LitStr) -> Result<Group, AttributeError> { - replacement in fluent_embed/src/lib.rs at line 38
let captured_locale = entry.matched().get(1).unwrap();let captured_locale = if let Some(captured) = entry.matched().get(1) {captured} else {return Err(AttributeError::NoMatches {path: entry.path().to_path_buf(),complete_match: entry.matched().complete().to_string(),});}; - replacement in fluent_embed/src/lib.rs at line 63
) -> Result<TokenStream, wax::GlobError> {) -> Result<TokenStream, AttributeError> { - edit in fluent_embed/Cargo.toml at line 16
thiserror = "1.0.61" - edit in cli_macros/src/lib.rs at line 3
use fluent_embed::AttributeError; - edit in cli_macros/src/lib.rs at line 8
use wax::GlobError; - replacement in cli_macros/src/lib.rs at line 18
Err(glob_error) => {Err(attribute_error) => { - replacement in cli_macros/src/lib.rs at line 20
match glob_error {GlobError::Build(build_error) => {match attribute_error {AttributeError::Build(build_error) => { - replacement in cli_macros/src/lib.rs at line 47
GlobError::Walk(walk_error) => {AttributeError::Walk(walk_error) => { - edit in cli_macros/src/lib.rs at line 66
AttributeError::NoMatches {path,complete_match,} => {// Validate the assumption that the user has provided an exact pathassert!(path.exists());assert_eq!(path.to_string_lossy(), complete_match);emit_error! { derive_attribute, "cannot match against an exact path";help = "The attribute should use glob syntax to match against multiple files";note = "For example, you can:\n{}\n{}","- Match against directories: locale/**/errors.ftl","- Match against files: locale/*.ftl";};} - edit in Cargo.lock at line 119
"thiserror",