aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/body.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def/src/body.rs')
-rw-r--r--crates/hir_def/src/body.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/crates/hir_def/src/body.rs b/crates/hir_def/src/body.rs
index 8bcc350ce..1080d9c2c 100644
--- a/crates/hir_def/src/body.rs
+++ b/crates/hir_def/src/body.rs
@@ -32,6 +32,7 @@ use crate::{
32 path::{ModPath, Path}, 32 path::{ModPath, Path},
33 src::HasSource, 33 src::HasSource,
34 AsMacroCall, BlockId, DefWithBodyId, HasModule, LocalModuleId, Lookup, ModuleId, 34 AsMacroCall, BlockId, DefWithBodyId, HasModule, LocalModuleId, Lookup, ModuleId,
35 UnresolvedMacro,
35}; 36};
36 37
37/// A subset of Expander that only deals with cfg attributes. We only need it to 38/// A subset of Expander that only deals with cfg attributes. We only need it to
@@ -101,10 +102,12 @@ impl Expander {
101 &mut self, 102 &mut self,
102 db: &dyn DefDatabase, 103 db: &dyn DefDatabase,
103 macro_call: ast::MacroCall, 104 macro_call: ast::MacroCall,
104 ) -> ExpandResult<Option<(Mark, T)>> { 105 ) -> Result<ExpandResult<Option<(Mark, T)>>, UnresolvedMacro> {
105 if self.recursion_limit + 1 > EXPANSION_RECURSION_LIMIT { 106 if self.recursion_limit + 1 > EXPANSION_RECURSION_LIMIT {
106 cov_mark::hit!(your_stack_belongs_to_me); 107 cov_mark::hit!(your_stack_belongs_to_me);
107 return ExpandResult::str_err("reached recursion limit during macro expansion".into()); 108 return Ok(ExpandResult::str_err(
109 "reached recursion limit during macro expansion".into(),
110 ));
108 } 111 }
109 112
110 let macro_call = InFile::new(self.current_file_id, &macro_call); 113 let macro_call = InFile::new(self.current_file_id, &macro_call);
@@ -116,14 +119,11 @@ impl Expander {
116 let call_id = 119 let call_id =
117 macro_call.as_call_id_with_errors(db, self.def_map.krate(), resolver, &mut |e| { 120 macro_call.as_call_id_with_errors(db, self.def_map.krate(), resolver, &mut |e| {
118 err.get_or_insert(e); 121 err.get_or_insert(e);
119 }); 122 })?;
120 let call_id = match call_id { 123 let call_id = match call_id {
121 Some(it) => it, 124 Ok(it) => it,
122 None => { 125 Err(_) => {
123 if err.is_none() { 126 return Ok(ExpandResult { value: None, err });
124 log::warn!("no error despite `as_call_id_with_errors` returning `None`");
125 }
126 return ExpandResult { value: None, err };
127 } 127 }
128 }; 128 };
129 129
@@ -141,9 +141,9 @@ impl Expander {
141 log::warn!("no error despite `parse_or_expand` failing"); 141 log::warn!("no error despite `parse_or_expand` failing");
142 } 142 }
143 143
144 return ExpandResult::only_err(err.unwrap_or_else(|| { 144 return Ok(ExpandResult::only_err(err.unwrap_or_else(|| {
145 mbe::ExpandError::Other("failed to parse macro invocation".into()) 145 mbe::ExpandError::Other("failed to parse macro invocation".into())
146 })); 146 })));
147 } 147 }
148 }; 148 };
149 149
@@ -151,7 +151,7 @@ impl Expander {
151 Some(it) => it, 151 Some(it) => it,
152 None => { 152 None => {
153 // This can happen without being an error, so only forward previous errors. 153 // This can happen without being an error, so only forward previous errors.
154 return ExpandResult { value: None, err }; 154 return Ok(ExpandResult { value: None, err });
155 } 155 }
156 }; 156 };
157 157
@@ -167,7 +167,7 @@ impl Expander {
167 self.current_file_id = file_id; 167 self.current_file_id = file_id;
168 self.ast_id_map = db.ast_id_map(file_id); 168 self.ast_id_map = db.ast_id_map(file_id);
169 169
170 ExpandResult { value: Some((mark, node)), err } 170 Ok(ExpandResult { value: Some((mark, node)), err })
171 } 171 }
172 172
173 pub(crate) fn exit(&mut self, db: &dyn DefDatabase, mut mark: Mark) { 173 pub(crate) fn exit(&mut self, db: &dyn DefDatabase, mut mark: Mark) {