Rollup merge of #49395 - petrochenkov:obsolete, r=alexcrichton

libsyntax: Remove obsolete.rs

This little piece of infra is obsolete (ha-ha) and is unlikely to be used in the future, even if new obsolete syntax appears.
This commit is contained in:
kennytm 2018-03-27 10:47:51 +02:00 committed by GitHub
commit 5eb4689d1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 74 deletions

View File

@ -40,7 +40,6 @@ pub mod attr;
pub mod common;
pub mod classify;
pub mod obsolete;
/// Info about a parsing session.
pub struct ParseSess {

View File

@ -1,67 +0,0 @@
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! Support for parsing unsupported, old syntaxes, for the purpose of reporting errors. Parsing of
//! these syntaxes is tested by compile-test/obsolete-syntax.rs.
//!
//! Obsolete syntax that becomes too hard to parse can be removed.
use syntax_pos::Span;
use parse::parser;
/// The specific types of unsupported syntax
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub enum ObsoleteSyntax {
// Nothing here at the moment
}
pub trait ParserObsoleteMethods {
/// Reports an obsolete syntax non-fatal error.
fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax);
fn report(&mut self,
sp: Span,
kind: ObsoleteSyntax,
kind_str: &str,
desc: &str,
error: bool);
}
impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
/// Reports an obsolete syntax non-fatal error.
#[allow(unused_variables)]
#[allow(unreachable_code)]
fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax) {
let (kind_str, desc, error) = match kind {
// Nothing here at the moment
};
self.report(sp, kind, kind_str, desc, error);
}
fn report(&mut self,
sp: Span,
kind: ObsoleteSyntax,
kind_str: &str,
desc: &str,
error: bool) {
let mut err = if error {
self.diagnostic().struct_span_err(sp, &format!("obsolete syntax: {}", kind_str))
} else {
self.diagnostic().struct_span_warn(sp, &format!("obsolete syntax: {}", kind_str))
};
if !self.obsolete_set.contains(&kind) &&
(error || self.sess.span_diagnostic.flags.can_emit_warnings) {
err.note(desc);
self.obsolete_set.insert(kind);
}
err.emit();
}
}

View File

@ -48,7 +48,6 @@ use parse::{self, classify, token};
use parse::common::SeqSep;
use parse::lexer::TokenAndSpan;
use parse::lexer::comments::{doc_comment_style, strip_doc_comment_decoration};
use parse::obsolete::ObsoleteSyntax;
use parse::{new_sub_parser_from_file, ParseSess, Directory, DirectoryOwnership};
use util::parser::{AssocOp, Fixity};
use print::pprust;
@ -59,7 +58,6 @@ use symbol::{Symbol, keywords};
use util::ThinVec;
use std::cmp;
use std::collections::HashSet;
use std::mem;
use std::path::{self, Path, PathBuf};
use std::slice;
@ -229,9 +227,6 @@ pub struct Parser<'a> {
/// the previous token kind
prev_token_kind: PrevTokenKind,
pub restrictions: Restrictions,
/// The set of seen errors about obsolete syntax. Used to suppress
/// extra detail when the same error is seen twice
pub obsolete_set: HashSet<ObsoleteSyntax>,
/// Used to determine the path to externally loaded source files
pub directory: Directory,
/// Whether to parse sub-modules in other files.
@ -555,7 +550,6 @@ impl<'a> Parser<'a> {
meta_var_span: None,
prev_token_kind: PrevTokenKind::Other,
restrictions: Restrictions::empty(),
obsolete_set: HashSet::new(),
recurse_into_file_modules,
directory: Directory {
path: PathBuf::new(),