Auto merge of #139114 - m-ou-se:super-let-pin, r=davidtwco
Implement `pin!()` using `super let`
Tracking issue for super let: https://github.com/rust-lang/rust/issues/139076
This uses `super let` to implement `pin!()`.
This means we can remove [the hack](https://github.com/rust-lang/rust/pull/138717) we had to put in to fix https://github.com/rust-lang/rust/issues/138596.
It also means we can remove the original hack to make `pin!()` work, which used a questionable public-but-unstable field rather than a proper private field.
While `super let` is still unstable and subject to change, it seems safe to assume that future Rust will always have a way to express `pin!()` in a compatible way, considering `pin!()` is already stable.
It'd help [the experiment](https://github.com/rust-lang/rust/issues/139076) to have `pin!()` use `super let`, so we can get some more experience with it.
diff --git a/Cargo.lock b/Cargo.lock
index 745a809..2dbb3f5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -902,9 +902,9 @@
[[package]]
name = "libc"
-version = "0.2.169"
+version = "0.2.172"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
+checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
[[package]]
name = "libloading"
diff --git a/crates/ide-db/src/generated/lints.rs b/crates/ide-db/src/generated/lints.rs
index 0a7a7d1..706d044 100644
--- a/crates/ide-db/src/generated/lints.rs
+++ b/crates/ide-db/src/generated/lints.rs
@@ -3795,35 +3795,6 @@
deny_since: None,
},
Lint {
- label: "cfg_boolean_literals",
- description: r##"# `cfg_boolean_literals`
-
-The tracking issue for this feature is: [#131204]
-
-[#131204]: https://github.com/rust-lang/rust/issues/131204
-
-------------------------
-
-The `cfg_boolean_literals` feature makes it possible to use the `true`/`false`
-literal as cfg predicate. They always evaluate to true/false respectively.
-
-## Examples
-
-```rust
-#![feature(cfg_boolean_literals)]
-
-#[cfg(true)]
-const A: i32 = 5;
-
-#[cfg(all(false))]
-const A: i32 = 58 * 89;
-```
-"##,
- default_severity: Severity::Allow,
- warn_since: None,
- deny_since: None,
- },
- Lint {
label: "cfg_eval",
description: r##"# `cfg_eval`
diff --git a/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs b/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs
index 59293ee..80f6d85 100644
--- a/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs
+++ b/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs
@@ -11,7 +11,7 @@
use intern::Symbol;
use proc_macro::bridge::{self, server};
-use span::{FileId, Span, FIXUP_ERASED_FILE_AST_ID_MARKER};
+use span::{Span, FIXUP_ERASED_FILE_AST_ID_MARKER};
use tt::{TextRange, TextSize};
use crate::server_impl::{literal_kind_to_internal, token_stream::TokenStreamBuilder, TopSubtree};
@@ -27,10 +27,6 @@
type TokenStream = crate::server_impl::TokenStream<Span>;
-#[derive(Copy, Clone, PartialEq, Eq, Debug)]
-pub struct SourceFile {
- file_id: FileId,
-}
pub struct FreeFunctions;
pub struct RaSpanServer {
@@ -46,7 +42,6 @@
impl server::Types for RaSpanServer {
type FreeFunctions = FreeFunctions;
type TokenStream = TokenStream;
- type SourceFile = SourceFile;
type Span = Span;
type Symbol = Symbol;
}
@@ -245,25 +240,17 @@
}
}
-impl server::SourceFile for RaSpanServer {
- fn eq(&mut self, file1: &Self::SourceFile, file2: &Self::SourceFile) -> bool {
- file1 == file2
- }
- fn path(&mut self, _file: &Self::SourceFile) -> String {
- // FIXME
- String::new()
- }
- fn is_real(&mut self, _file: &Self::SourceFile) -> bool {
- true
- }
-}
-
impl server::Span for RaSpanServer {
fn debug(&mut self, span: Self::Span) -> String {
format!("{:?}", span)
}
- fn source_file(&mut self, span: Self::Span) -> Self::SourceFile {
- SourceFile { file_id: span.anchor.file_id.file_id() }
+ fn file(&mut self, _: Self::Span) -> String {
+ // FIXME
+ String::new()
+ }
+ fn local_file(&mut self, _: Self::Span) -> Option<String> {
+ // FIXME
+ None
}
fn save_span(&mut self, _span: Self::Span) -> usize {
// FIXME, quote is incompatible with third-party tools
diff --git a/crates/proc-macro-srv/src/server_impl/token_id.rs b/crates/proc-macro-srv/src/server_impl/token_id.rs
index 409cf3c..4d7c7c4 100644
--- a/crates/proc-macro-srv/src/server_impl/token_id.rs
+++ b/crates/proc-macro-srv/src/server_impl/token_id.rs
@@ -24,8 +24,6 @@
type Span = tt::TokenId;
type TokenStream = crate::server_impl::TokenStream<Span>;
-#[derive(Clone)]
-pub struct SourceFile;
pub struct FreeFunctions;
pub struct TokenIdServer {
@@ -37,7 +35,6 @@
impl server::Types for TokenIdServer {
type FreeFunctions = FreeFunctions;
type TokenStream = TokenStream;
- type SourceFile = SourceFile;
type Span = Span;
type Symbol = Symbol;
}
@@ -223,24 +220,15 @@
}
}
-impl server::SourceFile for TokenIdServer {
- fn eq(&mut self, _file1: &Self::SourceFile, _file2: &Self::SourceFile) -> bool {
- true
- }
- fn path(&mut self, _file: &Self::SourceFile) -> String {
- String::new()
- }
- fn is_real(&mut self, _file: &Self::SourceFile) -> bool {
- true
- }
-}
-
impl server::Span for TokenIdServer {
fn debug(&mut self, span: Self::Span) -> String {
format!("{:?}", span.0)
}
- fn source_file(&mut self, _span: Self::Span) -> Self::SourceFile {
- SourceFile {}
+ fn file(&mut self, _span: Self::Span) -> String {
+ String::new()
+ }
+ fn local_file(&mut self, _span: Self::Span) -> Option<String> {
+ None
}
fn save_span(&mut self, _span: Self::Span) -> usize {
0
diff --git a/crates/proc-macro-srv/src/tests/mod.rs b/crates/proc-macro-srv/src/tests/mod.rs
index 15de88e..4bd365b 100644
--- a/crates/proc-macro-srv/src/tests/mod.rs
+++ b/crates/proc-macro-srv/src/tests/mod.rs
@@ -97,6 +97,7 @@
}
#[test]
+#[cfg(not(bootstrap))]
fn test_fn_like_fn_like_span_join() {
assert_expand(
"fn_like_span_join",
@@ -111,6 +112,7 @@
}
#[test]
+#[cfg(not(bootstrap))]
fn test_fn_like_fn_like_span_ops() {
assert_expand(
"fn_like_span_ops",