Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/hir-def/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ in-rust-tree = ["hir-expand/in-rust-tree"]

[lints]
workspace = true

[package.metadata.cargo-machete]
ignored = ["ra-ap-rustc_parse_format"]
10 changes: 6 additions & 4 deletions crates/hir-def/src/item_tree/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use hir_expand::{
use intern::{Interned, Symbol, sym};
use syntax::{AstNode, ast};
use syntax_bridge::DocCommentDesugarMode;
use tt::token_to_literal;
use tt::literal_from_str;

use crate::item_tree::lower::Ctx;

Expand Down Expand Up @@ -64,11 +64,13 @@ impl AttrsOrCfg {
ast::Meta::KeyValueMeta(meta) => {
let span = span_map.span_for(path_range);
let input = meta.expr().and_then(|value| {
if let ast::Expr::Literal(value) = value {
Some(Box::new(AttrInput::Literal(token_to_literal(
if let ast::Expr::Literal(value) = value
&& let Ok(lit) = literal_from_str(
value.token().text(),
span_map.span_for(value.syntax().text_range()),
))))
)
{
Some(Box::new(AttrInput::Literal(lit)))
} else {
None
}
Expand Down
8 changes: 3 additions & 5 deletions crates/hir-def/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]

#[cfg(feature = "in-rust-tree")]
extern crate rustc_parse_format;

#[cfg(not(feature = "in-rust-tree"))]
extern crate ra_ap_rustc_parse_format as rustc_parse_format;
stdx::rustc_crates! {
extern crate rustc_parse_format or ra_ap_rustc_parse_format;
}

pub extern crate ra_ap_rustc_abi as layout;
pub extern crate ra_ap_rustc_abi as rustc_abi;
Expand Down
6 changes: 3 additions & 3 deletions crates/load-cargo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ use ide_db::{
};
use itertools::Itertools;
use proc_macro_api::{
MacroDylib, ProcMacroClient,
bidirectional_protocol::msg::{ParentSpan, SubRequest, SubResponse},
client::{MacroDylib, ProcMacroClient},
};
use project_model::{CargoConfig, PackageRoot, ProjectManifest, ProjectWorkspace};
use span::{Span, SpanAnchor, SyntaxContext};
Expand Down Expand Up @@ -558,7 +558,7 @@ fn load_crate_graph_into_db(
}

fn expander_to_proc_macro(
expander: proc_macro_api::ProcMacro,
expander: proc_macro_api::client::ProcMacro,
ignored_macros: &[Box<str>],
) -> ProcMacro {
let name = expander.name();
Expand All @@ -577,7 +577,7 @@ fn expander_to_proc_macro(
}

#[derive(Debug, PartialEq, Eq)]
struct Expander(proc_macro_api::ProcMacro);
struct Expander(proc_macro_api::client::ProcMacro);

impl ProcMacroExpander for Expander {
fn expand(
Expand Down
3 changes: 3 additions & 0 deletions crates/mbe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ in-rust-tree = ["parser/in-rust-tree", "tt/in-rust-tree"]

[lints]
workspace = true

[package.metadata.cargo-machete]
ignored = ["ra-ap-rustc_lexer"]
7 changes: 3 additions & 4 deletions crates/mbe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]

#[cfg(not(feature = "in-rust-tree"))]
extern crate ra_ap_rustc_lexer as rustc_lexer;
#[cfg(feature = "in-rust-tree")]
extern crate rustc_lexer;
stdx::rustc_crates! {
extern crate rustc_lexer or ra_ap_rustc_lexer;
}

mod expander;
mod macro_call_style;
Expand Down
76 changes: 38 additions & 38 deletions crates/mbe/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,20 @@ struct MyTraitMap2
IDENT MyTraitMap2 1:Root[0000, 0]@8..19#ROOT2024
SUBTREE {} 0:Root[0000, 0]@48..49#ROOT2024 0:Root[0000, 0]@100..101#ROOT2024
IDENT map 0:Root[0000, 0]@58..61#ROOT2024
PUNCH : [alone] 0:Root[0000, 0]@61..62#ROOT2024
PUNCH : [joint] 0:Root[0000, 0]@63..64#ROOT2024
PUNCH : [alone] 0:Root[0000, 0]@64..65#ROOT2024
PUNCT : [alone] 0:Root[0000, 0]@61..62#ROOT2024
PUNCT : [joint] 0:Root[0000, 0]@63..64#ROOT2024
PUNCT : [alone] 0:Root[0000, 0]@64..65#ROOT2024
IDENT std 0:Root[0000, 0]@65..68#ROOT2024
PUNCH : [joint] 0:Root[0000, 0]@68..69#ROOT2024
PUNCH : [alone] 0:Root[0000, 0]@69..70#ROOT2024
PUNCT : [joint] 0:Root[0000, 0]@68..69#ROOT2024
PUNCT : [alone] 0:Root[0000, 0]@69..70#ROOT2024
IDENT collections 0:Root[0000, 0]@70..81#ROOT2024
PUNCH : [joint] 0:Root[0000, 0]@81..82#ROOT2024
PUNCH : [alone] 0:Root[0000, 0]@82..83#ROOT2024
PUNCT : [joint] 0:Root[0000, 0]@81..82#ROOT2024
PUNCT : [alone] 0:Root[0000, 0]@82..83#ROOT2024
IDENT HashSet 0:Root[0000, 0]@83..90#ROOT2024
PUNCH < [alone] 0:Root[0000, 0]@90..91#ROOT2024
PUNCT < [alone] 0:Root[0000, 0]@90..91#ROOT2024
SUBTREE () 0:Root[0000, 0]@91..92#ROOT2024 0:Root[0000, 0]@92..93#ROOT2024
PUNCH > [joint] 0:Root[0000, 0]@93..94#ROOT2024
PUNCH , [alone] 0:Root[0000, 0]@94..95#ROOT2024
PUNCT > [joint] 0:Root[0000, 0]@93..94#ROOT2024
PUNCT , [alone] 0:Root[0000, 0]@94..95#ROOT2024

struct MyTraitMap2 {
map: ::std::collections::HashSet<()>,
Expand Down Expand Up @@ -186,22 +186,22 @@ fn main() {
SUBTREE () 1:Root[0000, 0]@8..9#ROOT2024 1:Root[0000, 0]@9..10#ROOT2024
SUBTREE {} 1:Root[0000, 0]@11..12#ROOT2024 1:Root[0000, 0]@61..62#ROOT2024
LITERAL Integer 1 1:Root[0000, 0]@17..18#ROOT2024
PUNCH ; [alone] 1:Root[0000, 0]@18..19#ROOT2024
PUNCT ; [alone] 1:Root[0000, 0]@18..19#ROOT2024
LITERAL Float 1.0 1:Root[0000, 0]@24..27#ROOT2024
PUNCH ; [alone] 1:Root[0000, 0]@27..28#ROOT2024
PUNCT ; [alone] 1:Root[0000, 0]@27..28#ROOT2024
SUBTREE () 1:Root[0000, 0]@33..34#ROOT2024 1:Root[0000, 0]@39..40#ROOT2024
SUBTREE () 1:Root[0000, 0]@34..35#ROOT2024 1:Root[0000, 0]@37..38#ROOT2024
LITERAL Integer 1 1:Root[0000, 0]@35..36#ROOT2024
PUNCH , [alone] 1:Root[0000, 0]@36..37#ROOT2024
PUNCH , [alone] 1:Root[0000, 0]@38..39#ROOT2024
PUNCH . [alone] 1:Root[0000, 0]@40..41#ROOT2024
PUNCT , [alone] 1:Root[0000, 0]@36..37#ROOT2024
PUNCT , [alone] 1:Root[0000, 0]@38..39#ROOT2024
PUNCT . [alone] 1:Root[0000, 0]@40..41#ROOT2024
LITERAL Float 0.0 1:Root[0000, 0]@41..44#ROOT2024
PUNCH ; [alone] 1:Root[0000, 0]@44..45#ROOT2024
PUNCT ; [alone] 1:Root[0000, 0]@44..45#ROOT2024
IDENT let 1:Root[0000, 0]@50..53#ROOT2024
IDENT x 1:Root[0000, 0]@54..55#ROOT2024
PUNCH = [alone] 1:Root[0000, 0]@56..57#ROOT2024
PUNCT = [alone] 1:Root[0000, 0]@56..57#ROOT2024
LITERAL Integer 1 1:Root[0000, 0]@58..59#ROOT2024
PUNCH ; [alone] 1:Root[0000, 0]@59..60#ROOT2024
PUNCT ; [alone] 1:Root[0000, 0]@59..60#ROOT2024

fn main(){
1;
Expand Down Expand Up @@ -229,12 +229,12 @@ fn expr_2021() {
expect![[r#"
SUBTREE $$ 1:Root[0000, 0]@0..25#ROOT2024 1:Root[0000, 0]@0..25#ROOT2024
IDENT _ 1:Root[0000, 0]@5..6#ROOT2024
PUNCH ; [joint] 0:Root[0000, 0]@36..37#ROOT2024
PUNCT ; [joint] 0:Root[0000, 0]@36..37#ROOT2024
SUBTREE () 0:Root[0000, 0]@34..35#ROOT2024 0:Root[0000, 0]@34..35#ROOT2024
IDENT const 1:Root[0000, 0]@12..17#ROOT2024
SUBTREE {} 1:Root[0000, 0]@18..19#ROOT2024 1:Root[0000, 0]@22..23#ROOT2024
LITERAL Integer 1 1:Root[0000, 0]@20..21#ROOT2024
PUNCH ; [alone] 0:Root[0000, 0]@39..40#ROOT2024
PUNCT ; [alone] 0:Root[0000, 0]@39..40#ROOT2024

_;
(const {
Expand All @@ -261,7 +261,7 @@ fn expr_2021() {
}

SUBTREE $$ 1:Root[0000, 0]@0..8#ROOT2024 1:Root[0000, 0]@0..8#ROOT2024
PUNCH ; [alone] 0:Root[0000, 0]@39..40#ROOT2024
PUNCT ; [alone] 0:Root[0000, 0]@39..40#ROOT2024

;"#]],
);
Expand All @@ -285,7 +285,7 @@ fn expr_2021() {
}

SUBTREE $$ 1:Root[0000, 0]@0..18#ROOT2024 1:Root[0000, 0]@0..18#ROOT2024
PUNCH ; [alone] 0:Root[0000, 0]@39..40#ROOT2024
PUNCT ; [alone] 0:Root[0000, 0]@39..40#ROOT2024

;"#]],
);
Expand All @@ -307,24 +307,24 @@ fn expr_2021() {
expect![[r#"
SUBTREE $$ 1:Root[0000, 0]@0..76#ROOT2024 1:Root[0000, 0]@0..76#ROOT2024
LITERAL Integer 4 1:Root[0000, 0]@5..6#ROOT2024
PUNCH ; [joint] 0:Root[0000, 0]@41..42#ROOT2024
PUNCT ; [joint] 0:Root[0000, 0]@41..42#ROOT2024
LITERAL Str literal 1:Root[0000, 0]@12..21#ROOT2024
PUNCH ; [joint] 0:Root[0000, 0]@41..42#ROOT2024
PUNCT ; [joint] 0:Root[0000, 0]@41..42#ROOT2024
SUBTREE () 0:Root[0000, 0]@39..40#ROOT2024 0:Root[0000, 0]@39..40#ROOT2024
IDENT funcall 1:Root[0000, 0]@27..34#ROOT2024
SUBTREE () 1:Root[0000, 0]@34..35#ROOT2024 1:Root[0000, 0]@35..36#ROOT2024
PUNCH ; [joint] 0:Root[0000, 0]@41..42#ROOT2024
PUNCT ; [joint] 0:Root[0000, 0]@41..42#ROOT2024
SUBTREE () 0:Root[0000, 0]@39..40#ROOT2024 0:Root[0000, 0]@39..40#ROOT2024
IDENT future 1:Root[0000, 0]@42..48#ROOT2024
PUNCH . [alone] 1:Root[0000, 0]@48..49#ROOT2024
PUNCT . [alone] 1:Root[0000, 0]@48..49#ROOT2024
IDENT await 1:Root[0000, 0]@49..54#ROOT2024
PUNCH ; [joint] 0:Root[0000, 0]@41..42#ROOT2024
PUNCT ; [joint] 0:Root[0000, 0]@41..42#ROOT2024
SUBTREE () 0:Root[0000, 0]@39..40#ROOT2024 0:Root[0000, 0]@39..40#ROOT2024
IDENT break 1:Root[0000, 0]@60..65#ROOT2024
PUNCH ' [joint] 1:Root[0000, 0]@66..67#ROOT2024
PUNCT ' [joint] 1:Root[0000, 0]@66..67#ROOT2024
IDENT foo 1:Root[0000, 0]@67..70#ROOT2024
IDENT bar 1:Root[0000, 0]@71..74#ROOT2024
PUNCH ; [alone] 0:Root[0000, 0]@44..45#ROOT2024
PUNCT ; [alone] 0:Root[0000, 0]@44..45#ROOT2024

4;
"literal";
Expand Down Expand Up @@ -352,7 +352,7 @@ fn expr_2021() {
}

SUBTREE $$ 1:Root[0000, 0]@0..8#ROOT2024 1:Root[0000, 0]@0..8#ROOT2024
PUNCH ; [alone] 0:Root[0000, 0]@44..45#ROOT2024
PUNCT ; [alone] 0:Root[0000, 0]@44..45#ROOT2024

;"#]],
);
Expand All @@ -371,7 +371,7 @@ fn minus_belongs_to_literal() {
"-1",
expect![[r#"
SUBTREE $$ 1:Root[0000, 0]@0..2#ROOT2024 1:Root[0000, 0]@0..2#ROOT2024
PUNCH - [alone] 0:Root[0000, 0]@10..11#ROOT2024
PUNCT - [alone] 0:Root[0000, 0]@10..11#ROOT2024
LITERAL Integer 1 0:Root[0000, 0]@11..12#ROOT2024

-1"#]],
Expand All @@ -380,7 +380,7 @@ fn minus_belongs_to_literal() {
"- 1",
expect![[r#"
SUBTREE $$ 1:Root[0000, 0]@0..3#ROOT2024 1:Root[0000, 0]@0..3#ROOT2024
PUNCH - [alone] 0:Root[0000, 0]@10..11#ROOT2024
PUNCT - [alone] 0:Root[0000, 0]@10..11#ROOT2024
LITERAL Integer 1 0:Root[0000, 0]@11..12#ROOT2024

-1"#]],
Expand All @@ -389,7 +389,7 @@ fn minus_belongs_to_literal() {
"-2",
expect![[r#"
SUBTREE $$ 1:Root[0000, 0]@0..2#ROOT2024 1:Root[0000, 0]@0..2#ROOT2024
PUNCH - [alone] 0:Root[0000, 0]@25..26#ROOT2024
PUNCT - [alone] 0:Root[0000, 0]@25..26#ROOT2024
LITERAL Integer 2 0:Root[0000, 0]@27..28#ROOT2024

-2"#]],
Expand All @@ -398,7 +398,7 @@ fn minus_belongs_to_literal() {
"- 2",
expect![[r#"
SUBTREE $$ 1:Root[0000, 0]@0..3#ROOT2024 1:Root[0000, 0]@0..3#ROOT2024
PUNCH - [alone] 0:Root[0000, 0]@25..26#ROOT2024
PUNCT - [alone] 0:Root[0000, 0]@25..26#ROOT2024
LITERAL Integer 2 0:Root[0000, 0]@27..28#ROOT2024

-2"#]],
Expand All @@ -407,7 +407,7 @@ fn minus_belongs_to_literal() {
"-3.0",
expect![[r#"
SUBTREE $$ 1:Root[0000, 0]@0..4#ROOT2024 1:Root[0000, 0]@0..4#ROOT2024
PUNCH - [alone] 0:Root[0000, 0]@43..44#ROOT2024
PUNCT - [alone] 0:Root[0000, 0]@43..44#ROOT2024
LITERAL Float 3.0 0:Root[0000, 0]@45..48#ROOT2024

-3.0"#]],
Expand All @@ -416,7 +416,7 @@ fn minus_belongs_to_literal() {
"- 3.0",
expect![[r#"
SUBTREE $$ 1:Root[0000, 0]@0..5#ROOT2024 1:Root[0000, 0]@0..5#ROOT2024
PUNCH - [alone] 0:Root[0000, 0]@43..44#ROOT2024
PUNCT - [alone] 0:Root[0000, 0]@43..44#ROOT2024
LITERAL Float 3.0 0:Root[0000, 0]@45..48#ROOT2024

-3.0"#]],
Expand All @@ -433,7 +433,7 @@ fn minus_belongs_to_literal() {
"@-1",
expect![[r#"
SUBTREE $$ 1:Root[0000, 0]@0..3#ROOT2024 1:Root[0000, 0]@0..3#ROOT2024
PUNCH - [alone] 1:Root[0000, 0]@1..2#ROOT2024
PUNCT - [alone] 1:Root[0000, 0]@1..2#ROOT2024
LITERAL Integer 1 1:Root[0000, 0]@2..3#ROOT2024

-1"#]],
Expand All @@ -450,7 +450,7 @@ fn minus_belongs_to_literal() {
"@-1.0",
expect![[r#"
SUBTREE $$ 1:Root[0000, 0]@0..5#ROOT2024 1:Root[0000, 0]@0..5#ROOT2024
PUNCH - [alone] 1:Root[0000, 0]@1..2#ROOT2024
PUNCT - [alone] 1:Root[0000, 0]@1..2#ROOT2024
LITERAL Float 1.0 1:Root[0000, 0]@2..5#ROOT2024

-1.0"#]],
Expand Down
4 changes: 4 additions & 0 deletions crates/parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ rustc-literal-escaper.workspace = true
tracing.workspace = true

edition.workspace = true
stdx.workspace = true
winnow = { version = "0.7.13", default-features = false }

[dev-dependencies]
Expand All @@ -32,3 +33,6 @@ in-rust-tree = []

[lints]
workspace = true

[package.metadata.cargo-machete]
ignored = ["ra-ap-rustc_lexer"]
8 changes: 4 additions & 4 deletions crates/parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
#![allow(rustdoc::private_intra_doc_links)]
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]

#[cfg(not(feature = "in-rust-tree"))]
extern crate ra_ap_rustc_lexer as rustc_lexer;
#[cfg(feature = "in-rust-tree")]
extern crate rustc_driver as _;
#[cfg(feature = "in-rust-tree")]
extern crate rustc_lexer;

stdx::rustc_crates! {
extern crate rustc_lexer or ra_ap_rustc_lexer;
}

mod event;
mod frontmatter;
Expand Down
Loading