-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
thread 'rustc' panicked at 'called Result::unwrap()
on an Err
value: DistinctSources(DistinctSources
#66805
Comments
Please provide the source code needed to reproduce this. Backtrace:
|
Might be a duplicate of #63800, please retry with the newest nightly |
Same thing on the nightly. I will try to distill code just to capture the
bug.
…On Wed, 27 Nov 2019, 10:34 Jonas Schievink, ***@***.***> wrote:
Might be a duplicate of #63800
<#63800>, please retry with the
newest nightly
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#66805?email_source=notifications&email_token=AGEJLLGVLGLKN2NEQLUGZGLQVZELXA5CNFSM4JSEVCYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFJB62I#issuecomment-559030121>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGEJLLEH2563FG5SGTXCV23QVZELXANCNFSM4JSEVCYA>
.
|
code to reproduce the problem |
Thanks! |
same behavior with async-stream = "0.2.0" |
reduced (but not minimal yet): pub fn func() {}
fn main() {
let s = async_stream::stream! {
Ok(0_i32)?;
yield func();
};
} Seems to be an issue with the |
triage: P-high. Removing nomination label. |
I tried to boil it down and am now have three files. One
#![feature(proc_macro_hygiene)]
use std::marker::PhantomData;
use pm::crash;
mod a;
struct Sender<T> {
_p: PhantomData<T>,
}
impl<T> Sender<T> {
fn new() -> Self { unimplemented!() }
fn send(self, _: T) {}
}
fn func() {}
fn main() {
stream! {
()?;
yield func();
}
}
#[macro_export]
macro_rules! stream {
($($body:tt)*) => {{
crash! {
{
$($body)*
}
}
stream_0!()
}}
}
extern crate proc_macro;
use proc_macro::{Group, TokenStream, TokenTree};
use quote::quote;
use syn::visit_mut::VisitMut;
struct Dummy;
impl VisitMut for Dummy {
fn visit_expr_mut(&mut self, i: &mut syn::Expr) {
match i {
syn::Expr::Yield(yield_expr) => {
let value_expr = yield_expr.expr.as_ref().unwrap();
*i = syn::parse_quote! { __yield_tx.send(#value_expr)}
}
syn::Expr::Try(try_expr) => {
let e = &try_expr.expr;
*i = syn::parse_quote! { __yield_tx.send(Err(#e)) };
}
_ => (),
}
}
}
fn replace_for_await(input: TokenStream) -> TokenStream {
input.into_iter().map(|token| {
match token {
TokenTree::Group(group) => {
let stream = replace_for_await(group.stream());
Group::new(group.delimiter(), stream).into()
}
_ => token
}
}).collect()
}
#[proc_macro]
pub fn crash(input: TokenStream) -> TokenStream {
let inner = replace_for_await(input);
let syn::Block { mut stmts, .. } = syn::parse(inner).unwrap();
for mut stmt in &mut stmts[..] {
Dummy.visit_stmt_mut(&mut stmt);
}
quote!(
let __yield_tx = crate::Sender::new();
macro_rules! stream_0 {
() => {{
#(#stmts)*
}}
}
)
.into()
} where the [package]
name = "pm"
version = "0.0.0"
edition = "2018"
[lib]
proc-macro = true
[dependencies]
syn = { version = "1", features = ["full", "visit-mut"]}
quote = "1" |
This is indeed very similar to #63800 . The clue is, that a proc macro must create a macro_rules macro and then it must be called within the other macro (in this case I added the @matthewjasper you fix the original problem. Would you like to take a guess what's happening? |
I've seen something similiar. I don't know if it's the same or not but this is what I've got
Let me know if there's any other information you need. |
A pretty small reproduction was posted in #68605 |
I'm having the same issue on rustc 1.41.0 (5e1a799 2020-01-27) running on x86_64-unknown-linux-gnu |
The issue I was running into does not break when I change to nightly: |
Marking as needs test - from reading this thread, seems like this might be fixed (though feel free to remove label if this isn't the case) |
I made two changes: 1) Adding Removing priority label. |
Compiler panics. Debugging info attached. I would expect the compiler not to crash and print an error.
out.txt
The text was updated successfully, but these errors were encountered: