|
1 | 1 | use crate::base::ExtCtxt; |
2 | 2 |
|
3 | 3 | use rustc_ast as ast; |
4 | | -use rustc_ast::token::{self, Nonterminal, NtIdent}; |
| 4 | +use rustc_ast::token; |
5 | 5 | use rustc_ast::tokenstream::{self, CanSynthesizeMissingTokens}; |
6 | 6 | use rustc_ast::tokenstream::{DelimSpan, Spacing::*, TokenStream, TreeAndSpacing}; |
7 | 7 | use rustc_ast_pretty::pprust; |
8 | 8 | use rustc_data_structures::fx::FxHashMap; |
9 | 9 | use rustc_data_structures::sync::Lrc; |
10 | 10 | use rustc_errors::{Diagnostic, PResult}; |
11 | | -use rustc_lint_defs::builtin::PROC_MACRO_BACK_COMPAT; |
12 | | -use rustc_lint_defs::BuiltinLintDiagnostics; |
13 | 11 | use rustc_parse::lexer::nfc_normalize; |
14 | 12 | use rustc_parse::{nt_to_tokenstream, parse_stream_from_source_str}; |
15 | 13 | use rustc_session::parse::ParseSess; |
16 | 14 | use rustc_span::def_id::CrateNum; |
17 | | -use rustc_span::hygiene::ExpnKind; |
18 | 15 | use rustc_span::symbol::{self, kw, sym, Symbol}; |
19 | | -use rustc_span::{BytePos, FileName, MultiSpan, Pos, RealFileName, SourceFile, Span}; |
| 16 | +use rustc_span::{BytePos, FileName, MultiSpan, Pos, SourceFile, Span}; |
20 | 17 |
|
21 | 18 | use pm::bridge::{server, TokenTree}; |
22 | 19 | use pm::{Delimiter, Level, LineColumn, Spacing}; |
@@ -178,10 +175,8 @@ impl FromInternal<(TreeAndSpacing, &'_ mut Vec<Self>, &mut Rustc<'_, '_>)> |
178 | 175 | tt!(Punct::new('#', false)) |
179 | 176 | } |
180 | 177 |
|
181 | | - Interpolated(nt) |
182 | | - if let Some((name, is_raw)) = ident_name_compatibility_hack(&nt, span, rustc) => |
183 | | - { |
184 | | - TokenTree::Ident(Ident::new(rustc.sess(), name.name, is_raw, name.span)) |
| 178 | + Interpolated(nt) if let NtIdent(ident, is_raw) = *nt => { |
| 179 | + TokenTree::Ident(Ident::new(rustc.sess(), ident.name, is_raw, ident.span)) |
185 | 180 | } |
186 | 181 | Interpolated(nt) => { |
187 | 182 | let stream = nt_to_tokenstream(&nt, rustc.sess(), CanSynthesizeMissingTokens::No); |
@@ -868,100 +863,3 @@ impl server::Span for Rustc<'_, '_> { |
868 | 863 | }) |
869 | 864 | } |
870 | 865 | } |
871 | | - |
872 | | -// See issue #74616 for details |
873 | | -fn ident_name_compatibility_hack( |
874 | | - nt: &Nonterminal, |
875 | | - orig_span: Span, |
876 | | - rustc: &mut Rustc<'_, '_>, |
877 | | -) -> Option<(rustc_span::symbol::Ident, bool)> { |
878 | | - if let NtIdent(ident, is_raw) = nt { |
879 | | - if let ExpnKind::Macro(_, macro_name) = orig_span.ctxt().outer_expn_data().kind { |
880 | | - let source_map = rustc.sess().source_map(); |
881 | | - let filename = source_map.span_to_filename(orig_span); |
882 | | - if let FileName::Real(RealFileName::LocalPath(path)) = filename { |
883 | | - let matches_prefix = |prefix, filename| { |
884 | | - // Check for a path that ends with 'prefix*/src/<filename>' |
885 | | - let mut iter = path.components().rev(); |
886 | | - iter.next().and_then(|p| p.as_os_str().to_str()) == Some(filename) |
887 | | - && iter.next().and_then(|p| p.as_os_str().to_str()) == Some("src") |
888 | | - && iter |
889 | | - .next() |
890 | | - .and_then(|p| p.as_os_str().to_str()) |
891 | | - .map_or(false, |p| p.starts_with(prefix)) |
892 | | - }; |
893 | | - |
894 | | - let time_macros_impl = |
895 | | - macro_name == sym::impl_macros && matches_prefix("time-macros-impl", "lib.rs"); |
896 | | - let js_sys = macro_name == sym::arrays && matches_prefix("js-sys", "lib.rs"); |
897 | | - if time_macros_impl || js_sys { |
898 | | - let snippet = source_map.span_to_snippet(orig_span); |
899 | | - if snippet.as_deref() == Ok("$name") { |
900 | | - if time_macros_impl { |
901 | | - rustc.sess().buffer_lint_with_diagnostic( |
902 | | - &PROC_MACRO_BACK_COMPAT, |
903 | | - orig_span, |
904 | | - ast::CRATE_NODE_ID, |
905 | | - "using an old version of `time-macros-impl`", |
906 | | - BuiltinLintDiagnostics::ProcMacroBackCompat( |
907 | | - "the `time-macros-impl` crate will stop compiling in futures version of Rust. \ |
908 | | - Please update to the latest version of the `time` crate to avoid breakage".to_string()) |
909 | | - ); |
910 | | - return Some((*ident, *is_raw)); |
911 | | - } |
912 | | - if js_sys { |
913 | | - if let Some(c) = path |
914 | | - .components() |
915 | | - .flat_map(|c| c.as_os_str().to_str()) |
916 | | - .find(|c| c.starts_with("js-sys")) |
917 | | - { |
918 | | - let mut version = c.trim_start_matches("js-sys-").split('.'); |
919 | | - if version.next() == Some("0") |
920 | | - && version.next() == Some("3") |
921 | | - && version |
922 | | - .next() |
923 | | - .and_then(|c| c.parse::<u32>().ok()) |
924 | | - .map_or(false, |v| v < 40) |
925 | | - { |
926 | | - rustc.sess().buffer_lint_with_diagnostic( |
927 | | - &PROC_MACRO_BACK_COMPAT, |
928 | | - orig_span, |
929 | | - ast::CRATE_NODE_ID, |
930 | | - "using an old version of `js-sys`", |
931 | | - BuiltinLintDiagnostics::ProcMacroBackCompat( |
932 | | - "older versions of the `js-sys` crate will stop compiling in future versions of Rust; \ |
933 | | - please update to `js-sys` v0.3.40 or above".to_string()) |
934 | | - ); |
935 | | - return Some((*ident, *is_raw)); |
936 | | - } |
937 | | - } |
938 | | - } |
939 | | - } |
940 | | - } |
941 | | - |
942 | | - if macro_name == sym::tuple_from_req && matches_prefix("actix-web", "extract.rs") { |
943 | | - let snippet = source_map.span_to_snippet(orig_span); |
944 | | - if snippet.as_deref() == Ok("$T") { |
945 | | - if let FileName::Real(RealFileName::LocalPath(macro_path)) = |
946 | | - source_map.span_to_filename(rustc.def_site) |
947 | | - { |
948 | | - if macro_path.to_string_lossy().contains("pin-project-internal-0.") { |
949 | | - rustc.sess().buffer_lint_with_diagnostic( |
950 | | - &PROC_MACRO_BACK_COMPAT, |
951 | | - orig_span, |
952 | | - ast::CRATE_NODE_ID, |
953 | | - "using an old version of `actix-web`", |
954 | | - BuiltinLintDiagnostics::ProcMacroBackCompat( |
955 | | - "the version of `actix-web` you are using might stop compiling in future versions of Rust; \ |
956 | | - please update to the latest version of the `actix-web` crate to avoid breakage".to_string()) |
957 | | - ); |
958 | | - return Some((*ident, *is_raw)); |
959 | | - } |
960 | | - } |
961 | | - } |
962 | | - } |
963 | | - } |
964 | | - } |
965 | | - } |
966 | | - None |
967 | | -} |
0 commit comments