File tree Expand file tree Collapse file tree 3 files changed +45
-1
lines changed Expand file tree Collapse file tree 3 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -687,6 +687,16 @@ impl GlobalContext {
687687 } => anyhow ! (
688688 "unexpected variable `{variable}` in build.build-dir path `{raw_template}`"
689689 ) ,
690+ path:: ResolveTemplateError :: UnexpectedBracket { bracket_type, raw_template } => {
691+ let ( btype, literal) = match bracket_type {
692+ path:: BracketType :: Opening => ( "opening" , "{" ) ,
693+ path:: BracketType :: Closing => ( "closing" , "}" ) ,
694+ } ;
695+
696+ anyhow ! (
697+ "unexpected {btype} bracket `{literal}` in build.build-dir path `{raw_template}`"
698+ )
699+ }
690700 } ) ?;
691701
692702 // Check if the target directory is set to an empty string in the config.toml file.
Original file line number Diff line number Diff line change @@ -58,6 +58,20 @@ impl ConfigRelativePath {
5858 } ) ;
5959 } ;
6060
61+ if value. contains ( "{" ) {
62+ return Err ( ResolveTemplateError :: UnexpectedBracket {
63+ bracket_type : BracketType :: Opening ,
64+ raw_template : self . 0 . val . clone ( ) ,
65+ } ) ;
66+ }
67+
68+ if value. contains ( "}" ) {
69+ return Err ( ResolveTemplateError :: UnexpectedBracket {
70+ bracket_type : BracketType :: Closing ,
71+ raw_template : self . 0 . val . clone ( ) ,
72+ } ) ;
73+ }
74+
6175 Ok ( self . 0 . definition . root ( gctx) . join ( & value) )
6276 }
6377
@@ -139,4 +153,14 @@ pub enum ResolveTemplateError {
139153 variable : String ,
140154 raw_template : String ,
141155 } ,
156+ UnexpectedBracket {
157+ bracket_type : BracketType ,
158+ raw_template : String ,
159+ } ,
160+ }
161+
162+ #[ derive( Debug ) ]
163+ pub enum BracketType {
164+ Opening ,
165+ Closing ,
142166}
Original file line number Diff line number Diff line change @@ -685,7 +685,7 @@ fn template_workspace_path_hash_should_handle_symlink() {
685685}
686686
687687#[ cargo_test]
688- fn template_should_handle_ignore_unmatched_brackets ( ) {
688+ fn template_should_handle_reject_unmatched_brackets ( ) {
689689 let p = project ( )
690690 . file ( "src/lib.rs" , "" )
691691 . file (
@@ -699,6 +699,11 @@ fn template_should_handle_ignore_unmatched_brackets() {
699699
700700 p. cargo ( "build -Z build-dir" )
701701 . masquerade_as_nightly_cargo ( & [ "build-dir" ] )
702+ . with_status ( 101 )
703+ . with_stderr_data ( str![ [ r#"
704+ [ERROR] unexpected opening bracket `{` in build.build-dir path `foo/{bar`
705+
706+ "# ] ] )
702707 . run ( ) ;
703708
704709 let p = project ( )
@@ -714,6 +719,11 @@ fn template_should_handle_ignore_unmatched_brackets() {
714719
715720 p. cargo ( "build -Z build-dir" )
716721 . masquerade_as_nightly_cargo ( & [ "build-dir" ] )
722+ . with_status ( 101 )
723+ . with_stderr_data ( str![ [ r#"
724+ [ERROR] unexpected closing bracket `}` in build.build-dir path `foo/}bar`
725+
726+ "# ] ] )
717727 . run ( ) ;
718728}
719729
You can’t perform that action at this time.
0 commit comments