You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Its a little annoying that one has to prefix references to "unusual" types with super:: when using the condition! macro, as demonstrated for example by this code in the conditions tutorial:
// Modify the condition signature to return the new enum.// Note: a condition introduces a new module, so the enum must be// named with the `super::` prefix to access it.condition!{pub malformed_line : ~str -> super::MalformedLineFix;}
The necessity of the super:: prefix is a side-effect of the condition macro expanding into its own module.
But we could get around this if we changed the condition macro to import its parent module's pub declarations, via use super::*;, as illustrated in this code:
pubmod a {pubuse c_i = std::libc::c_int;// condition! { pub grr1: int -> c_i; } // does not workcondition!{pub grr2: int -> super::c_i;// standard way to cope with above}// but another way to "fix" the problem is to expand into:pubmod grr3 {#[allow(non_uppercase_statics)];usesuper::*;// <-- THIS LINE IS NEW IN THE EXPANSIONstatic key:::std::local_data::Key<
@::std::condition::Handler<int,c_i>> =
&::std::local_data::Key;pubstatic cond :::std::condition::Condition<int,c_i> =
::std::condition::Condition{name:stringify!(grr3),key: key
};}pubfnf(x:int) -> c_i{if x % 2 == 0{
grr2::cond.raise(x)}else{
grr3::cond.raise(x)}}}fnmain(){use std::libc::c_int;let result :c_int = do a::grr3::cond.trap(|whoops| {println(fmt!("hi from %?", whoops));4as std::libc::c_int}).inside{100 + a::f(173)};println(fmt!("result: %d", result as int));}
The text was updated successfully, but these errors were encountered:
Fix imports for "Checking if a type defines a specific method"
The import of `clippy_utils::is_type_diagnostic_item` would cause this error:
```
error[E0432]: unresolved import `clippy_utils::is_type_diagnostic_item
```
changelog: none
Its a little annoying that one has to prefix references to "unusual" types with
super::
when using thecondition!
macro, as demonstrated for example by this code in the conditions tutorial:The necessity of the
super::
prefix is a side-effect of the condition macro expanding into its own module.But we could get around this if we changed the condition macro to import its parent module's pub declarations, via
use super::*;
, as illustrated in this code:The text was updated successfully, but these errors were encountered: