Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error[E0423]: expected function, found macro log::set_boxed_logger - did you mean `log::set_boxed_logger!(...)? #303

Closed
iceiix opened this issue Oct 27, 2018 · 4 comments

Comments

@iceiix
Copy link

iceiix commented Oct 27, 2018

When updating a seemingly unrelated dependency (hyper 0.8.0, to either hyper 0.12.11 or reqwest 0.9.4), I get an error related to setting the boxed logger:

error[E0423]: expected function, found macro `log::set_boxed_logger`                                                                                                                                               
   --> src/main.rs:183:5                                                                                                                                                                                           
    |                                                                                                                                                                                                              
183 |     log::set_boxed_logger(Box::new(proxy))                                                                                                                                                                   
    |     ^^^^^^^^^^^^^^^^^^^^^ did you mean `log::set_boxed_logger!(...)`?                                                                                                                                        
                                                                                                                                                                                                                   
error: aborting due to previous error                                                                                                                                                                              
                                                                                                                                                                                                                   
For more information about this error, try `rustc --explain E0423`.             

I could try to regress further, but any idea what could cause this? If I try the compiler's suggestion, then log::set_boxed_logger! isn't found (and that doesn't match the documentation either so I don't think it is right).

@sfackler
Copy link
Member

That's very strange - set_boxed_logger is definitely a function and not a macro! Probably worth filing this over on rust-lang/rust since it seems like a compiler bug.

@iceiix
Copy link
Author

iceiix commented Oct 29, 2018

The incorrect "expected function, found macro" compile error looks like rust-lang/rust#40788

Found a fix: needed to update the Cargo.toml dependency in my project to include the "std" feature:

-log = "0.4.5"
+log = { version = "0.4.5", features = ["std"] }

@iceiix
Copy link
Author

iceiix commented Oct 29, 2018

Minimal example:

src/main.rs:

#[macro_use]
extern crate log;

fn main() {
    log::set_boxed_logger(Box::new(1));
}

Cargo.toml:

[package]
name = "logtest"
version = "0.1.0"

[dependencies]
#log = { version = "0.4.6", features = ["std"] }
log = "0.4.6"

Fails with:

error[E0423]: expected function, found macro `log::set_boxed_logger`                                                                                 
 --> src/main.rs:6:5                                                                                                                                 
  |                                                                                                                                                  
6 |     log::set_boxed_logger(Box::new(1));                                                                                                          
  |     ^^^^^^^^^^^^^^^^^^^^^ did you mean `log::set_boxed_logger!(...)`?                                                                            
                                                                                                                                                     
warning: unused `#[macro_use]` import                                                                                                                
 --> src/main.rs:1:1                                                                                                                                 
  |                                                                                                                                                  
1 | #[macro_use]                                                                                                                                     
  | ^^^^^^^^^^^^                                                                                                                                     
  |                                                                                                                                                  
  = note: #[warn(unused_imports)] on by default                                                                                                      
                                                                                                                                                     
error: aborting due to previous error                                

@rakhmanu
Copy link

adding std does not work for me I have the same issue with logging E0423

EFanZh pushed a commit to EFanZh/log that referenced this issue Jul 23, 2023
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants