]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_session/parse.rs
Rollup merge of #68079 - varkor:E0013-clarify, r=Centril
[rust.git] / src / librustc_session / parse.rs
index 2a5945d2b059538376ad02980cd9fa311ad4a132..946e77d35595e101ee35d03844c75e9becbef0e7 100644 (file)
@@ -1,7 +1,7 @@
 //! Contains `ParseSess` which holds state living beyond what one `Parser` might.
 //! It also serves as an input to the parser itself.
 
-use crate::lint::BufferedEarlyLint;
+use crate::lint::{BufferedEarlyLint, BuiltinLintDiagnostics, Lint, LintId};
 use crate::node_id::NodeId;
 
 use rustc_data_structures::fx::{FxHashMap, FxHashSet};
@@ -62,6 +62,8 @@ pub fn merge(&self, mut spans: FxHashMap<Symbol, Vec<Span>>) {
     }
 }
 
+/// The strenght of a feature gate.
+/// Either it is a `Hard` error, or only a `Soft` warning.
 #[derive(Debug, Copy, Clone, PartialEq)]
 pub enum GateStrength {
     /// A hard error. (Most feature gates should use this.)
@@ -70,6 +72,8 @@ pub enum GateStrength {
     Soft,
 }
 
+/// Construct a diagnostic for a language feature error due to the given `span`.
+/// The `feature`'s `Symbol` is the one you used in `active.rs` and `rustc_span::symbols`.
 pub fn feature_err<'a>(
     sess: &'a ParseSess,
     feature: Symbol,
@@ -79,6 +83,10 @@ pub fn feature_err<'a>(
     feature_err_issue(sess, feature, span, GateIssue::Language, explain)
 }
 
+/// Construct a diagnostic for a feature gate error.
+///
+/// This variant allows you to control whether it is a library or language feature.
+/// Almost always, you want to use this for a language feature. If so, prefer `feature_err`.
 pub fn feature_err_issue<'a>(
     sess: &'a ParseSess,
     feature: Symbol,
@@ -89,6 +97,9 @@ pub fn feature_err_issue<'a>(
     leveled_feature_err(sess, feature, span, issue, explain, GateStrength::Hard)
 }
 
+/// Construct a diagnostic for a feature gate error / warning.
+///
+/// You should typically just use `feature_err` instead.
 pub fn leveled_feature_err<'a>(
     sess: &'a ParseSess,
     feature: Symbol,
@@ -187,17 +198,18 @@ pub fn source_map(&self) -> &SourceMap {
 
     pub fn buffer_lint(
         &self,
-        lint_id: &'static crate::lint::Lint,
+        lint: &'static Lint,
         span: impl Into<MultiSpan>,
-        id: NodeId,
+        node_id: NodeId,
         msg: &str,
     ) {
         self.buffered_lints.with_lock(|buffered_lints| {
             buffered_lints.push(BufferedEarlyLint {
                 span: span.into(),
-                id,
+                node_id,
                 msg: msg.into(),
-                lint_id,
+                lint_id: LintId::of(lint),
+                diagnostic: BuiltinLintDiagnostics::Normal,
             });
         });
     }