-
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.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.L-false-negativeLint: False negative (should have fired but didn't).Lint: False negative (should have fired but didn't).L-unconditional_recursionLint: unconditional_recursionLint: unconditional_recursionT-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
I tried this code:
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum TokenType {
LEFT_PAREN
}
impl std::fmt::Display for TokenType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "TokenType: {}", self)
}
}
#[derive(Debug, Clone)]
pub struct Token {
pub token_type: TokenType,
pub lexeme: String,
pub line: u16,
}
impl Token {
pub fn new(token_type: TokenType, lexeme: String, line: u16) -> Self {
Self {
token_type,
lexeme,
line,
}
}
}
impl ToString for Token {
fn to_string(&self) -> String {
format!(
"token_type: {}, lexeme: {}, line: {}",
self.token_type, self.lexeme, self.line
)
}
}
fn main() {
let token_new = Token::new(TokenType::LEFT_PAREN, "NIL".to_string(), 12);
println!("TOKEN: {}", token_new.token_type);
}
I expected to see this happen: Some error like this
error[E0277]: `token_type` doesn't implement `std::fmt::Display`
Instead, this happened:
TOKEN: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: TokenType: ...
thread 'main' has overflowed its stack
fatal runtime error: stack overflow
Meta
rustc --version --verbose
:
rustc 1.85.0 (4d91de4e4 2025-02-17)
binary: rustc
commit-hash: 4d91de4e48198da2e33413efdcd9cd2cc0c46688
commit-date: 2025-02-17
host: x86_64-unknown-linux-gnu
release: 1.85.0
LLVM version: 19.1.7
Backtrace
<backtrace>
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.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.L-false-negativeLint: False negative (should have fired but didn't).Lint: False negative (should have fired but didn't).L-unconditional_recursionLint: unconditional_recursionLint: unconditional_recursionT-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.