Skip to content

Commit db5b4c2

Browse files
committed
rust-analyzer: Also use semiopaque instead of semitransparent
Like in rustc.
1 parent 7d06bb5 commit db5b4c2

File tree

12 files changed

+26
-26
lines changed

12 files changed

+26
-26
lines changed

src/tools/rust-analyzer/crates/hir-def/src/expr_store/expander.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl Expander {
6161
pub(super) fn hygiene_for_range(&self, db: &dyn DefDatabase, range: TextRange) -> HygieneId {
6262
match self.span_map.as_ref() {
6363
hir_expand::span_map::SpanMapRef::ExpansionSpanMap(span_map) => {
64-
HygieneId::new(span_map.span_at(range.start()).ctx.opaque_and_semitransparent(db))
64+
HygieneId::new(span_map.span_at(range.start()).ctx.opaque_and_semiopaque(db))
6565
}
6666
hir_expand::span_map::SpanMapRef::RealSpanMap(_) => HygieneId::ROOT,
6767
}

src/tools/rust-analyzer/crates/hir-def/src/expr_store/lower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2548,7 +2548,7 @@ impl<'db> ExprCollector<'db> {
25482548
// Therefore, if we got to the rib of its declaration, give up its hygiene
25492549
// and use its parent expansion.
25502550

2551-
hygiene_id = HygieneId::new(parent_ctx.opaque_and_semitransparent(self.db));
2551+
hygiene_id = HygieneId::new(parent_ctx.opaque_and_semiopaque(self.db));
25522552
hygiene_info = parent_ctx.outer_expn(self.db).map(|expansion| {
25532553
let expansion = self.db.lookup_intern_macro_call(expansion.into());
25542554
(parent_ctx.parent(self.db), expansion.def)

src/tools/rust-analyzer/crates/hir-def/src/resolver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ fn handle_macro_def_scope(
936936
// A macro is allowed to refer to variables from before its declaration.
937937
// Therefore, if we got to the rib of its declaration, give up its hygiene
938938
// and use its parent expansion.
939-
*hygiene_id = HygieneId::new(parent_ctx.opaque_and_semitransparent(db));
939+
*hygiene_id = HygieneId::new(parent_ctx.opaque_and_semiopaque(db));
940940
*hygiene_info = parent_ctx.outer_expn(db).map(|expansion| {
941941
let expansion = db.lookup_intern_macro_call(expansion.into());
942942
(parent_ctx.parent(db), expansion.def)

src/tools/rust-analyzer/crates/hir-expand/src/declarative.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ impl DeclarativeMacroExpander {
100100
{
101101
match &*value {
102102
"transparent" => ControlFlow::Break(Transparency::Transparent),
103-
"semitransparent" => ControlFlow::Break(Transparency::SemiTransparent),
103+
// "semitransparent" is for old rustc versions.
104+
"semiopaque" | "semitransparent" => ControlFlow::Break(Transparency::SemiOpaque),
104105
"opaque" => ControlFlow::Break(Transparency::Opaque),
105106
_ => ControlFlow::Continue(()),
106107
}
@@ -140,7 +141,7 @@ impl DeclarativeMacroExpander {
140141
)),
141142
},
142143
transparency(ast::AnyHasAttrs::from(macro_rules))
143-
.unwrap_or(Transparency::SemiTransparent),
144+
.unwrap_or(Transparency::SemiOpaque),
144145
),
145146
ast::Macro::MacroDef(macro_def) => (
146147
match macro_def.body() {

src/tools/rust-analyzer/crates/hir-expand/src/hygiene.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub fn span_with_mixed_site_ctxt(
5454
expn_id: MacroCallId,
5555
edition: Edition,
5656
) -> Span {
57-
span_with_ctxt_from_mark(db, span, expn_id, Transparency::SemiTransparent, edition)
57+
span_with_ctxt_from_mark(db, span, expn_id, Transparency::SemiOpaque, edition)
5858
}
5959

6060
fn span_with_ctxt_from_mark(
@@ -82,7 +82,7 @@ pub(super) fn apply_mark(
8282
}
8383

8484
let call_site_ctxt = db.lookup_intern_macro_call(call_id.into()).ctxt;
85-
let mut call_site_ctxt = if transparency == Transparency::SemiTransparent {
85+
let mut call_site_ctxt = if transparency == Transparency::SemiOpaque {
8686
call_site_ctxt.normalize_to_macros_2_0(db)
8787
} else {
8888
call_site_ctxt.normalize_to_macro_rules(db)
@@ -117,16 +117,16 @@ fn apply_mark_internal(
117117
let call_id = Some(call_id);
118118

119119
let mut opaque = ctxt.opaque(db);
120-
let mut opaque_and_semitransparent = ctxt.opaque_and_semitransparent(db);
120+
let mut opaque_and_semiopaque = ctxt.opaque_and_semiopaque(db);
121121

122122
if transparency >= Transparency::Opaque {
123123
let parent = opaque;
124124
opaque = SyntaxContext::new(db, call_id, transparency, edition, parent, identity, identity);
125125
}
126126

127-
if transparency >= Transparency::SemiTransparent {
128-
let parent = opaque_and_semitransparent;
129-
opaque_and_semitransparent =
127+
if transparency >= Transparency::SemiOpaque {
128+
let parent = opaque_and_semiopaque;
129+
opaque_and_semiopaque =
130130
SyntaxContext::new(db, call_id, transparency, edition, parent, |_| opaque, identity);
131131
}
132132

@@ -138,6 +138,6 @@ fn apply_mark_internal(
138138
edition,
139139
parent,
140140
|_| opaque,
141-
|_| opaque_and_semitransparent,
141+
|_| opaque_and_semiopaque,
142142
)
143143
}

src/tools/rust-analyzer/crates/hir-expand/src/inert_attr_macro.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
429429
rustc_attr!(rustc_proc_macro_decls, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE),
430430
rustc_attr!(
431431
rustc_macro_transparency, Normal,
432-
template!(NameValueStr: "transparent|semitransparent|opaque"), ErrorFollowing,
432+
template!(NameValueStr: "transparent|semiopaque|opaque"), ErrorFollowing,
433433
"used internally for testing macro hygiene",
434434
),
435435

src/tools/rust-analyzer/crates/hir-expand/src/mod_path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ pub fn resolve_crate_root(db: &dyn ExpandDatabase, mut ctxt: SyntaxContext) -> O
402402
iter.next();
403403
}
404404
// Then find the last semi-transparent mark from the end if it exists.
405-
while let Some((mark, Transparency::SemiTransparent)) = iter.next() {
405+
while let Some((mark, Transparency::SemiOpaque)) = iter.next() {
406406
result_mark = Some(mark);
407407
}
408408

src/tools/rust-analyzer/crates/hir-ty/src/tests/simple.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3702,7 +3702,7 @@ fn main() {
37023702
}
37033703

37043704
#[test]
3705-
fn macro_semitransparent_hygiene() {
3705+
fn macro_semiopaque_hygiene() {
37063706
check_types(
37073707
r#"
37083708
macro_rules! m {

src/tools/rust-analyzer/crates/hir/src/source_analyzer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1802,5 +1802,5 @@ pub(crate) fn name_hygiene(db: &dyn HirDatabase, name: InFile<&SyntaxNode>) -> H
18021802
};
18031803
let span_map = db.expansion_span_map(macro_file);
18041804
let ctx = span_map.span_at(name.value.text_range().start()).ctx;
1805-
HygieneId::new(ctx.opaque_and_semitransparent(db))
1805+
HygieneId::new(ctx.opaque_and_semiopaque(db))
18061806
}

src/tools/rust-analyzer/crates/intern/src/symbol/symbols.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,6 @@ define_symbols! {
441441
rustc_skip_array_during_method_dispatch,
442442
rustc_skip_during_method_dispatch,
443443
rustc_force_inline,
444-
semitransparent,
445444
shl_assign,
446445
shl,
447446
shr_assign,

0 commit comments

Comments
 (0)