Merge pull request #3491 from davidhewitt/pymethods-macro-error
emit compile errors on macros inside `#[pymethods]`
This commit is contained in:
commit
5b7885b7ee
|
@ -0,0 +1 @@
|
||||||
|
Emit compile errors instead of ignoring macro invocations inside `#[pymethods]` blocks.
|
|
@ -149,7 +149,12 @@ pub fn impl_methods(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => (),
|
syn::ImplItem::Macro(m) => bail_spanned!(
|
||||||
|
m.span() =>
|
||||||
|
"macros cannot be used as items in `#[pymethods]` impl blocks\n\
|
||||||
|
= note: this was previously accepted and ignored"
|
||||||
|
),
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -170,4 +170,13 @@ impl DuplicateMethod {
|
||||||
fn func_b(&self) {}
|
fn func_b(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro_rules! macro_invocation {
|
||||||
|
() => {};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[pymethods]
|
||||||
|
impl MyClass {
|
||||||
|
macro_invocation!();
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -133,6 +133,13 @@ error: Python objects are shared, so 'self' cannot be moved out of the Python in
|
||||||
144 | fn method_self_by_value(self) {}
|
144 | fn method_self_by_value(self) {}
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
||||||
|
error: macros cannot be used as items in `#[pymethods]` impl blocks
|
||||||
|
= note: this was previously accepted and ignored
|
||||||
|
--> tests/ui/invalid_pymethods.rs:179:5
|
||||||
|
|
|
||||||
|
179 | macro_invocation!();
|
||||||
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0119]: conflicting implementations of trait `pyo3::impl_::pyclass::PyClassNewTextSignature<TwoNew>` for type `pyo3::impl_::pyclass::PyClassImplCollector<TwoNew>`
|
error[E0119]: conflicting implementations of trait `pyo3::impl_::pyclass::PyClassNewTextSignature<TwoNew>` for type `pyo3::impl_::pyclass::PyClassImplCollector<TwoNew>`
|
||||||
--> tests/ui/invalid_pymethods.rs:149:1
|
--> tests/ui/invalid_pymethods.rs:149:1
|
||||||
|
|
|
|
||||||
|
|
Loading…
Reference in New Issue