I'm trying to install racer using cargo install:
cargo +nightly install racer
And at some point it fails with these errors:
Compiling racer v2.2.2
error[E0053]: method `fallback_fluent_bundle` has an incompatible type for trait
--> /home/username/.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.2.2/src/racer/ast.rs:36:41
|
36 | fn fallback_fluent_bundle(&self) -> &Lrc<rustc_errors::FluentBundle> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| expected struct `fluent_bundle::bundle::FluentBundle`, found struct `Lrc`
| help: change the output type to match the trait: `&fluent_bundle::bundle::FluentBundle<fluent_bundle::resource::FluentResource, intl_memoizer::IntlLangMemoizer>`
|
= note: expected fn pointer `fn(&DummyEmitter) -> &fluent_bundle::bundle::FluentBundle<fluent_bundle::resource::FluentResource, intl_memoizer::IntlLangMemoizer>`
found fn pointer `fn(&DummyEmitter) -> &Lrc<fluent_bundle::bundle::FluentBundle<fluent_bundle::resource::FluentResource, intl_memoizer::IntlLangMemoizer>>`
error[E0023]: this pattern has 5 fields, but the corresponding tuple variant has 6 fields
--> /home/username/.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.2.2/src/racer/ast.rs:232:31
|
232 | visit::FnKind::Fn(_, _, ref fn_sig, _, _) => &*fn_sig.decl,
| ^ ^ ^^^^^^^^^^ ^ ^ expected 6 fields, found 5
|
help: use `_` to explicitly ignore each field
|
232 | visit::FnKind::Fn(_, _, ref fn_sig, _, _, _) => &*fn_sig.decl,
| +++
Some errors have detailed explanations: E0023, E0053, E0277.
For more information about an error, try `rustc --explain E0023`.
error: could not compile `racer` due to 7 previous errors
How to fix it? What's causing it?
rustc --version
rustc 1.63.0 (4b91a6ea7 2022-08-08)
cargo --version
cargo 1.63.0 (fd9c4297c 2022-07-01)
echo $RUST_SRC_PATH
/home/username/.cargo/bin
Related
When compiling a project, it throws errors from the detour-rs crate:
Compiling detour v0.8.0 (https://github.com/darfink/detour-rs?rev=3b6f17a#3b6f17a8)
error[E0059]: type parameter to bare `Fn` trait must be a tuple
--> C:\Users\Станислав\.cargo\git\checkouts\detour-rs-497fa4e2739f3073\3b6f17a\src\detours\statik.rs:106:8
|
106 | D: Fn<T::Arguments, Output = T::Output> + Send + 'static,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Tuple` is not implemented for `<T as Function>::Arguments`
|
note: required by a bound in `Fn`
help: consider further restricting the associated type
|
106 | D: Fn<T::Arguments, Output = T::Output> + Send + 'static, <T as Function>::Arguments: Tuple
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error[E0059]: type parameter to bare `Fn` trait must be a tuple
--> C:\Users\Станислав\.cargo\git\checkouts\detour-rs-497fa4e2739f3073\3b6f17a\src\detours\statik.rs:157:8
|
157 | C: Fn<T::Arguments, Output = T::Output> + Send + 'static,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Tuple` is not implemented for `<T as Function>::Arguments`
|
note: required by a bound in `Fn`
help: consider further restricting the associated type
|
157 | C: Fn<T::Arguments, Output = T::Output> + Send + 'static, <T as Function>::Arguments: Tuple
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For more information about this error, try `rustc --explain E0059`.
error: could not compile `detour` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
I tried changing the version of detour-rs, but that didn't help. How to fix it?
detour relies on using nightly Rust features to implement the static_detour! macro.
Nightly features are unstable and subject to change without warning - and in this case, it looks like that is what's happened.
Your options are:
If you are not using static_detour!, disable the default feature flags of the crate to avoid including this in the build.
detour = { version = "0.8", default-features = false }
Wait for the crate to update to support the latest nightly (though note that detour hasn't had commits since 2021).
Or alternatively, fork the crate and do the update yourself.
Downgrade to an earlier nightly version of Rust.
Commands for downgrading rust toolchain that helped me with this problem
rustup toolchain install nightly-2022-10-29-x86_64-pc-windows-msvc
rustup default nightly-2022-10-29-x86_64-pc-windows-msvc
I am setting up this project to help me pass authorization data between each subgraphs. I have an authorization subgraph to gather the data so the router will have to make a graphql query to the authorization subgraph and then pass it along. I picked graphql_client dependency because it's the same one that Apollo uses and it seems to have a lot of support compare to the other Rust graphql clients however when I add this dependency, it breaks another dependency. These are the steps
set up context example project -> https://github.com/apollographql/router/tree/v0.1.0-preview.6/examples/context
add these as dependency in Cargo.toml
graphql_client = { version = "0.10.0", features = ["reqwest-blocking"] }
reqwest = { version = "0.11.10", features = ["blocking"] }
run cargo build
see error
Compiling launchpad v0.1.0 (https://github.com/apollographql/rover.git?rev=94141242ba34cf00cde9630fc4a6dcd05d4fa5da#94141242)
error[E0433]: failed to resolve: use of undeclared type `HeaderMap`
--> /Users/macuser/.cargo/git/checkouts/rover-efd9f422be37a06b/9414124/crates/launchpad/src/introspect/runner.rs:30:26
|
30 | let mut header_map = HeaderMap::new();
| ^^^^^^^^^ not found in this scope
|
help: consider importing this struct
|
1 | use reqwest::header::HeaderMap;
|
error[E0433]: failed to resolve: use of undeclared type `HeaderName`
--> /Users/macuser/.cargo/git/checkouts/rover-efd9f422be37a06b/9414124/crates/launchpad/src/introspect/runner.rs:33:13
|
33 | HeaderName::from_bytes(header_key.as_bytes())?,
| ^^^^^^^^^^ not found in this scope
|
help: consider importing this struct
|
1 | use reqwest::header::HeaderName;
|
error[E0433]: failed to resolve: use of undeclared type `HeaderValue`
--> /Users/macuser/.cargo/git/checkouts/rover-efd9f422be37a06b/9414124/crates/launchpad/src/introspect/runner.rs:34:13
|
34 | HeaderValue::from_str(&header_value)?,
| ^^^^^^^^^^^ not found in this scope
|
help: consider importing this struct
|
1 | use reqwest::header::HeaderValue;
|
error[E0659]: `reqwest` is ambiguous
--> /Users/macuser/.cargo/git/checkouts/rover-efd9f422be37a06b/9414124/crates/launchpad/src/introspect/runner.rs:6:5
|
6 | use reqwest::header::{HeaderMap, HeaderName, HeaderValue};
| ^^^^^^^ ambiguous name
|
= note: ambiguous because of multiple potential import sources
= note: `reqwest` could refer to a crate passed with `--extern`
= help: use `::reqwest` to refer to this crate unambiguously
note: `reqwest` could also refer to the module imported here
--> /Users/macuser/.cargo/git/checkouts/rover-efd9f422be37a06b/9414124/crates/launchpad/src/introspect/runner.rs:5:5
|
5 | use graphql_client::*;
| ^^^^^^^^^^^^^^^^^
= help: use `self::reqwest` to refer to this module unambiguously
Dependency tree is apollo router -> uplink -> rover (branch = geal/launchpad)
I posted this same issue on apollo/router repo and they said it'll be fix soon
https://github.com/apollographql/router/issues/937#issuecomment-1114995491
You need to configure your subgraph to receive it.
I am new to rust and embedded systems. I was reading and going along "The Discovery Book" and I can't seem to figure out the errors below.
I have placed this in my main.rs:
#![deny(unsafe_code)]
#![no_main]
#![no_std]
use aux5::{entry, prelude::*, Delay, Leds};
#[entry]
fn main() -> ! {
let (mut delay, mut leds): (Delay, Leds) = aux5::init();
let half_period = 500_u16;
loop {
leds[0].on();
delay.delay_ms(half_period);
leds[0].off();
delay.delay_ms(half_period);
}
}
My auxiliary lib.rs contains:
pub use stm32f3_discovery::{leds::Leds, stm32f3xx_hal, switch_hal};
pub use switch_hal::{ActiveHigh, OutputSwitch, Switch, ToggleableOutputSwitch};
use stm32f3xx_hal::prelude::*;
pub use stm32f3xx_hal::{
delay::Delay,
gpio::{gpioe, Output, PushPull},
hal::blocking::delay::DelayMs,
stm32,
};
pub type LedArray = [Switch<gpioe::PEx<Output<PushPull>>, ActiveHigh>; 8];
pub fn init() -> (Delay, LedArray) {
let device_periphs = stm32::Peripherals::take().unwrap();
let mut reset_and_clock_control = device_periphs.RCC.constrain();
let core_periphs = cortex_m::Peripherals::take().unwrap();
let mut flash = device_periphs.FLASH.constrain();
let clocks = reset_and_clock_control.cfgr.freeze(&mut flash.acr);
let delay = Delay::new(core_periphs.SYST, clocks);
// initialize user leds
let mut gpioe = device_periphs.GPIOE.split(&mut reset_and_clock_control.ahb);
let leds = Leds::new(
gpioe.pe8,
gpioe.pe9,
gpioe.pe10,
gpioe.pe11,
gpioe.pe12,
gpioe.pe13,
gpioe.pe14,
gpioe.pe15,
&mut gpioe.moder,
&mut gpioe.otyper,
);
(delay, leds.into_array())
}
I have not changed anything in lib.rs and I am following the instructions from the book, along with the source code.
Running the code results in the following errors when building for the target:
error[E0432]: unresolved import `aux5::prelude`
--> src\05-led-roulette\src\main.rs:5:19
|
5 | use aux5::{entry, prelude::*, Delay, Leds};
| ^^^^^^^ could not find `prelude` in `aux5`
error[E0308]: mismatched types
--> src\05-led-roulette\src\main.rs:9:48
|
9 | let (mut delay, mut leds): (Delay, Leds) = aux5::init();
| ------------- ^^^^^^^^^^^^ expected struct `Leds`, found array of 8 elements
| |
| expected due to this
|
= note: expected tuple `(Delay, Leds)`
found tuple `(Delay, [Switch<PEx<Output<PushPull>>, ActiveHigh>; 8])`
error[E0608]: cannot index into a value of type `Leds`
--> src\05-led-roulette\src\main.rs:14:9
|
14 | leds[0].on();
| ^^^^^^^
error[E0599]: no method named `delay_ms` found for struct `Delay` in the current scope
--> src\05-led-roulette\src\main.rs:15:15
|
15 | delay.delay_ms(half_period);
| ^^^^^^^^ method not found in `Delay`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
5 | use aux5::DelayMs;
|
error[E0608]: cannot index into a value of type `Leds`
--> src\05-led-roulette\src\main.rs:17:9
|
17 | leds[0].off();
| ^^^^^^^
error[E0599]: no method named `delay_ms` found for struct `Delay` in the current scope
--> src\05-led-roulette\src\main.rs:18:15
|
18 | delay.delay_ms(half_period);
| ^^^^^^^^ method not found in `Delay`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
5 | use aux5::DelayMs;
|
error: aborting due to 6 previous errors
Some errors have detailed explanations: E0308, E0432, E0599, E0608.
For more information about an error, try `rustc --explain E0308`.
error: could not compile `led-roulette`
To learn more, run the command again with --verbose.
From the following page, "The Led and Delay abstractions", it looks like this is the set of imports that you need.
use aux5::{entry, Delay, DelayMs, LedArray, OutputSwitch};
In the above abstraction, compared to your main.rs, note the:
Addition of DelayMs trait, making .delay_ms() available.
Removal of a prelude as it is not being used.
Change from Leds to the expected LedArray.
Also see:
Stack Overflow, "Why do I need to import a trait to use the methods it defines for a type?"
Consider the following example:
use std::env;
use std::path::Path;
fn main() {
let args: Vec<_> = env::args().collect();
let out_path: String = args[2];
let _path = Path::new(out_path);
}
Here's the error I'm getting while compiling:
error[E0308]: mismatched types
--> main.rs:8:27
|
8 | let _path = Path::new(out_path);
| ^^^^^^^^
| |
| expected reference, found struct `std::string::String`
| help: consider borrowing here: `&out_path`
|
= note: expected type `&_`
found type `std::string::String`
Now if I follow compiler's suggestion, I get this:
error[E0507]: cannot move out of indexed content
--> main.rs:7:28
|
7 | let out_path: String = args[2];
| ^^^^^^^
| |
| cannot move out of indexed content
| help: consider using a reference instead: `&args[2]`
error: aborting due to previous error
Which, after applying the suggestion, leads me to the previous error:
error[E0308]: mismatched types
--> main.rs:7:28
|
7 | let out_path: String = &args[2];
| ^^^^^^^^
| |
| expected struct `std::string::String`, found reference
| help: consider removing the borrow: `args[2]`
|
= note: expected type `std::string::String`
found type `&std::string::String`
How can I understand the situation and solve the problem?
This was indeed an unfortunate sequence of suggestions (use a reference > remove that reference), but this was caused by the manual type ascription related to out_path.
You want a string slice, not an owned String:
let out_path: &str = &args[2];
This fits both the restriction of args (you can't move out of indexed content) and the requirements of Path::new, which requires a reference.
As for your comment, a clone() "fixes" the cannot move out of indexed content error because it doesn't require a move from the args vector - it copies an element from it instead. This fix is of course inferior to just borrowing it, which also works with Path::new.
I am trying to update cargo: cargo install cargo-update, but I'm faced with the following error:
Compiling semver-parser v0.7.0
error: the `?` operator is not stable (see issue #31436)
--> /home/netlab/.cargo/registry/src/github.com-1ecc6299db9ec823/semver-parser-0.7.0/src/version.rs:56:26
|
56 | let (pre, pre_len) = common::parse_optional_meta(&s[i..], b'-')?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: the `?` operator is not stable (see issue #31436)
--> /home/netlab/.cargo/registry/src/github.com-1ecc6299db9ec823/semver-parser-0.7.0/src/version.rs:58:30
|
58 | let (build, build_len) = common::parse_optional_meta(&s[i..], b'+')?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: the `?` operator is not stable (see issue #31436)
--> /home/netlab/.cargo/registry/src/github.com-1ecc6299db9ec823/semver-parser-0.7.0/src/range.rs:133:26
|
133 | let (pre, pre_len) = common::parse_optional_meta(&s[i..], b'-')?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It depends on your Rust version — with versions of Rust before 1.13 you will receive the error because the operator wasn't stable in these versions.
Your error message refers to a GitHub issue number.