-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Rust-analyser not processing results from next() method of async_std::stream::StreamExt #4243
Comments
Maybe a duplicate of #1791? (types wrong with Content of the zip, for mobile usersuse async_amqp::*;
use async_std::stream::StreamExt;
use lapin::{
message::DeliveryResult, options::*, publisher_confirm::Confirmation, types::FieldTable,
BasicProperties, Connection, ConnectionProperties, Result,
};
use log::info;
use futures::channel::mpsc;
use futures::sink::SinkExt;
struct TaskProperty {
name: String,
sval: Option<String>,
nval: Option<i32>,
}
struct Task {
task_id: String,
task_ulid: String,
sample_id: String,
vm_profile: String,
task_properties: Vec<TaskProperty>,
}
#[async_std::main]
async fn main() -> Result<()> {
env_logger::init();
let (tx, mut rx)= mpsc::channel::<String>(100);
let addr = "amqp://localhost:5673";
let conn = Connection::connect(&addr, ConnectionProperties::default().with_async_std()).await?;
let queue_name = "bob";
info!("CONNECTED");
let channel_a = conn.create_channel().await?;
let channel_b = conn.create_channel().await?;
let queue = channel_a
.queue_declare(
queue_name,
QueueDeclareOptions::default(),
FieldTable::default(),
)
.await?;
info!("Declared queue {:?}", queue);
let consumer = channel_b
.clone()
.basic_consume(
queue_name,
"my_consumer",
BasicConsumeOptions::default(),
FieldTable::default(),
)
.await?;
consumer.set_delegate(move |delivery: DeliveryResult| {
let channel_b = channel_b.clone();
let mut tx = tx.clone();
async move {
let delivery = delivery.expect("error caught in in consumer");
if let Some(delivery) = delivery {
channel_b
.basic_ack(delivery.delivery_tag, BasicAckOptions::default())
.await
.expect("failed to ack");
tx.send(String::from_utf8(delivery.data).unwrap()).await.unwrap();
}
}
});
let payload = b"Hello world!";
let confirm = channel_a
.basic_publish(
"",
queue_name,
BasicPublishOptions::default(),
payload.to_vec(),
BasicProperties::default(),
)
.await?
.await?;
assert_eq!(confirm, Confirmation::NotRequested);
let res = rx.next().await.unwrap();
info!("Got {:?}", res);
Ok(())
} [package]
name = "ivm2_rust"
version = "0.1.0"
authors = ["Chris Mills <Chris_Mills@symantec.com>"]
edition = "2018"
[dependencies]
smol = "0.1.4"
log = "0.4.8"
async-amqp = "0.1.0-beta3"
env_logger = "0.7.1"
futures = "0.3.4"
[dependencies.async-std]
version = "^1.0"
features = ["default"]
[dev-dependencies.async-std]
version = "^1.0"
features = ["attributes", "default"]
[dependencies.lapin]
version = "1.0.0-beta3"
default-features = true |
It's worth noting that the failure is at the call to next() rather than the call to await. So not quite sure if it is the same thing. |
It looks to me like we're not managing to expand the |
Yeah, it is related to #4039 |
Great stuff, thanks. |
Update: we still don't resolve Or maybe we do, but it doesn't work on my system (#4676). |
A first step here might be to extract |
Somewhat minimized test case: macro_rules! extension_trait {
(
pub trait $name:ident {
$($body_base:tt)*
}
) => {
#[cfg(feature = "docs")]
pub trait $name {
extension_trait!(@doc () $($body_base)*);
}
};
(@doc ($($head:tt)*) $token:tt $($tail:tt)*) => {
extension_trait!(@doc ($($head)* $token) $($tail)*);
};
(@doc ($($head:tt)*)) => { $($head)* };
}
extension_trait! {
pub trait Stream {
type Item;
}
}
|
CC @edwin0cheng :-) |
Triage: #4243 (comment) still happens after the recent macro fixes. |
It is because we ignore macro expansion under |
This rabbit hole is quite deep :) The actual problem of
And noted that by default, Such that, there are no code to implement the |
Wait, why? Is that how it's supposed to work? |
The expansion in #4243 (comment) looks correct to me. After all, the |
Removing the |
I don't really understand what's being said in this thread, how do I configure rust-analyzer to work properly in this instance if it has been fixed? |
@PorkSausages it hasn't been fixed and I'm still not sure what's wrong. It was suggested above that this might be caused by some |
If I remove enough tokens from the This happens because |
|
Rust analyser is not able to process the next() method at the end of the attached rust file. This works ok with vs-code and rls, but vs-code with rust-analyzer it fails to return a type for the result of next().
src.zip
The text was updated successfully, but these errors were encountered: