Skip to content

Commit 64087bc

Browse files
authored
Rollup merge of rust-lang#152753 - cyrgani:remove-hack, r=petrochenkov
remove the explicit error for old `rental` versions This was converted to a hard error 20 months ago (in rust-lang#125596). This seems like enough time for anyone still using it to notice, so remove the note entirely now. In comparison, the explicit note for the more impactful `time` breakage was already removed after 6 months (rust-lang#129343). Closes rust-lang#73933. Closes rust-lang#83125. r? @petrochenkov
2 parents 7312ac3 + 195b849 commit 64087bc

File tree

13 files changed

+6
-226
lines changed

13 files changed

+6
-226
lines changed

compiler/rustc_expand/src/base.rs

Lines changed: 3 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ use std::any::Any;
22
use std::default::Default;
33
use std::iter;
44
use std::path::Component::Prefix;
5-
use std::path::{Path, PathBuf};
5+
use std::path::PathBuf;
66
use std::rc::Rc;
77
use std::sync::Arc;
88

99
use rustc_ast::attr::MarkedAttrs;
10-
use rustc_ast::token::MetaVarKind;
1110
use rustc_ast::tokenstream::TokenStream;
1211
use rustc_ast::visit::{AssocCtxt, Visitor};
1312
use rustc_ast::{self as ast, AttrVec, Attribute, HasAttrs, Item, NodeId, PatKind, Safety};
@@ -22,14 +21,14 @@ use rustc_hir::limit::Limit;
2221
use rustc_hir::{Stability, find_attr};
2322
use rustc_lint_defs::RegisteredTools;
2423
use rustc_parse::MACRO_ARGUMENTS;
25-
use rustc_parse::parser::{AllowConstBlockItems, ForceCollect, Parser};
24+
use rustc_parse::parser::Parser;
2625
use rustc_session::Session;
2726
use rustc_session::parse::ParseSess;
2827
use rustc_span::def_id::{CrateNum, DefId, LocalDefId};
2928
use rustc_span::edition::Edition;
3029
use rustc_span::hygiene::{AstPass, ExpnData, ExpnKind, LocalExpnId, MacroKind};
3130
use rustc_span::source_map::SourceMap;
32-
use rustc_span::{DUMMY_SP, FileName, Ident, Span, Symbol, kw, sym};
31+
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw};
3332
use smallvec::{SmallVec, smallvec};
3433
use thin_vec::ThinVec;
3534

@@ -1421,80 +1420,3 @@ pub fn resolve_path(sess: &Session, path: impl Into<PathBuf>, span: Span) -> PRe
14211420
}
14221421
}
14231422
}
1424-
1425-
/// If this item looks like a specific enums from `rental`, emit a fatal error.
1426-
/// See #73345 and #83125 for more details.
1427-
/// FIXME(#73933): Remove this eventually.
1428-
fn pretty_printing_compatibility_hack(item: &Item, psess: &ParseSess) {
1429-
if let ast::ItemKind::Enum(ident, _, enum_def) = &item.kind
1430-
&& ident.name == sym::ProceduralMasqueradeDummyType
1431-
&& let [variant] = &*enum_def.variants
1432-
&& variant.ident.name == sym::Input
1433-
&& let FileName::Real(real) = psess.source_map().span_to_filename(ident.span)
1434-
&& let Some(c) = real
1435-
.local_path()
1436-
.unwrap_or(Path::new(""))
1437-
.components()
1438-
.flat_map(|c| c.as_os_str().to_str())
1439-
.find(|c| c.starts_with("rental") || c.starts_with("allsorts-rental"))
1440-
{
1441-
let crate_matches = if c.starts_with("allsorts-rental") {
1442-
true
1443-
} else {
1444-
let mut version = c.trim_start_matches("rental-").split('.');
1445-
version.next() == Some("0")
1446-
&& version.next() == Some("5")
1447-
&& version.next().and_then(|c| c.parse::<u32>().ok()).is_some_and(|v| v < 6)
1448-
};
1449-
1450-
if crate_matches {
1451-
psess.dcx().emit_fatal(errors::ProcMacroBackCompat {
1452-
crate_name: "rental".to_string(),
1453-
fixed_version: "0.5.6".to_string(),
1454-
});
1455-
}
1456-
}
1457-
}
1458-
1459-
pub(crate) fn ann_pretty_printing_compatibility_hack(ann: &Annotatable, psess: &ParseSess) {
1460-
let item = match ann {
1461-
Annotatable::Item(item) => item,
1462-
Annotatable::Stmt(stmt) => match &stmt.kind {
1463-
ast::StmtKind::Item(item) => item,
1464-
_ => return,
1465-
},
1466-
_ => return,
1467-
};
1468-
pretty_printing_compatibility_hack(item, psess)
1469-
}
1470-
1471-
pub(crate) fn stream_pretty_printing_compatibility_hack(
1472-
kind: MetaVarKind,
1473-
stream: &TokenStream,
1474-
psess: &ParseSess,
1475-
) {
1476-
let item = match kind {
1477-
MetaVarKind::Item => {
1478-
let mut parser = Parser::new(psess, stream.clone(), None);
1479-
// No need to collect tokens for this simple check.
1480-
parser
1481-
.parse_item(ForceCollect::No, AllowConstBlockItems::No)
1482-
.expect("failed to reparse item")
1483-
.expect("an actual item")
1484-
}
1485-
MetaVarKind::Stmt => {
1486-
let mut parser = Parser::new(psess, stream.clone(), None);
1487-
// No need to collect tokens for this simple check.
1488-
let stmt = parser
1489-
.parse_stmt(ForceCollect::No)
1490-
.expect("failed to reparse")
1491-
.expect("an actual stmt");
1492-
match &stmt.kind {
1493-
ast::StmtKind::Item(item) => item.clone(),
1494-
_ => return,
1495-
}
1496-
}
1497-
_ => return,
1498-
};
1499-
pretty_printing_compatibility_hack(&item, psess)
1500-
}

compiler/rustc_expand/src/errors.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -446,18 +446,6 @@ pub(crate) struct GlobDelegationTraitlessQpath {
446446
pub span: Span,
447447
}
448448

449-
// This used to be the `proc_macro_back_compat` lint (#83125). It was later
450-
// turned into a hard error.
451-
#[derive(Diagnostic)]
452-
#[diag("using an old version of `{$crate_name}`")]
453-
#[note(
454-
"older versions of the `{$crate_name}` crate no longer compile; please update to `{$crate_name}` v{$fixed_version}, or switch to one of the `{$crate_name}` alternatives"
455-
)]
456-
pub(crate) struct ProcMacroBackCompat {
457-
pub crate_name: String,
458-
pub fixed_version: String,
459-
}
460-
461449
pub(crate) use metavar_exprs::*;
462450
mod metavar_exprs {
463451
use super::*;

compiler/rustc_expand/src/proc_macro.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,6 @@ impl MultiItemModifier for DeriveProcMacro {
105105
// (e.g. `fn foo() { #[derive(Debug)] struct Bar; }`)
106106
let is_stmt = matches!(item, Annotatable::Stmt(..));
107107

108-
// We used to have an alternative behaviour for crates that needed it.
109-
// We had a lint for a long time, but now we just emit a hard error.
110-
// Eventually we might remove the special case hard error check
111-
// altogether. See #73345.
112-
crate::base::ann_pretty_printing_compatibility_hack(&item, &ecx.sess.psess);
113108
let input = item.to_tokens();
114109

115110
let invoc_id = ecx.current_expansion.id;

compiler/rustc_expand/src/proc_macro_server.rs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ impl ToInternal<token::LitKind> for LitKind {
103103
}
104104
}
105105

106-
impl FromInternal<(TokenStream, &mut Rustc<'_, '_>)> for Vec<TokenTree<TokenStream, Span, Symbol>> {
107-
fn from_internal((stream, rustc): (TokenStream, &mut Rustc<'_, '_>)) -> Self {
106+
impl FromInternal<TokenStream> for Vec<TokenTree<TokenStream, Span, Symbol>> {
107+
fn from_internal(stream: TokenStream) -> Self {
108108
use rustc_ast::token::*;
109109

110110
// Estimate the capacity as `stream.len()` rounded up to the next power
@@ -115,22 +115,6 @@ impl FromInternal<(TokenStream, &mut Rustc<'_, '_>)> for Vec<TokenTree<TokenStre
115115
while let Some(tree) = iter.next() {
116116
let (Token { kind, span }, joint) = match tree.clone() {
117117
tokenstream::TokenTree::Delimited(span, _, mut delim, mut stream) => {
118-
// We used to have an alternative behaviour for crates that
119-
// needed it: a hack used to pass AST fragments to
120-
// attribute and derive macros as a single nonterminal
121-
// token instead of a token stream. Such token needs to be
122-
// "unwrapped" and not represented as a delimited group. We
123-
// had a lint for a long time, but now we just emit a hard
124-
// error. Eventually we might remove the special case hard
125-
// error check altogether. See #73345.
126-
if let Delimiter::Invisible(InvisibleOrigin::MetaVar(kind)) = delim {
127-
crate::base::stream_pretty_printing_compatibility_hack(
128-
kind,
129-
&stream,
130-
rustc.psess(),
131-
);
132-
}
133-
134118
// In `mk_delimited` we avoid nesting invisible delimited
135119
// of the same `MetaVarKind`. Here we do the same but
136120
// ignore the `MetaVarKind` because it is discarded when we
@@ -687,7 +671,7 @@ impl server::Server for Rustc<'_, '_> {
687671
&mut self,
688672
stream: Self::TokenStream,
689673
) -> Vec<TokenTree<Self::TokenStream, Self::Span, Self::Symbol>> {
690-
FromInternal::from_internal((stream, self))
674+
FromInternal::from_internal(stream)
691675
}
692676

693677
fn span_debug(&mut self, span: Self::Span) -> String {

compiler/rustc_span/src/symbol.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ symbols! {
327327
Pointer,
328328
Poll,
329329
ProcMacro,
330-
ProceduralMasqueradeDummyType,
331330
Range,
332331
RangeBounds,
333332
RangeCopy,

tests/ui/proc-macro/pretty-print-hack-hide.rs

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/ui/proc-macro/pretty-print-hack-hide.stdout

Lines changed: 0 additions & 21 deletions
This file was deleted.

tests/ui/proc-macro/pretty-print-hack-show.local.stderr

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/ui/proc-macro/pretty-print-hack-show.remapped.stderr

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/ui/proc-macro/pretty-print-hack-show.rs

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)