-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Hi,
I ma working with edition 2018 and I tried this piece of code with 1.37 nightly, 1.35 and 1.32 (random pick) with the same result.
Sorry if the point of my issue is at the end but I belive that the code is much more clear than me.
The code is:
lib.rs:
extern crate proc_macro;
use proc_macro::TokenStream;
#[proc_macro_derive(TestMacro)]
pub fn derive_answer_fn(input: TokenStream) -> TokenStream {
let name = input.into_iter().nth(1).unwrap();
format!(
r#"
pub trait A {{
fn f() -> Self;
}}
#[deny(unconditional_recursion)]
impl A for {0} {{
fn f() -> Self {{
let a = 0;
<{0} as A>::f()
}}
}}"#, name.to_string()
).parse().unwrap()
}
test.rs:
use m::TestMacro;
#[derive(TestMacro)]
struct Struct;
fn main() {
Struct::f();
}
I thought my test code would behave like:
struct Struct;
pub trait A {
fn f() -> Self;
}
#[deny(unconditional_recursion)]
impl A for Struct {
fn f() -> Self {
<Struct as A>::f()
}
}
fn main() {
Struct::f();
}
giving this error:
error: function cannot return without recursing
instead compiles and (obviously)
thread 'main' has overflowed its stack
fatal runtime error: stack overflow
Am I doing something wrong?
When does the linter check my code?
Is this a normal behavoir?
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.