about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2025-03-28 22:31:20 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2025-03-31 15:41:48 +0300
commit54bb849affcbede09ab1327c6cd996e5c5948cdd (patch)
treef300a4c0911d4c95c66534e2bc29e723e576cf23
parent10a76d634781180b4f5402c519f0c237d3be6ee6 (diff)
downloadrust-54bb849affcbede09ab1327c6cd996e5c5948cdd.tar.gz
rust-54bb849affcbede09ab1327c6cd996e5c5948cdd.zip
hygiene: Rename semi-transparent to semi-opaque
The former is just too long, see the examples in `hygiene.rs`

-rw-r--r--compiler/rustc_attr_parsing/src/attributes/transparency.rs2
-rw-r--r--compiler/rustc_feature/src/builtin_attrs.rs2
-rw-r--r--compiler/rustc_resolve/src/lib.rs6
-rw-r--r--compiler/rustc_span/src/hygiene.rs47
-rw-r--r--compiler/rustc_span/src/lib.rs2
-rw-r--r--compiler/rustc_span/src/symbol.rs1
-rw-r--r--tests/ui/hygiene/rustc-macro-transparency.rs12
-rw-r--r--tests/ui/hygiene/rustc-macro-transparency.stderr12
-rw-r--r--tests/ui/hygiene/unpretty-debug.stdout2
-rw-r--r--tests/ui/proc-macro/meta-macro-hygiene.stdout6
-rw-r--r--tests/ui/proc-macro/nonterminal-token-hygiene.stdout4
11 files changed, 48 insertions, 48 deletions
diff --git a/compiler/rustc_attr_parsing/src/attributes/transparency.rs b/compiler/rustc_attr_parsing/src/attributes/transparency.rs
index ad83a1f7af8..ce42b0507ed 100644
--- a/compiler/rustc_attr_parsing/src/attributes/transparency.rs
+++ b/compiler/rustc_attr_parsing/src/attributes/transparency.rs
@@ -20,7 +20,7 @@ impl SingleAttributeParser for TransparencyParser {
     fn convert(cx: &AcceptContext<'_>, args: &ArgParser<'_>) -> Option<AttributeKind> {
         match args.name_value().and_then(|nv| nv.value_as_str()) {
             Some(sym::transparent) => Some(Transparency::Transparent),
-            Some(sym::semitransparent) => Some(Transparency::SemiTransparent),
+            Some(sym::semiopaque | sym::semitransparent) => Some(Transparency::SemiOpaque),
             Some(sym::opaque) => Some(Transparency::Opaque),
             Some(other) => {
                 cx.dcx().span_err(cx.attr_span, format!("unknown macro transparency: `{other}`"));
diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs
index 1e33e2e9393..a8f0da736c6 100644
--- a/compiler/rustc_feature/src/builtin_attrs.rs
+++ b/compiler/rustc_feature/src/builtin_attrs.rs
@@ -752,7 +752,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
     ),
     rustc_attr!(
         rustc_macro_transparency, Normal,
-        template!(NameValueStr: "transparent|semitransparent|opaque"), ErrorFollowing,
+        template!(NameValueStr: "transparent|semiopaque|opaque"), ErrorFollowing,
         EncodeCrossCrate::Yes, "used internally for testing macro hygiene",
     ),
     rustc_attr!(
diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs
index 612e091770f..1eac3f848b6 100644
--- a/compiler/rustc_resolve/src/lib.rs
+++ b/compiler/rustc_resolve/src/lib.rs
@@ -1998,16 +1998,16 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
                 result,
                 result.map(|r| r.expn_data())
             );
-            // Then find the last semi-transparent mark from the end if it exists.
+            // Then find the last semi-opaque mark from the end if it exists.
             for (mark, transparency) in iter {
-                if transparency == Transparency::SemiTransparent {
+                if transparency == Transparency::SemiOpaque {
                     result = Some(mark);
                 } else {
                     break;
                 }
             }
             debug!(
-                "resolve_crate_root: found semi-transparent mark {:?} {:?}",
+                "resolve_crate_root: found semi-opaque mark {:?} {:?}",
                 result,
                 result.map(|r| r.expn_data())
             );
diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs
index e7a8dee27f5..c2e7cb45775 100644
--- a/compiler/rustc_span/src/hygiene.rs
+++ b/compiler/rustc_span/src/hygiene.rs
@@ -66,10 +66,10 @@ pub struct SyntaxContextData {
     outer_expn: ExpnId,
     outer_transparency: Transparency,
     parent: SyntaxContext,
-    /// This context, but with all transparent and semi-transparent expansions filtered away.
+    /// This context, but with all transparent and semi-opaque expansions filtered away.
     opaque: SyntaxContext,
     /// This context, but with all transparent expansions filtered away.
-    opaque_and_semitransparent: SyntaxContext,
+    opaque_and_semiopaque: SyntaxContext,
     /// Name of the crate to which `$crate` with this context would resolve.
     dollar_crate_name: Symbol,
 }
@@ -78,14 +78,14 @@ impl SyntaxContextData {
     fn new(
         (parent, outer_expn, outer_transparency): SyntaxContextKey,
         opaque: SyntaxContext,
-        opaque_and_semitransparent: SyntaxContext,
+        opaque_and_semiopaque: SyntaxContext,
     ) -> SyntaxContextData {
         SyntaxContextData {
             outer_expn,
             outer_transparency,
             parent,
             opaque,
-            opaque_and_semitransparent,
+            opaque_and_semiopaque,
             dollar_crate_name: kw::DollarCrate,
         }
     }
@@ -96,7 +96,7 @@ impl SyntaxContextData {
             outer_transparency: Transparency::Opaque,
             parent: SyntaxContext::root(),
             opaque: SyntaxContext::root(),
-            opaque_and_semitransparent: SyntaxContext::root(),
+            opaque_and_semiopaque: SyntaxContext::root(),
             dollar_crate_name: kw::DollarCrate,
         }
     }
@@ -207,13 +207,13 @@ pub enum Transparency {
     /// Identifier produced by a transparent expansion is always resolved at call-site.
     /// Call-site spans in procedural macros, hygiene opt-out in `macro` should use this.
     Transparent,
-    /// Identifier produced by a semi-transparent expansion may be resolved
+    /// Identifier produced by a semi-opaque expansion may be resolved
     /// either at call-site or at definition-site.
     /// If it's a local variable, label or `$crate` then it's resolved at def-site.
     /// Otherwise it's resolved at call-site.
     /// `macro_rules` macros behave like this, built-in macros currently behave like this too,
     /// but that's an implementation detail.
-    SemiTransparent,
+    SemiOpaque,
     /// Identifier produced by an opaque expansion is always resolved at definition-site.
     /// Def-site spans in procedural macros, identifiers from `macro` by default use this.
     Opaque,
@@ -221,7 +221,7 @@ pub enum Transparency {
 
 impl Transparency {
     pub fn fallback(macro_rules: bool) -> Self {
-        if macro_rules { Transparency::SemiTransparent } else { Transparency::Opaque }
+        if macro_rules { Transparency::SemiOpaque } else { Transparency::Opaque }
     }
 }
 
@@ -469,7 +469,7 @@ impl HygieneData {
 
     fn normalize_to_macro_rules(&self, ctxt: SyntaxContext) -> SyntaxContext {
         debug_assert!(!self.syntax_context_data[ctxt.0 as usize].is_decode_placeholder());
-        self.syntax_context_data[ctxt.0 as usize].opaque_and_semitransparent
+        self.syntax_context_data[ctxt.0 as usize].opaque_and_semiopaque
     }
 
     fn outer_expn(&self, ctxt: SyntaxContext) -> ExpnId {
@@ -562,7 +562,7 @@ impl HygieneData {
         }
 
         let call_site_ctxt = self.expn_data(expn_id).call_site.ctxt();
-        let mut call_site_ctxt = if transparency == Transparency::SemiTransparent {
+        let mut call_site_ctxt = if transparency == Transparency::SemiOpaque {
             self.normalize_to_macros_2_0(call_site_ctxt)
         } else {
             self.normalize_to_macro_rules(call_site_ctxt)
@@ -608,33 +608,32 @@ impl HygieneData {
         self.syntax_context_data.push(SyntaxContextData::decode_placeholder());
         self.syntax_context_map.insert(key, ctxt);
 
-        // Opaque and semi-transparent versions of the parent. Note that they may be equal to the
+        // Opaque and semi-opaque versions of the parent. Note that they may be equal to the
         // parent itself. E.g. `parent_opaque` == `parent` if the expn chain contains only opaques,
-        // and `parent_opaque_and_semitransparent` == `parent` if the expn contains only opaques
-        // and semi-transparents.
+        // and `parent_opaque_and_semiopaque` == `parent` if the expn contains only (semi-)opaques.
         let parent_opaque = self.syntax_context_data[parent.0 as usize].opaque;
-        let parent_opaque_and_semitransparent =
-            self.syntax_context_data[parent.0 as usize].opaque_and_semitransparent;
+        let parent_opaque_and_semiopaque =
+            self.syntax_context_data[parent.0 as usize].opaque_and_semiopaque;
 
-        // Evaluate opaque and semi-transparent versions of the new syntax context.
-        let (opaque, opaque_and_semitransparent) = match transparency {
-            Transparency::Transparent => (parent_opaque, parent_opaque_and_semitransparent),
-            Transparency::SemiTransparent => (
+        // Evaluate opaque and semi-opaque versions of the new syntax context.
+        let (opaque, opaque_and_semiopaque) = match transparency {
+            Transparency::Transparent => (parent_opaque, parent_opaque_and_semiopaque),
+            Transparency::SemiOpaque => (
                 parent_opaque,
-                // Will be the same as `ctxt` if the expn chain contains only opaques and semi-transparents.
-                self.alloc_ctxt(parent_opaque_and_semitransparent, expn_id, transparency),
+                // Will be the same as `ctxt` if the expn chain contains only (semi-)opaques.
+                self.alloc_ctxt(parent_opaque_and_semiopaque, expn_id, transparency),
             ),
             Transparency::Opaque => (
                 // Will be the same as `ctxt` if the expn chain contains only opaques.
                 self.alloc_ctxt(parent_opaque, expn_id, transparency),
-                // Will be the same as `ctxt` if the expn chain contains only opaques and semi-transparents.
-                self.alloc_ctxt(parent_opaque_and_semitransparent, expn_id, transparency),
+                // Will be the same as `ctxt` if the expn chain contains only (semi-)opaques.
+                self.alloc_ctxt(parent_opaque_and_semiopaque, expn_id, transparency),
             ),
         };
 
         // Fill the full data, now that we have it.
         self.syntax_context_data[ctxt.as_u32() as usize] =
-            SyntaxContextData::new(key, opaque, opaque_and_semitransparent);
+            SyntaxContextData::new(key, opaque, opaque_and_semiopaque);
         ctxt
     }
 }
diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs
index 9e6ba2e1b9c..625ece787b9 100644
--- a/compiler/rustc_span/src/lib.rs
+++ b/compiler/rustc_span/src/lib.rs
@@ -1112,7 +1112,7 @@ impl Span {
     /// Equivalent of `Span::mixed_site` from the proc macro API,
     /// except that the location is taken from the `self` span.
     pub fn with_mixed_site_ctxt(self, expn_id: ExpnId) -> Span {
-        self.with_ctxt_from_mark(expn_id, Transparency::SemiTransparent)
+        self.with_ctxt_from_mark(expn_id, Transparency::SemiOpaque)
     }
 
     /// Produces a span with the same location as `self` and context produced by a macro with the
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs
index 47dd80c432e..02f89c527e6 100644
--- a/compiler/rustc_span/src/symbol.rs
+++ b/compiler/rustc_span/src/symbol.rs
@@ -1871,6 +1871,7 @@ symbols! {
         select_unpredictable,
         self_in_typedefs,
         self_struct_ctor,
+        semiopaque,
         semitransparent,
         sha2,
         sha3,
diff --git a/tests/ui/hygiene/rustc-macro-transparency.rs b/tests/ui/hygiene/rustc-macro-transparency.rs
index 5f36993af2f..1a78a7543cf 100644
--- a/tests/ui/hygiene/rustc-macro-transparency.rs
+++ b/tests/ui/hygiene/rustc-macro-transparency.rs
@@ -6,9 +6,9 @@ macro transparent() {
     let transparent = 0;
 }
 #[rustc_macro_transparency = "semitransparent"]
-macro semitransparent() {
-    struct SemiTransparent;
-    let semitransparent = 0;
+macro semiopaque() {
+    struct SemiOpaque;
+    let semiopaque = 0;
 }
 #[rustc_macro_transparency = "opaque"]
 macro opaque() {
@@ -18,14 +18,14 @@ macro opaque() {
 
 fn main() {
     transparent!();
-    semitransparent!();
+    semiopaque!();
     opaque!();
 
     Transparent; // OK
-    SemiTransparent; // OK
+    SemiOpaque; // OK
     Opaque; //~ ERROR cannot find value `Opaque` in this scope
 
     transparent; // OK
-    semitransparent; //~ ERROR expected value, found macro `semitransparent`
+    semiopaque; //~ ERROR expected value, found macro `semiopaque`
     opaque; //~ ERROR expected value, found macro `opaque`
 }
diff --git a/tests/ui/hygiene/rustc-macro-transparency.stderr b/tests/ui/hygiene/rustc-macro-transparency.stderr
index 1d2a1e12498..1bea8a0ee4f 100644
--- a/tests/ui/hygiene/rustc-macro-transparency.stderr
+++ b/tests/ui/hygiene/rustc-macro-transparency.stderr
@@ -4,17 +4,17 @@ error[E0425]: cannot find value `Opaque` in this scope
 LL |     Opaque;
    |     ^^^^^^ not found in this scope
 
-error[E0423]: expected value, found macro `semitransparent`
+error[E0423]: expected value, found macro `semiopaque`
   --> $DIR/rustc-macro-transparency.rs:29:5
    |
-LL |     struct SemiTransparent;
-   |     ----------------------- similarly named unit struct `SemiTransparent` defined here
+LL |     struct SemiOpaque;
+   |     ------------------ similarly named unit struct `SemiOpaque` defined here
 ...
-LL |     semitransparent;
-   |     ^^^^^^^^^^^^^^^
+LL |     semiopaque;
+   |     ^^^^^^^^^^
    |     |
    |     not a value
-   |     help: a unit struct with a similar name exists: `SemiTransparent`
+   |     help: a unit struct with a similar name exists (notice the capitalization): `SemiOpaque`
 
 error[E0423]: expected value, found macro `opaque`
   --> $DIR/rustc-macro-transparency.rs:30:5
diff --git a/tests/ui/hygiene/unpretty-debug.stdout b/tests/ui/hygiene/unpretty-debug.stdout
index e475cfac2fc..f35bd7a7cb2 100644
--- a/tests/ui/hygiene/unpretty-debug.stdout
+++ b/tests/ui/hygiene/unpretty-debug.stdout
@@ -24,5 +24,5 @@ crate0::{{expn1}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt:
 
 SyntaxContexts:
 #0: parent: #0, outer_mark: (crate0::{{expn0}}, Opaque)
-#1: parent: #0, outer_mark: (crate0::{{expn1}}, SemiTransparent)
+#1: parent: #0, outer_mark: (crate0::{{expn1}}, SemiOpaque)
 */
diff --git a/tests/ui/proc-macro/meta-macro-hygiene.stdout b/tests/ui/proc-macro/meta-macro-hygiene.stdout
index 1ee7179e84c..1734b9afe92 100644
--- a/tests/ui/proc-macro/meta-macro-hygiene.stdout
+++ b/tests/ui/proc-macro/meta-macro-hygiene.stdout
@@ -60,11 +60,11 @@ SyntaxContexts:
 #0: parent: #0, outer_mark: (crate0::{{expn0}}, Opaque)
 #1: parent: #0, outer_mark: (crate0::{{expn1}}, Opaque)
 #2: parent: #0, outer_mark: (crate0::{{expn1}}, Transparent)
-#3: parent: #0, outer_mark: (crate0::{{expn2}}, SemiTransparent)
+#3: parent: #0, outer_mark: (crate0::{{expn2}}, SemiOpaque)
 #4: parent: #0, outer_mark: (crate0::{{expn3}}, Opaque)
 #5: parent: #3, outer_mark: (crate0::{{expn3}}, Transparent)
-#6: parent: #0, outer_mark: (crate0::{{expn3}}, SemiTransparent)
+#6: parent: #0, outer_mark: (crate0::{{expn3}}, SemiOpaque)
 #7: parent: #0, outer_mark: (crate0::{{expn4}}, Opaque)
 #8: parent: #4, outer_mark: (crate0::{{expn4}}, Transparent)
-#9: parent: #4, outer_mark: (crate0::{{expn4}}, SemiTransparent)
+#9: parent: #4, outer_mark: (crate0::{{expn4}}, SemiOpaque)
 */
diff --git a/tests/ui/proc-macro/nonterminal-token-hygiene.stdout b/tests/ui/proc-macro/nonterminal-token-hygiene.stdout
index 6fd6cb47469..0f1b19ffdea 100644
--- a/tests/ui/proc-macro/nonterminal-token-hygiene.stdout
+++ b/tests/ui/proc-macro/nonterminal-token-hygiene.stdout
@@ -82,10 +82,10 @@ SyntaxContexts:
 #0: parent: #0, outer_mark: (crate0::{{expn0}}, Opaque)
 #1: parent: #0, outer_mark: (crate0::{{expn1}}, Opaque)
 #2: parent: #0, outer_mark: (crate0::{{expn1}}, Transparent)
-#3: parent: #0, outer_mark: (crate0::{{expn2}}, SemiTransparent)
+#3: parent: #0, outer_mark: (crate0::{{expn2}}, SemiOpaque)
 #4: parent: #3, outer_mark: (crate0::{{expn3}}, Opaque)
 #5: parent: #0, outer_mark: (crate0::{{expn3}}, Opaque)
 #6: parent: #0, outer_mark: (crate0::{{expn4}}, Opaque)
 #7: parent: #4, outer_mark: (crate0::{{expn4}}, Transparent)
-#8: parent: #5, outer_mark: (crate0::{{expn4}}, SemiTransparent)
+#8: parent: #5, outer_mark: (crate0::{{expn4}}, SemiOpaque)
 */