Add check for ui_testing via promoting parameters from ParseSess
to Session
This commit is contained in:
parent
b55faad314
commit
36a69e9d39
44 changed files with 188 additions and 233 deletions
|
@ -48,7 +48,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
);
|
);
|
||||||
if !is_stable && !self.tcx.features().asm_experimental_arch {
|
if !is_stable && !self.tcx.features().asm_experimental_arch {
|
||||||
feature_err(
|
feature_err(
|
||||||
&self.tcx.sess.parse_sess,
|
&self.tcx.sess,
|
||||||
sym::asm_experimental_arch,
|
sym::asm_experimental_arch,
|
||||||
sp,
|
sp,
|
||||||
"inline assembly is not stable yet on this architecture",
|
"inline assembly is not stable yet on this architecture",
|
||||||
|
@ -63,12 +63,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
self.dcx().emit_err(AttSyntaxOnlyX86 { span: sp });
|
self.dcx().emit_err(AttSyntaxOnlyX86 { span: sp });
|
||||||
}
|
}
|
||||||
if asm.options.contains(InlineAsmOptions::MAY_UNWIND) && !self.tcx.features().asm_unwind {
|
if asm.options.contains(InlineAsmOptions::MAY_UNWIND) && !self.tcx.features().asm_unwind {
|
||||||
feature_err(
|
feature_err(&self.tcx.sess, sym::asm_unwind, sp, "the `may_unwind` option is unstable")
|
||||||
&self.tcx.sess.parse_sess,
|
|
||||||
sym::asm_unwind,
|
|
||||||
sp,
|
|
||||||
"the `may_unwind` option is unstable",
|
|
||||||
)
|
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +178,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
InlineAsmOperand::Const { anon_const } => {
|
InlineAsmOperand::Const { anon_const } => {
|
||||||
if !self.tcx.features().asm_const {
|
if !self.tcx.features().asm_const {
|
||||||
feature_err(
|
feature_err(
|
||||||
&sess.parse_sess,
|
sess,
|
||||||
sym::asm_const,
|
sym::asm_const,
|
||||||
*op_sp,
|
*op_sp,
|
||||||
"const operands for inline assembly are unstable",
|
"const operands for inline assembly are unstable",
|
||||||
|
|
|
@ -1512,7 +1512,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
Some(hir::CoroutineKind::Coroutine(_)) => {
|
Some(hir::CoroutineKind::Coroutine(_)) => {
|
||||||
if !self.tcx.features().coroutines {
|
if !self.tcx.features().coroutines {
|
||||||
rustc_session::parse::feature_err(
|
rustc_session::parse::feature_err(
|
||||||
&self.tcx.sess.parse_sess,
|
&self.tcx.sess,
|
||||||
sym::coroutines,
|
sym::coroutines,
|
||||||
span,
|
span,
|
||||||
"yield syntax is experimental",
|
"yield syntax is experimental",
|
||||||
|
@ -1524,7 +1524,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
None => {
|
None => {
|
||||||
if !self.tcx.features().coroutines {
|
if !self.tcx.features().coroutines {
|
||||||
rustc_session::parse::feature_err(
|
rustc_session::parse::feature_err(
|
||||||
&self.tcx.sess.parse_sess,
|
&self.tcx.sess,
|
||||||
sym::coroutines,
|
sym::coroutines,
|
||||||
span,
|
span,
|
||||||
"yield syntax is experimental",
|
"yield syntax is experimental",
|
||||||
|
|
|
@ -1043,7 +1043,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
{
|
{
|
||||||
add_feature_diagnostics(
|
add_feature_diagnostics(
|
||||||
&mut err,
|
&mut err,
|
||||||
&self.tcx.sess.parse_sess,
|
&self.tcx.sess,
|
||||||
sym::return_type_notation,
|
sym::return_type_notation,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -2310,7 +2310,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
hir::ArrayLen::Infer(self.lower_node_id(c.id), self.lower_span(c.value.span))
|
hir::ArrayLen::Infer(self.lower_node_id(c.id), self.lower_span(c.value.span))
|
||||||
} else {
|
} else {
|
||||||
feature_err(
|
feature_err(
|
||||||
&self.tcx.sess.parse_sess,
|
&self.tcx.sess,
|
||||||
sym::generic_arg_infer,
|
sym::generic_arg_infer,
|
||||||
c.value.span,
|
c.value.span,
|
||||||
"using `_` for array lengths is unstable",
|
"using `_` for array lengths is unstable",
|
||||||
|
|
|
@ -17,14 +17,12 @@ use crate::errors;
|
||||||
macro_rules! gate {
|
macro_rules! gate {
|
||||||
($visitor:expr, $feature:ident, $span:expr, $explain:expr) => {{
|
($visitor:expr, $feature:ident, $span:expr, $explain:expr) => {{
|
||||||
if !$visitor.features.$feature && !$span.allows_unstable(sym::$feature) {
|
if !$visitor.features.$feature && !$span.allows_unstable(sym::$feature) {
|
||||||
feature_err(&$visitor.sess.parse_sess, sym::$feature, $span, $explain).emit();
|
feature_err(&$visitor.sess, sym::$feature, $span, $explain).emit();
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
($visitor:expr, $feature:ident, $span:expr, $explain:expr, $help:expr) => {{
|
($visitor:expr, $feature:ident, $span:expr, $explain:expr, $help:expr) => {{
|
||||||
if !$visitor.features.$feature && !$span.allows_unstable(sym::$feature) {
|
if !$visitor.features.$feature && !$span.allows_unstable(sym::$feature) {
|
||||||
feature_err(&$visitor.sess.parse_sess, sym::$feature, $span, $explain)
|
feature_err(&$visitor.sess, sym::$feature, $span, $explain).with_help($help).emit();
|
||||||
.with_help($help)
|
|
||||||
.emit();
|
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
@ -33,7 +31,7 @@ macro_rules! gate {
|
||||||
macro_rules! gate_alt {
|
macro_rules! gate_alt {
|
||||||
($visitor:expr, $has_feature:expr, $name:expr, $span:expr, $explain:expr) => {{
|
($visitor:expr, $has_feature:expr, $name:expr, $span:expr, $explain:expr) => {{
|
||||||
if !$has_feature && !$span.allows_unstable($name) {
|
if !$has_feature && !$span.allows_unstable($name) {
|
||||||
feature_err(&$visitor.sess.parse_sess, $name, $span, $explain).emit();
|
feature_err(&$visitor.sess, $name, $span, $explain).emit();
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
@ -45,7 +43,7 @@ macro_rules! gate_multi {
|
||||||
let spans: Vec<_> =
|
let spans: Vec<_> =
|
||||||
$spans.filter(|span| !span.allows_unstable(sym::$feature)).collect();
|
$spans.filter(|span| !span.allows_unstable(sym::$feature)).collect();
|
||||||
if !spans.is_empty() {
|
if !spans.is_empty() {
|
||||||
feature_err(&$visitor.sess.parse_sess, sym::$feature, spans, $explain).emit();
|
feature_err(&$visitor.sess, sym::$feature, spans, $explain).emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
|
@ -55,7 +53,7 @@ macro_rules! gate_multi {
|
||||||
macro_rules! gate_legacy {
|
macro_rules! gate_legacy {
|
||||||
($visitor:expr, $feature:ident, $span:expr, $explain:expr) => {{
|
($visitor:expr, $feature:ident, $span:expr, $explain:expr) => {{
|
||||||
if !$visitor.features.$feature && !$span.allows_unstable(sym::$feature) {
|
if !$visitor.features.$feature && !$span.allows_unstable(sym::$feature) {
|
||||||
feature_warn(&$visitor.sess.parse_sess, sym::$feature, $span, $explain);
|
feature_warn(&$visitor.sess, sym::$feature, $span, $explain);
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
@ -91,14 +89,7 @@ impl<'a> PostExpansionVisitor<'a> {
|
||||||
match abi::is_enabled(self.features, span, symbol_unescaped.as_str()) {
|
match abi::is_enabled(self.features, span, symbol_unescaped.as_str()) {
|
||||||
Ok(()) => (),
|
Ok(()) => (),
|
||||||
Err(abi::AbiDisabled::Unstable { feature, explain }) => {
|
Err(abi::AbiDisabled::Unstable { feature, explain }) => {
|
||||||
feature_err_issue(
|
feature_err_issue(&self.sess, feature, span, GateIssue::Language, explain).emit();
|
||||||
&self.sess.parse_sess,
|
|
||||||
feature,
|
|
||||||
span,
|
|
||||||
GateIssue::Language,
|
|
||||||
explain,
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
}
|
}
|
||||||
Err(abi::AbiDisabled::Unrecognized) => {
|
Err(abi::AbiDisabled::Unrecognized) => {
|
||||||
if self.sess.opts.pretty.map_or(true, |ppm| ppm.needs_hir()) {
|
if self.sess.opts.pretty.map_or(true, |ppm| ppm.needs_hir()) {
|
||||||
|
@ -571,12 +562,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
|
||||||
if let Ok(snippet) = sm.span_to_snippet(span)
|
if let Ok(snippet) = sm.span_to_snippet(span)
|
||||||
&& snippet == "!"
|
&& snippet == "!"
|
||||||
{
|
{
|
||||||
feature_err(
|
feature_err(sess, sym::never_patterns, span, "`!` patterns are experimental")
|
||||||
&sess.parse_sess,
|
|
||||||
sym::never_patterns,
|
|
||||||
span,
|
|
||||||
"`!` patterns are experimental",
|
|
||||||
)
|
|
||||||
.emit();
|
.emit();
|
||||||
} else {
|
} else {
|
||||||
let suggestion = span.shrink_to_hi();
|
let suggestion = span.shrink_to_hi();
|
||||||
|
|
|
@ -9,7 +9,7 @@ use rustc_macros::HashStable_Generic;
|
||||||
use rustc_session::config::ExpectedValues;
|
use rustc_session::config::ExpectedValues;
|
||||||
use rustc_session::lint::builtin::UNEXPECTED_CFGS;
|
use rustc_session::lint::builtin::UNEXPECTED_CFGS;
|
||||||
use rustc_session::lint::BuiltinLintDiagnostics;
|
use rustc_session::lint::BuiltinLintDiagnostics;
|
||||||
use rustc_session::parse::{feature_err, ParseSess};
|
use rustc_session::parse::feature_err;
|
||||||
use rustc_session::{RustcVersion, Session};
|
use rustc_session::{RustcVersion, Session};
|
||||||
use rustc_span::hygiene::Transparency;
|
use rustc_span::hygiene::Transparency;
|
||||||
use rustc_span::{symbol::sym, symbol::Symbol, Span};
|
use rustc_span::{symbol::sym, symbol::Symbol, Span};
|
||||||
|
@ -518,15 +518,15 @@ pub struct Condition {
|
||||||
/// Tests if a cfg-pattern matches the cfg set
|
/// Tests if a cfg-pattern matches the cfg set
|
||||||
pub fn cfg_matches(
|
pub fn cfg_matches(
|
||||||
cfg: &ast::MetaItem,
|
cfg: &ast::MetaItem,
|
||||||
sess: &ParseSess,
|
sess: &Session,
|
||||||
lint_node_id: NodeId,
|
lint_node_id: NodeId,
|
||||||
features: Option<&Features>,
|
features: Option<&Features>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
eval_condition(cfg, sess, features, &mut |cfg| {
|
eval_condition(cfg, sess, features, &mut |cfg| {
|
||||||
try_gate_cfg(cfg.name, cfg.span, sess, features);
|
try_gate_cfg(cfg.name, cfg.span, sess, features);
|
||||||
match sess.check_config.expecteds.get(&cfg.name) {
|
match sess.parse_sess.check_config.expecteds.get(&cfg.name) {
|
||||||
Some(ExpectedValues::Some(values)) if !values.contains(&cfg.value) => {
|
Some(ExpectedValues::Some(values)) if !values.contains(&cfg.value) => {
|
||||||
sess.buffer_lint_with_diagnostic(
|
sess.parse_sess.buffer_lint_with_diagnostic(
|
||||||
UNEXPECTED_CFGS,
|
UNEXPECTED_CFGS,
|
||||||
cfg.span,
|
cfg.span,
|
||||||
lint_node_id,
|
lint_node_id,
|
||||||
|
@ -541,8 +541,8 @@ pub fn cfg_matches(
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
None if sess.check_config.exhaustive_names => {
|
None if sess.parse_sess.check_config.exhaustive_names => {
|
||||||
sess.buffer_lint_with_diagnostic(
|
sess.parse_sess.buffer_lint_with_diagnostic(
|
||||||
UNEXPECTED_CFGS,
|
UNEXPECTED_CFGS,
|
||||||
cfg.span,
|
cfg.span,
|
||||||
lint_node_id,
|
lint_node_id,
|
||||||
|
@ -555,18 +555,18 @@ pub fn cfg_matches(
|
||||||
}
|
}
|
||||||
_ => { /* not unexpected */ }
|
_ => { /* not unexpected */ }
|
||||||
}
|
}
|
||||||
sess.config.contains(&(cfg.name, cfg.value))
|
sess.parse_sess.config.contains(&(cfg.name, cfg.value))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_gate_cfg(name: Symbol, span: Span, sess: &ParseSess, features: Option<&Features>) {
|
fn try_gate_cfg(name: Symbol, span: Span, sess: &Session, features: Option<&Features>) {
|
||||||
let gate = find_gated_cfg(|sym| sym == name);
|
let gate = find_gated_cfg(|sym| sym == name);
|
||||||
if let (Some(feats), Some(gated_cfg)) = (features, gate) {
|
if let (Some(feats), Some(gated_cfg)) = (features, gate) {
|
||||||
gate_cfg(gated_cfg, span, sess, feats);
|
gate_cfg(gated_cfg, span, sess, feats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gate_cfg(gated_cfg: &GatedCfg, cfg_span: Span, sess: &ParseSess, features: &Features) {
|
fn gate_cfg(gated_cfg: &GatedCfg, cfg_span: Span, sess: &Session, features: &Features) {
|
||||||
let (cfg, feature, has_feature) = gated_cfg;
|
let (cfg, feature, has_feature) = gated_cfg;
|
||||||
if !has_feature(features) && !cfg_span.allows_unstable(*feature) {
|
if !has_feature(features) && !cfg_span.allows_unstable(*feature) {
|
||||||
let explain = format!("`cfg({cfg})` is experimental and subject to change");
|
let explain = format!("`cfg({cfg})` is experimental and subject to change");
|
||||||
|
@ -594,11 +594,11 @@ fn parse_version(s: Symbol) -> Option<RustcVersion> {
|
||||||
/// evaluate individual items.
|
/// evaluate individual items.
|
||||||
pub fn eval_condition(
|
pub fn eval_condition(
|
||||||
cfg: &ast::MetaItem,
|
cfg: &ast::MetaItem,
|
||||||
sess: &ParseSess,
|
sess: &Session,
|
||||||
features: Option<&Features>,
|
features: Option<&Features>,
|
||||||
eval: &mut impl FnMut(Condition) -> bool,
|
eval: &mut impl FnMut(Condition) -> bool,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let dcx = &sess.dcx;
|
let dcx = &sess.parse_sess.dcx;
|
||||||
match &cfg.kind {
|
match &cfg.kind {
|
||||||
ast::MetaItemKind::List(mis) if cfg.name_or_empty() == sym::version => {
|
ast::MetaItemKind::List(mis) if cfg.name_or_empty() == sym::version => {
|
||||||
try_gate_cfg(sym::version, cfg.span, sess, features);
|
try_gate_cfg(sym::version, cfg.span, sess, features);
|
||||||
|
@ -626,7 +626,7 @@ pub fn eval_condition(
|
||||||
};
|
};
|
||||||
|
|
||||||
// See https://github.com/rust-lang/rust/issues/64796#issuecomment-640851454 for details
|
// See https://github.com/rust-lang/rust/issues/64796#issuecomment-640851454 for details
|
||||||
if sess.assume_incomplete_release {
|
if sess.parse_sess.assume_incomplete_release {
|
||||||
RustcVersion::CURRENT > min_version
|
RustcVersion::CURRENT > min_version
|
||||||
} else {
|
} else {
|
||||||
RustcVersion::CURRENT >= min_version
|
RustcVersion::CURRENT >= min_version
|
||||||
|
|
|
@ -22,7 +22,7 @@ pub fn expand_cfg(
|
||||||
Ok(cfg) => {
|
Ok(cfg) => {
|
||||||
let matches_cfg = attr::cfg_matches(
|
let matches_cfg = attr::cfg_matches(
|
||||||
&cfg,
|
&cfg,
|
||||||
&cx.sess.parse_sess,
|
&cx.sess,
|
||||||
cx.current_expansion.lint_node_id,
|
cx.current_expansion.lint_node_id,
|
||||||
Some(cx.ecfg.features),
|
Some(cx.ecfg.features),
|
||||||
);
|
);
|
||||||
|
|
|
@ -107,7 +107,7 @@ pub fn expand_include<'cx>(
|
||||||
return DummyResult::any(sp);
|
return DummyResult::any(sp);
|
||||||
};
|
};
|
||||||
// The file will be added to the code map by the parser
|
// The file will be added to the code map by the parser
|
||||||
let file = match resolve_path(&cx.sess.parse_sess, file.as_str(), sp) {
|
let file = match resolve_path(&cx.sess, file.as_str(), sp) {
|
||||||
Ok(f) => f,
|
Ok(f) => f,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.emit();
|
err.emit();
|
||||||
|
@ -179,7 +179,7 @@ pub fn expand_include_str(
|
||||||
let Some(file) = get_single_str_from_tts(cx, sp, tts, "include_str!") else {
|
let Some(file) = get_single_str_from_tts(cx, sp, tts, "include_str!") else {
|
||||||
return DummyResult::any(sp);
|
return DummyResult::any(sp);
|
||||||
};
|
};
|
||||||
let file = match resolve_path(&cx.sess.parse_sess, file.as_str(), sp) {
|
let file = match resolve_path(&cx.sess, file.as_str(), sp) {
|
||||||
Ok(f) => f,
|
Ok(f) => f,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.emit();
|
err.emit();
|
||||||
|
@ -213,7 +213,7 @@ pub fn expand_include_bytes(
|
||||||
let Some(file) = get_single_str_from_tts(cx, sp, tts, "include_bytes!") else {
|
let Some(file) = get_single_str_from_tts(cx, sp, tts, "include_bytes!") else {
|
||||||
return DummyResult::any(sp);
|
return DummyResult::any(sp);
|
||||||
};
|
};
|
||||||
let file = match resolve_path(&cx.sess.parse_sess, file.as_str(), sp) {
|
let file = match resolve_path(&cx.sess, file.as_str(), sp) {
|
||||||
Ok(f) => f,
|
Ok(f) => f,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.emit();
|
err.emit();
|
||||||
|
|
|
@ -2860,7 +2860,7 @@ fn add_dynamic_crate(cmd: &mut dyn Linker, sess: &Session, cratepath: &Path) {
|
||||||
|
|
||||||
fn relevant_lib(sess: &Session, lib: &NativeLib) -> bool {
|
fn relevant_lib(sess: &Session, lib: &NativeLib) -> bool {
|
||||||
match lib.cfg {
|
match lib.cfg {
|
||||||
Some(ref cfg) => rustc_attr::cfg_matches(cfg, &sess.parse_sess, CRATE_NODE_ID, None),
|
Some(ref cfg) => rustc_attr::cfg_matches(cfg, sess, CRATE_NODE_ID, None),
|
||||||
None => true,
|
None => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||||
Some([item]) if item.has_name(sym::linker) => {
|
Some([item]) if item.has_name(sym::linker) => {
|
||||||
if !tcx.features().used_with_arg {
|
if !tcx.features().used_with_arg {
|
||||||
feature_err(
|
feature_err(
|
||||||
&tcx.sess.parse_sess,
|
&tcx.sess,
|
||||||
sym::used_with_arg,
|
sym::used_with_arg,
|
||||||
attr.span,
|
attr.span,
|
||||||
"`#[used(linker)]` is currently unstable",
|
"`#[used(linker)]` is currently unstable",
|
||||||
|
@ -167,7 +167,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||||
Some([item]) if item.has_name(sym::compiler) => {
|
Some([item]) if item.has_name(sym::compiler) => {
|
||||||
if !tcx.features().used_with_arg {
|
if !tcx.features().used_with_arg {
|
||||||
feature_err(
|
feature_err(
|
||||||
&tcx.sess.parse_sess,
|
&tcx.sess,
|
||||||
sym::used_with_arg,
|
sym::used_with_arg,
|
||||||
attr.span,
|
attr.span,
|
||||||
"`#[used(compiler)]` is currently unstable",
|
"`#[used(compiler)]` is currently unstable",
|
||||||
|
@ -251,7 +251,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||||
&& !attr.span.allows_unstable(sym::closure_track_caller)
|
&& !attr.span.allows_unstable(sym::closure_track_caller)
|
||||||
{
|
{
|
||||||
feature_err(
|
feature_err(
|
||||||
&tcx.sess.parse_sess,
|
&tcx.sess,
|
||||||
sym::closure_track_caller,
|
sym::closure_track_caller,
|
||||||
attr.span,
|
attr.span,
|
||||||
"`#[track_caller]` on closures is currently unstable",
|
"`#[track_caller]` on closures is currently unstable",
|
||||||
|
@ -304,7 +304,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||||
// `#[target_feature]` on `main` and `start`.
|
// `#[target_feature]` on `main` and `start`.
|
||||||
} else if !tcx.features().target_feature_11 {
|
} else if !tcx.features().target_feature_11 {
|
||||||
feature_err(
|
feature_err(
|
||||||
&tcx.sess.parse_sess,
|
&tcx.sess,
|
||||||
sym::target_feature_11,
|
sym::target_feature_11,
|
||||||
attr.span,
|
attr.span,
|
||||||
"`#[target_feature(..)]` can only be applied to `unsafe` functions",
|
"`#[target_feature(..)]` can only be applied to `unsafe` functions",
|
||||||
|
|
|
@ -82,7 +82,7 @@ pub fn from_target_feature(
|
||||||
};
|
};
|
||||||
if !allowed {
|
if !allowed {
|
||||||
feature_err(
|
feature_err(
|
||||||
&tcx.sess.parse_sess,
|
&tcx.sess,
|
||||||
feature_gate.unwrap(),
|
feature_gate.unwrap(),
|
||||||
item.span(),
|
item.span(),
|
||||||
format!("the target feature `{feature}` is currently unstable"),
|
format!("the target feature `{feature}` is currently unstable"),
|
||||||
|
|
|
@ -64,7 +64,7 @@ impl<'tcx> NonConstOp<'tcx> for FloatingPointOp {
|
||||||
|
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
feature_err(
|
feature_err(
|
||||||
&ccx.tcx.sess.parse_sess,
|
&ccx.tcx.sess,
|
||||||
sym::const_fn_floating_point_arithmetic,
|
sym::const_fn_floating_point_arithmetic,
|
||||||
span,
|
span,
|
||||||
format!("floating point arithmetic is not allowed in {}s", ccx.const_kind()),
|
format!("floating point arithmetic is not allowed in {}s", ccx.const_kind()),
|
||||||
|
@ -553,7 +553,7 @@ impl<'tcx> NonConstOp<'tcx> for RawMutPtrDeref {
|
||||||
|
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
feature_err(
|
feature_err(
|
||||||
&ccx.tcx.sess.parse_sess,
|
&ccx.tcx.sess,
|
||||||
sym::const_mut_refs,
|
sym::const_mut_refs,
|
||||||
span,
|
span,
|
||||||
format!("dereferencing raw mutable pointers in {}s is unstable", ccx.const_kind(),),
|
format!("dereferencing raw mutable pointers in {}s is unstable", ccx.const_kind(),),
|
||||||
|
@ -624,7 +624,7 @@ pub mod ty {
|
||||||
|
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
feature_err(
|
feature_err(
|
||||||
&ccx.tcx.sess.parse_sess,
|
&ccx.tcx.sess,
|
||||||
sym::const_mut_refs,
|
sym::const_mut_refs,
|
||||||
span,
|
span,
|
||||||
format!("mutable references are not allowed in {}s", ccx.const_kind()),
|
format!("mutable references are not allowed in {}s", ccx.const_kind()),
|
||||||
|
|
|
@ -1150,7 +1150,7 @@ impl<'a> ExtCtxt<'a> {
|
||||||
///
|
///
|
||||||
/// This unifies the logic used for resolving `include_X!`.
|
/// This unifies the logic used for resolving `include_X!`.
|
||||||
pub fn resolve_path(
|
pub fn resolve_path(
|
||||||
parse_sess: &ParseSess,
|
parse_sess: &Session,
|
||||||
path: impl Into<PathBuf>,
|
path: impl Into<PathBuf>,
|
||||||
span: Span,
|
span: Span,
|
||||||
) -> PResult<'_, PathBuf> {
|
) -> PResult<'_, PathBuf> {
|
||||||
|
@ -1166,7 +1166,7 @@ pub fn resolve_path(
|
||||||
.expect("attempting to resolve a file path in an external file"),
|
.expect("attempting to resolve a file path in an external file"),
|
||||||
FileName::DocTest(path, _) => path,
|
FileName::DocTest(path, _) => path,
|
||||||
other => {
|
other => {
|
||||||
return Err(parse_sess.dcx.create_err(errors::ResolveRelativePath {
|
return Err(parse_sess.dcx().create_err(errors::ResolveRelativePath {
|
||||||
span,
|
span,
|
||||||
path: parse_sess.source_map().filename_for_diagnostics(&other).to_string(),
|
path: parse_sess.source_map().filename_for_diagnostics(&other).to_string(),
|
||||||
}));
|
}));
|
||||||
|
@ -1390,7 +1390,7 @@ pub fn parse_macro_name_and_helper_attrs(
|
||||||
/// asserts in old versions of those crates and their wide use in the ecosystem.
|
/// asserts in old versions of those crates and their wide use in the ecosystem.
|
||||||
/// See issue #73345 for more details.
|
/// See issue #73345 for more details.
|
||||||
/// FIXME(#73933): Remove this eventually.
|
/// FIXME(#73933): Remove this eventually.
|
||||||
fn pretty_printing_compatibility_hack(item: &Item, sess: &ParseSess) -> bool {
|
fn pretty_printing_compatibility_hack(item: &Item, sess: &Session) -> bool {
|
||||||
let name = item.ident.name;
|
let name = item.ident.name;
|
||||||
if name == sym::ProceduralMasqueradeDummyType {
|
if name == sym::ProceduralMasqueradeDummyType {
|
||||||
if let ast::ItemKind::Enum(enum_def, _) = &item.kind {
|
if let ast::ItemKind::Enum(enum_def, _) = &item.kind {
|
||||||
|
@ -1418,7 +1418,7 @@ fn pretty_printing_compatibility_hack(item: &Item, sess: &ParseSess) -> bool {
|
||||||
};
|
};
|
||||||
|
|
||||||
if crate_matches {
|
if crate_matches {
|
||||||
sess.buffer_lint_with_diagnostic(
|
sess.parse_sess.buffer_lint_with_diagnostic(
|
||||||
PROC_MACRO_BACK_COMPAT,
|
PROC_MACRO_BACK_COMPAT,
|
||||||
item.ident.span,
|
item.ident.span,
|
||||||
ast::CRATE_NODE_ID,
|
ast::CRATE_NODE_ID,
|
||||||
|
@ -1439,7 +1439,7 @@ fn pretty_printing_compatibility_hack(item: &Item, sess: &ParseSess) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn ann_pretty_printing_compatibility_hack(ann: &Annotatable, sess: &ParseSess) -> bool {
|
pub(crate) fn ann_pretty_printing_compatibility_hack(ann: &Annotatable, sess: &Session) -> bool {
|
||||||
let item = match ann {
|
let item = match ann {
|
||||||
Annotatable::Item(item) => item,
|
Annotatable::Item(item) => item,
|
||||||
Annotatable::Stmt(stmt) => match &stmt.kind {
|
Annotatable::Stmt(stmt) => match &stmt.kind {
|
||||||
|
@ -1451,7 +1451,7 @@ pub(crate) fn ann_pretty_printing_compatibility_hack(ann: &Annotatable, sess: &P
|
||||||
pretty_printing_compatibility_hack(item, sess)
|
pretty_printing_compatibility_hack(item, sess)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn nt_pretty_printing_compatibility_hack(nt: &Nonterminal, sess: &ParseSess) -> bool {
|
pub(crate) fn nt_pretty_printing_compatibility_hack(nt: &Nonterminal, sess: &Session) -> bool {
|
||||||
let item = match nt {
|
let item = match nt {
|
||||||
Nonterminal::NtItem(item) => item,
|
Nonterminal::NtItem(item) => item,
|
||||||
Nonterminal::NtStmt(stmt) => match &stmt.kind {
|
Nonterminal::NtStmt(stmt) => match &stmt.kind {
|
||||||
|
|
|
@ -256,12 +256,7 @@ impl<'a> StripUnconfigured<'a> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if !attr::cfg_matches(
|
if !attr::cfg_matches(&cfg_predicate, &self.sess, self.lint_node_id, self.features) {
|
||||||
&cfg_predicate,
|
|
||||||
&self.sess.parse_sess,
|
|
||||||
self.lint_node_id,
|
|
||||||
self.features,
|
|
||||||
) {
|
|
||||||
return vec![];
|
return vec![];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,12 +364,7 @@ impl<'a> StripUnconfigured<'a> {
|
||||||
};
|
};
|
||||||
(
|
(
|
||||||
parse_cfg(&meta_item, self.sess).map_or(true, |meta_item| {
|
parse_cfg(&meta_item, self.sess).map_or(true, |meta_item| {
|
||||||
attr::cfg_matches(
|
attr::cfg_matches(meta_item, &self.sess, self.lint_node_id, self.features)
|
||||||
meta_item,
|
|
||||||
&self.sess.parse_sess,
|
|
||||||
self.lint_node_id,
|
|
||||||
self.features,
|
|
||||||
)
|
|
||||||
}),
|
}),
|
||||||
Some(meta_item),
|
Some(meta_item),
|
||||||
)
|
)
|
||||||
|
@ -385,7 +375,7 @@ impl<'a> StripUnconfigured<'a> {
|
||||||
pub(crate) fn maybe_emit_expr_attr_err(&self, attr: &Attribute) {
|
pub(crate) fn maybe_emit_expr_attr_err(&self, attr: &Attribute) {
|
||||||
if self.features.is_some_and(|features| !features.stmt_expr_attributes) {
|
if self.features.is_some_and(|features| !features.stmt_expr_attributes) {
|
||||||
let mut err = feature_err(
|
let mut err = feature_err(
|
||||||
&self.sess.parse_sess,
|
&self.sess,
|
||||||
sym::stmt_expr_attributes,
|
sym::stmt_expr_attributes,
|
||||||
attr.span,
|
attr.span,
|
||||||
"attributes on expressions are experimental",
|
"attributes on expressions are experimental",
|
||||||
|
|
|
@ -30,8 +30,8 @@ use rustc_parse::parser::{
|
||||||
use rustc_parse::validate_attr;
|
use rustc_parse::validate_attr;
|
||||||
use rustc_session::lint::builtin::{UNUSED_ATTRIBUTES, UNUSED_DOC_COMMENTS};
|
use rustc_session::lint::builtin::{UNUSED_ATTRIBUTES, UNUSED_DOC_COMMENTS};
|
||||||
use rustc_session::lint::BuiltinLintDiagnostics;
|
use rustc_session::lint::BuiltinLintDiagnostics;
|
||||||
use rustc_session::parse::{feature_err, ParseSess};
|
use rustc_session::parse::feature_err;
|
||||||
use rustc_session::Limit;
|
use rustc_session::{Limit, Session};
|
||||||
use rustc_span::symbol::{sym, Ident};
|
use rustc_span::symbol::{sym, Ident};
|
||||||
use rustc_span::{FileName, LocalExpnId, Span};
|
use rustc_span::{FileName, LocalExpnId, Span};
|
||||||
|
|
||||||
|
@ -800,7 +800,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
feature_err(
|
feature_err(
|
||||||
&self.cx.sess.parse_sess,
|
&self.cx.sess,
|
||||||
sym::proc_macro_hygiene,
|
sym::proc_macro_hygiene,
|
||||||
span,
|
span,
|
||||||
format!("custom attributes cannot be applied to {kind}"),
|
format!("custom attributes cannot be applied to {kind}"),
|
||||||
|
@ -810,7 +810,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||||
|
|
||||||
fn gate_proc_macro_input(&self, annotatable: &Annotatable) {
|
fn gate_proc_macro_input(&self, annotatable: &Annotatable) {
|
||||||
struct GateProcMacroInput<'a> {
|
struct GateProcMacroInput<'a> {
|
||||||
parse_sess: &'a ParseSess,
|
sess: &'a Session,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ast, 'a> Visitor<'ast> for GateProcMacroInput<'a> {
|
impl<'ast, 'a> Visitor<'ast> for GateProcMacroInput<'a> {
|
||||||
|
@ -820,7 +820,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||||
if !matches!(mod_kind, ModKind::Loaded(_, Inline::Yes, _)) =>
|
if !matches!(mod_kind, ModKind::Loaded(_, Inline::Yes, _)) =>
|
||||||
{
|
{
|
||||||
feature_err(
|
feature_err(
|
||||||
self.parse_sess,
|
self.sess,
|
||||||
sym::proc_macro_hygiene,
|
sym::proc_macro_hygiene,
|
||||||
item.span,
|
item.span,
|
||||||
"non-inline modules in proc macro input are unstable",
|
"non-inline modules in proc macro input are unstable",
|
||||||
|
@ -835,8 +835,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !self.cx.ecfg.features.proc_macro_hygiene {
|
if !self.cx.ecfg.features.proc_macro_hygiene {
|
||||||
annotatable
|
annotatable.visit_with(&mut GateProcMacroInput { sess: &self.cx.sess });
|
||||||
.visit_with(&mut GateProcMacroInput { parse_sess: &self.cx.sess.parse_sess });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -477,14 +477,14 @@ pub fn compile_declarative_macro(
|
||||||
let tt = mbe::quoted::parse(
|
let tt = mbe::quoted::parse(
|
||||||
&TokenStream::new(vec![tt.clone()]),
|
&TokenStream::new(vec![tt.clone()]),
|
||||||
true,
|
true,
|
||||||
&sess.parse_sess,
|
sess,
|
||||||
def.id,
|
def.id,
|
||||||
features,
|
features,
|
||||||
edition,
|
edition,
|
||||||
)
|
)
|
||||||
.pop()
|
.pop()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
valid &= check_lhs_nt_follows(&sess.parse_sess, def, &tt);
|
valid &= check_lhs_nt_follows(sess, def, &tt);
|
||||||
return tt;
|
return tt;
|
||||||
}
|
}
|
||||||
sess.dcx().span_bug(def.span, "wrong-structured lhs")
|
sess.dcx().span_bug(def.span, "wrong-structured lhs")
|
||||||
|
@ -501,7 +501,7 @@ pub fn compile_declarative_macro(
|
||||||
return mbe::quoted::parse(
|
return mbe::quoted::parse(
|
||||||
&TokenStream::new(vec![tt.clone()]),
|
&TokenStream::new(vec![tt.clone()]),
|
||||||
false,
|
false,
|
||||||
&sess.parse_sess,
|
sess,
|
||||||
def.id,
|
def.id,
|
||||||
features,
|
features,
|
||||||
edition,
|
edition,
|
||||||
|
@ -516,12 +516,12 @@ pub fn compile_declarative_macro(
|
||||||
};
|
};
|
||||||
|
|
||||||
for rhs in &rhses {
|
for rhs in &rhses {
|
||||||
valid &= check_rhs(&sess.parse_sess, rhs);
|
valid &= check_rhs(sess, rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't abort iteration early, so that errors for multiple lhses can be reported
|
// don't abort iteration early, so that errors for multiple lhses can be reported
|
||||||
for lhs in &lhses {
|
for lhs in &lhses {
|
||||||
valid &= check_lhs_no_empty_seq(&sess.parse_sess, slice::from_ref(lhs));
|
valid &= check_lhs_no_empty_seq(sess, slice::from_ref(lhs));
|
||||||
}
|
}
|
||||||
|
|
||||||
valid &= macro_check::check_meta_variables(&sess.parse_sess, def.id, def.span, &lhses, &rhses);
|
valid &= macro_check::check_meta_variables(&sess.parse_sess, def.id, def.span, &lhses, &rhses);
|
||||||
|
@ -588,21 +588,21 @@ pub fn compile_declarative_macro(
|
||||||
(mk_syn_ext(expander), rule_spans)
|
(mk_syn_ext(expander), rule_spans)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_lhs_nt_follows(sess: &ParseSess, def: &ast::Item, lhs: &mbe::TokenTree) -> bool {
|
fn check_lhs_nt_follows(sess: &Session, def: &ast::Item, lhs: &mbe::TokenTree) -> bool {
|
||||||
// lhs is going to be like TokenTree::Delimited(...), where the
|
// lhs is going to be like TokenTree::Delimited(...), where the
|
||||||
// entire lhs is those tts. Or, it can be a "bare sequence", not wrapped in parens.
|
// entire lhs is those tts. Or, it can be a "bare sequence", not wrapped in parens.
|
||||||
if let mbe::TokenTree::Delimited(.., delimited) = lhs {
|
if let mbe::TokenTree::Delimited(.., delimited) = lhs {
|
||||||
check_matcher(sess, def, &delimited.tts)
|
check_matcher(sess, def, &delimited.tts)
|
||||||
} else {
|
} else {
|
||||||
let msg = "invalid macro matcher; matchers must be contained in balanced delimiters";
|
let msg = "invalid macro matcher; matchers must be contained in balanced delimiters";
|
||||||
sess.dcx.span_err(lhs.span(), msg);
|
sess.dcx().span_err(lhs.span(), msg);
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
// we don't abort on errors on rejection, the driver will do that for us
|
// we don't abort on errors on rejection, the driver will do that for us
|
||||||
// after parsing/expansion. we can report every error in every macro this way.
|
// after parsing/expansion. we can report every error in every macro this way.
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_empty_token_tree(sess: &ParseSess, seq: &mbe::SequenceRepetition) -> bool {
|
fn is_empty_token_tree(sess: &Session, seq: &mbe::SequenceRepetition) -> bool {
|
||||||
if seq.separator.is_some() {
|
if seq.separator.is_some() {
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
|
@ -621,7 +621,7 @@ fn is_empty_token_tree(sess: &ParseSess, seq: &mbe::SequenceRepetition) -> bool
|
||||||
iter.next();
|
iter.next();
|
||||||
}
|
}
|
||||||
let span = t.span.to(now.span);
|
let span = t.span.to(now.span);
|
||||||
sess.dcx.span_note(span, "doc comments are ignored in matcher position");
|
sess.dcx().span_note(span, "doc comments are ignored in matcher position");
|
||||||
}
|
}
|
||||||
mbe::TokenTree::Sequence(_, sub_seq)
|
mbe::TokenTree::Sequence(_, sub_seq)
|
||||||
if (sub_seq.kleene.op == mbe::KleeneOp::ZeroOrMore
|
if (sub_seq.kleene.op == mbe::KleeneOp::ZeroOrMore
|
||||||
|
@ -635,7 +635,7 @@ fn is_empty_token_tree(sess: &ParseSess, seq: &mbe::SequenceRepetition) -> bool
|
||||||
|
|
||||||
/// Checks that the lhs contains no repetition which could match an empty token
|
/// Checks that the lhs contains no repetition which could match an empty token
|
||||||
/// tree, because then the matcher would hang indefinitely.
|
/// tree, because then the matcher would hang indefinitely.
|
||||||
fn check_lhs_no_empty_seq(sess: &ParseSess, tts: &[mbe::TokenTree]) -> bool {
|
fn check_lhs_no_empty_seq(sess: &Session, tts: &[mbe::TokenTree]) -> bool {
|
||||||
use mbe::TokenTree;
|
use mbe::TokenTree;
|
||||||
for tt in tts {
|
for tt in tts {
|
||||||
match tt {
|
match tt {
|
||||||
|
@ -651,7 +651,7 @@ fn check_lhs_no_empty_seq(sess: &ParseSess, tts: &[mbe::TokenTree]) -> bool {
|
||||||
TokenTree::Sequence(span, seq) => {
|
TokenTree::Sequence(span, seq) => {
|
||||||
if is_empty_token_tree(sess, seq) {
|
if is_empty_token_tree(sess, seq) {
|
||||||
let sp = span.entire();
|
let sp = span.entire();
|
||||||
sess.dcx.span_err(sp, "repetition matches empty token tree");
|
sess.dcx().span_err(sp, "repetition matches empty token tree");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if !check_lhs_no_empty_seq(sess, &seq.tts) {
|
if !check_lhs_no_empty_seq(sess, &seq.tts) {
|
||||||
|
@ -664,22 +664,22 @@ fn check_lhs_no_empty_seq(sess: &ParseSess, tts: &[mbe::TokenTree]) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_rhs(sess: &ParseSess, rhs: &mbe::TokenTree) -> bool {
|
fn check_rhs(sess: &Session, rhs: &mbe::TokenTree) -> bool {
|
||||||
match *rhs {
|
match *rhs {
|
||||||
mbe::TokenTree::Delimited(..) => return true,
|
mbe::TokenTree::Delimited(..) => return true,
|
||||||
_ => {
|
_ => {
|
||||||
sess.dcx.span_err(rhs.span(), "macro rhs must be delimited");
|
sess.dcx().span_err(rhs.span(), "macro rhs must be delimited");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_matcher(sess: &ParseSess, def: &ast::Item, matcher: &[mbe::TokenTree]) -> bool {
|
fn check_matcher(sess: &Session, def: &ast::Item, matcher: &[mbe::TokenTree]) -> bool {
|
||||||
let first_sets = FirstSets::new(matcher);
|
let first_sets = FirstSets::new(matcher);
|
||||||
let empty_suffix = TokenSet::empty();
|
let empty_suffix = TokenSet::empty();
|
||||||
let err = sess.dcx.err_count();
|
let err = sess.dcx().err_count();
|
||||||
check_matcher_core(sess, def, &first_sets, matcher, &empty_suffix);
|
check_matcher_core(sess, def, &first_sets, matcher, &empty_suffix);
|
||||||
err == sess.dcx.err_count()
|
err == sess.dcx().err_count()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_compile_error_macro(rhs: &mbe::TokenTree) -> bool {
|
fn has_compile_error_macro(rhs: &mbe::TokenTree) -> bool {
|
||||||
|
@ -1014,7 +1014,7 @@ impl<'tt> TokenSet<'tt> {
|
||||||
// Requires that `first_sets` is pre-computed for `matcher`;
|
// Requires that `first_sets` is pre-computed for `matcher`;
|
||||||
// see `FirstSets::new`.
|
// see `FirstSets::new`.
|
||||||
fn check_matcher_core<'tt>(
|
fn check_matcher_core<'tt>(
|
||||||
sess: &ParseSess,
|
sess: &Session,
|
||||||
def: &ast::Item,
|
def: &ast::Item,
|
||||||
first_sets: &FirstSets<'tt>,
|
first_sets: &FirstSets<'tt>,
|
||||||
matcher: &'tt [mbe::TokenTree],
|
matcher: &'tt [mbe::TokenTree],
|
||||||
|
@ -1139,7 +1139,7 @@ fn check_matcher_core<'tt>(
|
||||||
name,
|
name,
|
||||||
Some(NonterminalKind::PatParam { inferred: false }),
|
Some(NonterminalKind::PatParam { inferred: false }),
|
||||||
));
|
));
|
||||||
sess.buffer_lint_with_diagnostic(
|
sess.parse_sess.buffer_lint_with_diagnostic(
|
||||||
RUST_2021_INCOMPATIBLE_OR_PATTERNS,
|
RUST_2021_INCOMPATIBLE_OR_PATTERNS,
|
||||||
span,
|
span,
|
||||||
ast::CRATE_NODE_ID,
|
ast::CRATE_NODE_ID,
|
||||||
|
@ -1158,7 +1158,7 @@ fn check_matcher_core<'tt>(
|
||||||
};
|
};
|
||||||
|
|
||||||
let sp = next_token.span();
|
let sp = next_token.span();
|
||||||
let mut err = sess.dcx.struct_span_err(
|
let mut err = sess.dcx().struct_span_err(
|
||||||
sp,
|
sp,
|
||||||
format!(
|
format!(
|
||||||
"`${name}:{frag}` {may_be} followed by `{next}`, which \
|
"`${name}:{frag}` {may_be} followed by `{next}`, which \
|
||||||
|
@ -1172,7 +1172,7 @@ fn check_matcher_core<'tt>(
|
||||||
err.span_label(sp, format!("not allowed after `{kind}` fragments"));
|
err.span_label(sp, format!("not allowed after `{kind}` fragments"));
|
||||||
|
|
||||||
if kind == NonterminalKind::PatWithOr
|
if kind == NonterminalKind::PatWithOr
|
||||||
&& sess.edition.at_least_rust_2021()
|
&& sess.parse_sess.edition.at_least_rust_2021()
|
||||||
&& next_token.is_token(&BinOp(token::BinOpToken::Or))
|
&& next_token.is_token(&BinOp(token::BinOpToken::Or))
|
||||||
{
|
{
|
||||||
let suggestion = quoted_tt_to_string(&TokenTree::MetaVarDecl(
|
let suggestion = quoted_tt_to_string(&TokenTree::MetaVarDecl(
|
||||||
|
|
|
@ -5,7 +5,8 @@ use rustc_ast::token::{self, Delimiter, Token};
|
||||||
use rustc_ast::{tokenstream, NodeId};
|
use rustc_ast::{tokenstream, NodeId};
|
||||||
use rustc_ast_pretty::pprust;
|
use rustc_ast_pretty::pprust;
|
||||||
use rustc_feature::Features;
|
use rustc_feature::Features;
|
||||||
use rustc_session::parse::{feature_err, ParseSess};
|
use rustc_session::parse::feature_err;
|
||||||
|
use rustc_session::Session;
|
||||||
use rustc_span::symbol::{kw, sym, Ident};
|
use rustc_span::symbol::{kw, sym, Ident};
|
||||||
|
|
||||||
use rustc_span::edition::Edition;
|
use rustc_span::edition::Edition;
|
||||||
|
@ -38,7 +39,7 @@ const VALID_FRAGMENT_NAMES_MSG: &str = "valid fragment specifiers are \
|
||||||
pub(super) fn parse(
|
pub(super) fn parse(
|
||||||
input: &tokenstream::TokenStream,
|
input: &tokenstream::TokenStream,
|
||||||
parsing_patterns: bool,
|
parsing_patterns: bool,
|
||||||
sess: &ParseSess,
|
sess: &Session,
|
||||||
node_id: NodeId,
|
node_id: NodeId,
|
||||||
features: &Features,
|
features: &Features,
|
||||||
edition: Edition,
|
edition: Edition,
|
||||||
|
@ -84,7 +85,7 @@ pub(super) fn parse(
|
||||||
"invalid fragment specifier `{}`",
|
"invalid fragment specifier `{}`",
|
||||||
frag.name
|
frag.name
|
||||||
);
|
);
|
||||||
sess.dcx
|
sess.dcx()
|
||||||
.struct_span_err(span, msg)
|
.struct_span_err(span, msg)
|
||||||
.with_help(VALID_FRAGMENT_NAMES_MSG)
|
.with_help(VALID_FRAGMENT_NAMES_MSG)
|
||||||
.emit();
|
.emit();
|
||||||
|
@ -113,7 +114,7 @@ pub(super) fn parse(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Asks for the `macro_metavar_expr` feature if it is not already declared
|
/// Asks for the `macro_metavar_expr` feature if it is not already declared
|
||||||
fn maybe_emit_macro_metavar_expr_feature(features: &Features, sess: &ParseSess, span: Span) {
|
fn maybe_emit_macro_metavar_expr_feature(features: &Features, sess: &Session, span: Span) {
|
||||||
if !features.macro_metavar_expr {
|
if !features.macro_metavar_expr {
|
||||||
let msg = "meta-variable expressions are unstable";
|
let msg = "meta-variable expressions are unstable";
|
||||||
feature_err(sess, sym::macro_metavar_expr, span, msg).emit();
|
feature_err(sess, sym::macro_metavar_expr, span, msg).emit();
|
||||||
|
@ -138,7 +139,7 @@ fn parse_tree<'a>(
|
||||||
tree: &'a tokenstream::TokenTree,
|
tree: &'a tokenstream::TokenTree,
|
||||||
outer_trees: &mut impl Iterator<Item = &'a tokenstream::TokenTree>,
|
outer_trees: &mut impl Iterator<Item = &'a tokenstream::TokenTree>,
|
||||||
parsing_patterns: bool,
|
parsing_patterns: bool,
|
||||||
sess: &ParseSess,
|
sess: &Session,
|
||||||
node_id: NodeId,
|
node_id: NodeId,
|
||||||
features: &Features,
|
features: &Features,
|
||||||
edition: Edition,
|
edition: Edition,
|
||||||
|
@ -174,7 +175,8 @@ fn parse_tree<'a>(
|
||||||
// The delimiter is `{`. This indicates the beginning
|
// The delimiter is `{`. This indicates the beginning
|
||||||
// of a meta-variable expression (e.g. `${count(ident)}`).
|
// of a meta-variable expression (e.g. `${count(ident)}`).
|
||||||
// Try to parse the meta-variable expression.
|
// Try to parse the meta-variable expression.
|
||||||
match MetaVarExpr::parse(tts, delim_span.entire(), sess) {
|
match MetaVarExpr::parse(tts, delim_span.entire(), &sess.parse_sess)
|
||||||
|
{
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.emit();
|
err.emit();
|
||||||
// Returns early the same read `$` to avoid spanning
|
// Returns early the same read `$` to avoid spanning
|
||||||
|
@ -195,7 +197,7 @@ fn parse_tree<'a>(
|
||||||
_ => {
|
_ => {
|
||||||
let tok = pprust::token_kind_to_string(&token::OpenDelim(delim));
|
let tok = pprust::token_kind_to_string(&token::OpenDelim(delim));
|
||||||
let msg = format!("expected `(` or `{{`, found `{tok}`");
|
let msg = format!("expected `(` or `{{`, found `{tok}`");
|
||||||
sess.dcx.span_err(delim_span.entire(), msg);
|
sess.dcx().span_err(delim_span.entire(), msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,7 +246,7 @@ fn parse_tree<'a>(
|
||||||
Some(tokenstream::TokenTree::Token(token, _)) => {
|
Some(tokenstream::TokenTree::Token(token, _)) => {
|
||||||
let msg =
|
let msg =
|
||||||
format!("expected identifier, found `{}`", pprust::token_to_string(token),);
|
format!("expected identifier, found `{}`", pprust::token_to_string(token),);
|
||||||
sess.dcx.span_err(token.span, msg);
|
sess.dcx().span_err(token.span, msg);
|
||||||
TokenTree::MetaVar(token.span, Ident::empty())
|
TokenTree::MetaVar(token.span, Ident::empty())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +315,7 @@ fn parse_kleene_op<'a>(
|
||||||
fn parse_sep_and_kleene_op<'a>(
|
fn parse_sep_and_kleene_op<'a>(
|
||||||
input: &mut impl Iterator<Item = &'a tokenstream::TokenTree>,
|
input: &mut impl Iterator<Item = &'a tokenstream::TokenTree>,
|
||||||
span: Span,
|
span: Span,
|
||||||
sess: &ParseSess,
|
sess: &Session,
|
||||||
) -> (Option<Token>, KleeneToken) {
|
) -> (Option<Token>, KleeneToken) {
|
||||||
// We basically look at two token trees here, denoted as #1 and #2 below
|
// We basically look at two token trees here, denoted as #1 and #2 below
|
||||||
let span = match parse_kleene_op(input, span) {
|
let span = match parse_kleene_op(input, span) {
|
||||||
|
@ -325,7 +327,7 @@ fn parse_sep_and_kleene_op<'a>(
|
||||||
// #2 is the `?` Kleene op, which does not take a separator (error)
|
// #2 is the `?` Kleene op, which does not take a separator (error)
|
||||||
Ok(Ok((KleeneOp::ZeroOrOne, span))) => {
|
Ok(Ok((KleeneOp::ZeroOrOne, span))) => {
|
||||||
// Error!
|
// Error!
|
||||||
sess.dcx.span_err(
|
sess.dcx().span_err(
|
||||||
token.span,
|
token.span,
|
||||||
"the `?` macro repetition operator does not take a separator",
|
"the `?` macro repetition operator does not take a separator",
|
||||||
);
|
);
|
||||||
|
@ -346,7 +348,7 @@ fn parse_sep_and_kleene_op<'a>(
|
||||||
};
|
};
|
||||||
|
|
||||||
// If we ever get to this point, we have experienced an "unexpected token" error
|
// If we ever get to this point, we have experienced an "unexpected token" error
|
||||||
sess.dcx.span_err(span, "expected one of: `*`, `+`, or `?`");
|
sess.dcx().span_err(span, "expected one of: `*`, `+`, or `?`");
|
||||||
|
|
||||||
// Return a dummy
|
// Return a dummy
|
||||||
(None, KleeneToken::new(KleeneOp::ZeroOrMore, span))
|
(None, KleeneToken::new(KleeneOp::ZeroOrMore, span))
|
||||||
|
@ -355,9 +357,10 @@ fn parse_sep_and_kleene_op<'a>(
|
||||||
// `$$` or a meta-variable is the lhs of a macro but shouldn't.
|
// `$$` or a meta-variable is the lhs of a macro but shouldn't.
|
||||||
//
|
//
|
||||||
// For example, `macro_rules! foo { ( ${length()} ) => {} }`
|
// For example, `macro_rules! foo { ( ${length()} ) => {} }`
|
||||||
fn span_dollar_dollar_or_metavar_in_the_lhs_err(sess: &ParseSess, token: &Token) {
|
fn span_dollar_dollar_or_metavar_in_the_lhs_err(sess: &Session, token: &Token) {
|
||||||
sess.dcx.span_err(token.span, format!("unexpected token: {}", pprust::token_to_string(token)));
|
sess.dcx()
|
||||||
sess.dcx.span_note(
|
.span_err(token.span, format!("unexpected token: {}", pprust::token_to_string(token)));
|
||||||
|
sess.dcx().span_note(
|
||||||
token.span,
|
token.span,
|
||||||
"`$$` and meta-variable expressions are not allowed inside macro parameter definitions",
|
"`$$` and meta-variable expressions are not allowed inside macro parameter definitions",
|
||||||
);
|
);
|
||||||
|
|
|
@ -119,7 +119,7 @@ impl MultiItemModifier for DeriveProcMacro {
|
||||||
// We need special handling for statement items
|
// We need special handling for statement items
|
||||||
// (e.g. `fn foo() { #[derive(Debug)] struct Bar; }`)
|
// (e.g. `fn foo() { #[derive(Debug)] struct Bar; }`)
|
||||||
let is_stmt = matches!(item, Annotatable::Stmt(..));
|
let is_stmt = matches!(item, Annotatable::Stmt(..));
|
||||||
let hack = crate::base::ann_pretty_printing_compatibility_hack(&item, &ecx.sess.parse_sess);
|
let hack = crate::base::ann_pretty_printing_compatibility_hack(&item, &ecx.sess);
|
||||||
let input = if hack {
|
let input = if hack {
|
||||||
let nt = match item {
|
let nt = match item {
|
||||||
Annotatable::Item(item) => token::NtItem(item),
|
Annotatable::Item(item) => token::NtItem(item),
|
||||||
|
|
|
@ -258,7 +258,7 @@ impl FromInternal<(TokenStream, &mut Rustc<'_, '_>)> for Vec<TokenTree<TokenStre
|
||||||
// represented as a delimited group.
|
// represented as a delimited group.
|
||||||
// FIXME: It needs to be removed, but there are some
|
// FIXME: It needs to be removed, but there are some
|
||||||
// compatibility issues (see #73345).
|
// compatibility issues (see #73345).
|
||||||
if crate::base::nt_pretty_printing_compatibility_hack(&nt.0, rustc.sess()) {
|
if crate::base::nt_pretty_printing_compatibility_hack(&nt.0, rustc.ecx.sess) {
|
||||||
trees.extend(Self::from_internal((stream, rustc)));
|
trees.extend(Self::from_internal((stream, rustc)));
|
||||||
} else {
|
} else {
|
||||||
trees.push(TokenTree::Group(Group {
|
trees.push(TokenTree::Group(Group {
|
||||||
|
|
|
@ -59,7 +59,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
if trait_segment.args().parenthesized == hir::GenericArgsParentheses::ParenSugar {
|
if trait_segment.args().parenthesized == hir::GenericArgsParentheses::ParenSugar {
|
||||||
// For now, require that parenthetical notation be used only with `Fn()` etc.
|
// For now, require that parenthetical notation be used only with `Fn()` etc.
|
||||||
feature_err(
|
feature_err(
|
||||||
&self.tcx().sess.parse_sess,
|
&self.tcx().sess,
|
||||||
sym::unboxed_closures,
|
sym::unboxed_closures,
|
||||||
span,
|
span,
|
||||||
"parenthetical notation is only stable when used with `Fn`-family traits",
|
"parenthetical notation is only stable when used with `Fn`-family traits",
|
||||||
|
@ -75,7 +75,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
if trait_segment.args().parenthesized != hir::GenericArgsParentheses::ParenSugar {
|
if trait_segment.args().parenthesized != hir::GenericArgsParentheses::ParenSugar {
|
||||||
// For now, require that parenthetical notation be used only with `Fn()` etc.
|
// For now, require that parenthetical notation be used only with `Fn()` etc.
|
||||||
let mut err = feature_err(
|
let mut err = feature_err(
|
||||||
&sess.parse_sess,
|
sess,
|
||||||
sym::unboxed_closures,
|
sym::unboxed_closures,
|
||||||
span,
|
span,
|
||||||
"the precise format of `Fn`-family traits' type parameters is subject to change",
|
"the precise format of `Fn`-family traits' type parameters is subject to change",
|
||||||
|
|
|
@ -996,7 +996,7 @@ pub(super) fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>)
|
||||||
|
|
||||||
if adt.is_union() && !tcx.features().transparent_unions {
|
if adt.is_union() && !tcx.features().transparent_unions {
|
||||||
feature_err(
|
feature_err(
|
||||||
&tcx.sess.parse_sess,
|
&tcx.sess,
|
||||||
sym::transparent_unions,
|
sym::transparent_unions,
|
||||||
tcx.def_span(adt.did()),
|
tcx.def_span(adt.did()),
|
||||||
"transparent unions are unstable",
|
"transparent unions are unstable",
|
||||||
|
@ -1128,7 +1128,7 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||||
if repr_type_ty == tcx.types.i128 || repr_type_ty == tcx.types.u128 {
|
if repr_type_ty == tcx.types.i128 || repr_type_ty == tcx.types.u128 {
|
||||||
if !tcx.features().repr128 {
|
if !tcx.features().repr128 {
|
||||||
feature_err(
|
feature_err(
|
||||||
&tcx.sess.parse_sess,
|
&tcx.sess,
|
||||||
sym::repr128,
|
sym::repr128,
|
||||||
tcx.def_span(def_id),
|
tcx.def_span(def_id),
|
||||||
"repr with 128-bit type is unstable",
|
"repr with 128-bit type is unstable",
|
||||||
|
|
|
@ -293,7 +293,7 @@ fn default_body_is_unstable(
|
||||||
|
|
||||||
rustc_session::parse::add_feature_diagnostics_for_issue(
|
rustc_session::parse::add_feature_diagnostics_for_issue(
|
||||||
&mut err,
|
&mut err,
|
||||||
&tcx.sess.parse_sess,
|
&tcx.sess,
|
||||||
feature,
|
feature,
|
||||||
rustc_feature::GateIssue::Library(issue),
|
rustc_feature::GateIssue::Library(issue),
|
||||||
false,
|
false,
|
||||||
|
|
|
@ -1591,7 +1591,7 @@ fn check_method_receiver<'tcx>(
|
||||||
return Err(if receiver_is_valid(wfcx, span, receiver_ty, self_ty, true) {
|
return Err(if receiver_is_valid(wfcx, span, receiver_ty, self_ty, true) {
|
||||||
// Report error; would have worked with `arbitrary_self_types`.
|
// Report error; would have worked with `arbitrary_self_types`.
|
||||||
feature_err(
|
feature_err(
|
||||||
&tcx.sess.parse_sess,
|
&tcx.sess,
|
||||||
sym::arbitrary_self_types,
|
sym::arbitrary_self_types,
|
||||||
span,
|
span,
|
||||||
format!(
|
format!(
|
||||||
|
|
|
@ -1189,8 +1189,9 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
||||||
&& !self.tcx.asyncness(lifetime_ref.hir_id.owner.def_id).is_async()
|
&& !self.tcx.asyncness(lifetime_ref.hir_id.owner.def_id).is_async()
|
||||||
&& !self.tcx.features().anonymous_lifetime_in_impl_trait
|
&& !self.tcx.features().anonymous_lifetime_in_impl_trait
|
||||||
{
|
{
|
||||||
let mut diag = rustc_session::parse::feature_err(
|
let mut diag: rustc_errors::DiagnosticBuilder<'_> =
|
||||||
&self.tcx.sess.parse_sess,
|
rustc_session::parse::feature_err(
|
||||||
|
&self.tcx.sess,
|
||||||
sym::anonymous_lifetime_in_impl_trait,
|
sym::anonymous_lifetime_in_impl_trait,
|
||||||
lifetime_ref.ident.span,
|
lifetime_ref.ident.span,
|
||||||
"anonymous lifetimes in `impl Trait` are unstable",
|
"anonymous lifetimes in `impl Trait` are unstable",
|
||||||
|
|
|
@ -639,7 +639,7 @@ fn check_feature_inherent_assoc_ty(tcx: TyCtxt<'_>, span: Span) {
|
||||||
use rustc_session::parse::feature_err;
|
use rustc_session::parse::feature_err;
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
feature_err(
|
feature_err(
|
||||||
&tcx.sess.parse_sess,
|
&tcx.sess,
|
||||||
sym::inherent_associated_types,
|
sym::inherent_associated_types,
|
||||||
span,
|
span,
|
||||||
"inherent associated types are unstable",
|
"inherent associated types are unstable",
|
||||||
|
|
|
@ -133,12 +133,7 @@ fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_>, decl: &hir::FnDecl<'_>, abi: Abi
|
||||||
// Using this ABI would be ok, if the feature for additional ABI support was enabled.
|
// Using this ABI would be ok, if the feature for additional ABI support was enabled.
|
||||||
// Return CONVENTIONS_STABLE, because we want the other error to look the same.
|
// Return CONVENTIONS_STABLE, because we want the other error to look the same.
|
||||||
(false, true) => {
|
(false, true) => {
|
||||||
feature_err(
|
feature_err(&tcx.sess, sym::extended_varargs_abi_support, span, UNSTABLE_EXPLAIN)
|
||||||
&tcx.sess.parse_sess,
|
|
||||||
sym::extended_varargs_abi_support,
|
|
||||||
span,
|
|
||||||
UNSTABLE_EXPLAIN,
|
|
||||||
)
|
|
||||||
.emit();
|
.emit();
|
||||||
CONVENTIONS_STABLE
|
CONVENTIONS_STABLE
|
||||||
}
|
}
|
||||||
|
|
|
@ -704,7 +704,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
||||||
|
|
||||||
if has_unsized_tuple_coercion && !self.tcx.features().unsized_tuple_coercion {
|
if has_unsized_tuple_coercion && !self.tcx.features().unsized_tuple_coercion {
|
||||||
feature_err(
|
feature_err(
|
||||||
&self.tcx.sess.parse_sess,
|
&self.tcx.sess,
|
||||||
sym::unsized_tuple_coercion,
|
sym::unsized_tuple_coercion,
|
||||||
self.cause.span,
|
self.cause.span,
|
||||||
"unsized tuple coercion is not stable enough for use and is subject to change",
|
"unsized tuple coercion is not stable enough for use and is subject to change",
|
||||||
|
|
|
@ -1865,7 +1865,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
(ty::Adt(adt, _), ty::Adt(base_adt, _)) if adt == base_adt);
|
(ty::Adt(adt, _), ty::Adt(base_adt, _)) if adt == base_adt);
|
||||||
if self.tcx.sess.is_nightly_build() && same_adt {
|
if self.tcx.sess.is_nightly_build() && same_adt {
|
||||||
feature_err(
|
feature_err(
|
||||||
&self.tcx.sess.parse_sess,
|
&self.tcx.sess,
|
||||||
sym::type_changing_struct_update,
|
sym::type_changing_struct_update,
|
||||||
base_expr.span,
|
base_expr.span,
|
||||||
"type changing struct updating is experimental",
|
"type changing struct updating is experimental",
|
||||||
|
@ -3262,7 +3262,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
if !self.tcx.features().offset_of_enum {
|
if !self.tcx.features().offset_of_enum {
|
||||||
rustc_session::parse::feature_err(
|
rustc_session::parse::feature_err(
|
||||||
&self.tcx.sess.parse_sess,
|
&self.tcx.sess,
|
||||||
sym::offset_of_enum,
|
sym::offset_of_enum,
|
||||||
ident.span,
|
ident.span,
|
||||||
"using enums in offset_of is experimental",
|
"using enums in offset_of is experimental",
|
||||||
|
|
|
@ -1306,10 +1306,7 @@ impl<'tcx> LateLintPass<'tcx> for UngatedAsyncFnTrackCaller {
|
||||||
cx.emit_spanned_lint(
|
cx.emit_spanned_lint(
|
||||||
UNGATED_ASYNC_FN_TRACK_CALLER,
|
UNGATED_ASYNC_FN_TRACK_CALLER,
|
||||||
attr.span,
|
attr.span,
|
||||||
BuiltinUngatedAsyncFnTrackCaller {
|
BuiltinUngatedAsyncFnTrackCaller { label: span, session: &cx.tcx.sess },
|
||||||
label: span,
|
|
||||||
parse_sess: &cx.tcx.sess.parse_sess,
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -786,7 +786,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||||
if let ast::LitKind::Str(rationale, _) = name_value.kind {
|
if let ast::LitKind::Str(rationale, _) = name_value.kind {
|
||||||
if !self.features.lint_reasons {
|
if !self.features.lint_reasons {
|
||||||
feature_err(
|
feature_err(
|
||||||
&self.sess.parse_sess,
|
&self.sess,
|
||||||
sym::lint_reasons,
|
sym::lint_reasons,
|
||||||
item.span,
|
item.span,
|
||||||
"lint reasons are experimental",
|
"lint reasons are experimental",
|
||||||
|
@ -1074,7 +1074,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||||
lint.note(fluent::lint_note);
|
lint.note(fluent::lint_note);
|
||||||
rustc_session::parse::add_feature_diagnostics_for_issue(
|
rustc_session::parse::add_feature_diagnostics_for_issue(
|
||||||
lint,
|
lint,
|
||||||
&self.sess.parse_sess,
|
&self.sess,
|
||||||
feature,
|
feature,
|
||||||
GateIssue::Language,
|
GateIssue::Language,
|
||||||
lint_from_cli,
|
lint_from_cli,
|
||||||
|
|
|
@ -13,7 +13,7 @@ use rustc_macros::{LintDiagnostic, Subdiagnostic};
|
||||||
use rustc_middle::ty::{
|
use rustc_middle::ty::{
|
||||||
inhabitedness::InhabitedPredicate, Clause, PolyExistentialTraitRef, Ty, TyCtxt,
|
inhabitedness::InhabitedPredicate, Clause, PolyExistentialTraitRef, Ty, TyCtxt,
|
||||||
};
|
};
|
||||||
use rustc_session::parse::ParseSess;
|
use rustc_session::Session;
|
||||||
use rustc_span::{edition::Edition, sym, symbol::Ident, Span, Symbol};
|
use rustc_span::{edition::Edition, sym, symbol::Ident, Span, Symbol};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -235,7 +235,7 @@ pub struct BuiltinUnstableFeatures;
|
||||||
// lint_ungated_async_fn_track_caller
|
// lint_ungated_async_fn_track_caller
|
||||||
pub struct BuiltinUngatedAsyncFnTrackCaller<'a> {
|
pub struct BuiltinUngatedAsyncFnTrackCaller<'a> {
|
||||||
pub label: Span,
|
pub label: Span,
|
||||||
pub parse_sess: &'a ParseSess,
|
pub session: &'a Session,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DecorateLint<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> {
|
impl<'a> DecorateLint<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> {
|
||||||
|
@ -243,7 +243,7 @@ impl<'a> DecorateLint<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> {
|
||||||
diag.span_label(self.label, fluent::lint_label);
|
diag.span_label(self.label, fluent::lint_label);
|
||||||
rustc_session::parse::add_feature_diagnostics(
|
rustc_session::parse::add_feature_diagnostics(
|
||||||
diag,
|
diag,
|
||||||
self.parse_sess,
|
self.session,
|
||||||
sym::async_fn_track_caller,
|
sym::async_fn_track_caller,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ pub(crate) fn collect(tcx: TyCtxt<'_>, LocalCrate: LocalCrate) -> Vec<NativeLib>
|
||||||
|
|
||||||
pub(crate) fn relevant_lib(sess: &Session, lib: &NativeLib) -> bool {
|
pub(crate) fn relevant_lib(sess: &Session, lib: &NativeLib) -> bool {
|
||||||
match lib.cfg {
|
match lib.cfg {
|
||||||
Some(ref cfg) => attr::cfg_matches(cfg, &sess.parse_sess, CRATE_NODE_ID, None),
|
Some(ref cfg) => attr::cfg_matches(cfg, sess, CRATE_NODE_ID, None),
|
||||||
None => true,
|
None => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ impl<'tcx> Collector<'tcx> {
|
||||||
"link-arg" => {
|
"link-arg" => {
|
||||||
if !features.link_arg_attribute {
|
if !features.link_arg_attribute {
|
||||||
feature_err(
|
feature_err(
|
||||||
&sess.parse_sess,
|
sess,
|
||||||
sym::link_arg_attribute,
|
sym::link_arg_attribute,
|
||||||
span,
|
span,
|
||||||
"link kind `link-arg` is unstable",
|
"link kind `link-arg` is unstable",
|
||||||
|
@ -206,12 +206,7 @@ impl<'tcx> Collector<'tcx> {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
if !features.link_cfg {
|
if !features.link_cfg {
|
||||||
feature_err(
|
feature_err(sess, sym::link_cfg, item.span(), "link cfg is unstable")
|
||||||
&sess.parse_sess,
|
|
||||||
sym::link_cfg,
|
|
||||||
item.span(),
|
|
||||||
"link cfg is unstable",
|
|
||||||
)
|
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
cfg = Some(link_cfg.clone());
|
cfg = Some(link_cfg.clone());
|
||||||
|
@ -277,7 +272,7 @@ impl<'tcx> Collector<'tcx> {
|
||||||
macro report_unstable_modifier($feature: ident) {
|
macro report_unstable_modifier($feature: ident) {
|
||||||
if !features.$feature {
|
if !features.$feature {
|
||||||
feature_err(
|
feature_err(
|
||||||
&sess.parse_sess,
|
sess,
|
||||||
sym::$feature,
|
sym::$feature,
|
||||||
span,
|
span,
|
||||||
format!("linking modifier `{modifier}` is unstable"),
|
format!("linking modifier `{modifier}` is unstable"),
|
||||||
|
|
|
@ -116,8 +116,7 @@ pub fn report_unstable(
|
||||||
if is_soft {
|
if is_soft {
|
||||||
soft_handler(SOFT_UNSTABLE, span, msg)
|
soft_handler(SOFT_UNSTABLE, span, msg)
|
||||||
} else {
|
} else {
|
||||||
let mut err =
|
let mut err = feature_err_issue(sess, feature, span, GateIssue::Library(issue), msg);
|
||||||
feature_err_issue(&sess.parse_sess, feature, span, GateIssue::Library(issue), msg);
|
|
||||||
if let Some((inner_types, msg, sugg, applicability)) = suggestion {
|
if let Some((inner_types, msg, sugg, applicability)) = suggestion {
|
||||||
err.span_suggestion(inner_types, msg, sugg, applicability);
|
err.span_suggestion(inner_types, msg, sugg, applicability);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1170,7 +1170,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
||||||
sym::rust_logo => {
|
sym::rust_logo => {
|
||||||
if !self.tcx.features().rustdoc_internals {
|
if !self.tcx.features().rustdoc_internals {
|
||||||
feature_err(
|
feature_err(
|
||||||
&self.tcx.sess.parse_sess,
|
&self.tcx.sess,
|
||||||
sym::rustdoc_internals,
|
sym::rustdoc_internals,
|
||||||
meta.span(),
|
meta.span(),
|
||||||
"the `#[doc(rust_logo)]` attribute is used for Rust branding",
|
"the `#[doc(rust_logo)]` attribute is used for Rust branding",
|
||||||
|
@ -1815,7 +1815,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
||||||
(target, self.tcx.features().fn_align)
|
(target, self.tcx.features().fn_align)
|
||||||
{
|
{
|
||||||
feature_err(
|
feature_err(
|
||||||
&self.tcx.sess.parse_sess,
|
&self.tcx.sess,
|
||||||
sym::fn_align,
|
sym::fn_align,
|
||||||
hint.span(),
|
hint.span(),
|
||||||
"`repr(align)` attributes on functions are unstable",
|
"`repr(align)` attributes on functions are unstable",
|
||||||
|
|
|
@ -147,7 +147,7 @@ impl<'tcx> CheckConstVisitor<'tcx> {
|
||||||
[missing_primary, ref missing_secondary @ ..] => {
|
[missing_primary, ref missing_secondary @ ..] => {
|
||||||
let msg =
|
let msg =
|
||||||
format!("{} is not allowed in a `{}`", expr.name(), const_kind.keyword_name());
|
format!("{} is not allowed in a `{}`", expr.name(), const_kind.keyword_name());
|
||||||
let mut err = feature_err(&tcx.sess.parse_sess, *missing_primary, span, msg);
|
let mut err = feature_err(&tcx.sess, *missing_primary, span, msg);
|
||||||
|
|
||||||
// If multiple feature gates would be required to enable this expression, include
|
// If multiple feature gates would be required to enable this expression, include
|
||||||
// them as help messages. Don't emit a separate error for each missing feature gate.
|
// them as help messages. Don't emit a separate error for each missing feature gate.
|
||||||
|
|
|
@ -45,8 +45,7 @@ impl DebuggerVisualizerCollector<'_> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let file =
|
let file = match resolve_path(&self.sess, visualizer_path.as_str(), attr.span) {
|
||||||
match resolve_path(&self.sess.parse_sess, visualizer_path.as_str(), attr.span) {
|
|
||||||
Ok(file) => file,
|
Ok(file) => file,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.emit();
|
err.emit();
|
||||||
|
|
|
@ -135,7 +135,7 @@ fn configure_main(tcx: TyCtxt<'_>, visitor: &EntryContext<'_>) -> Option<(DefId,
|
||||||
if main_def.is_import && !tcx.features().imported_main {
|
if main_def.is_import && !tcx.features().imported_main {
|
||||||
let span = main_def.span;
|
let span = main_def.span;
|
||||||
feature_err(
|
feature_err(
|
||||||
&tcx.sess.parse_sess,
|
&tcx.sess,
|
||||||
sym::imported_main,
|
sym::imported_main,
|
||||||
span,
|
span,
|
||||||
"using an imported function as entry point `main` is experimental",
|
"using an imported function as entry point `main` is experimental",
|
||||||
|
|
|
@ -594,13 +594,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
if soft_custom_inner_attributes_gate {
|
if soft_custom_inner_attributes_gate {
|
||||||
self.tcx.sess.parse_sess.buffer_lint(SOFT_UNSTABLE, path.span, node_id, msg);
|
self.tcx.sess.parse_sess.buffer_lint(SOFT_UNSTABLE, path.span, node_id, msg);
|
||||||
} else {
|
} else {
|
||||||
feature_err(
|
feature_err(&self.tcx.sess, sym::custom_inner_attributes, path.span, msg).emit();
|
||||||
&self.tcx.sess.parse_sess,
|
|
||||||
sym::custom_inner_attributes,
|
|
||||||
path.span,
|
|
||||||
msg,
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ session_feature_diagnostic_help =
|
||||||
add `#![feature({$feature})]` to the crate attributes to enable
|
add `#![feature({$feature})]` to the crate attributes to enable
|
||||||
|
|
||||||
session_feature_suggest_upgrade_compiler =
|
session_feature_suggest_upgrade_compiler =
|
||||||
this compiler is version {$version} built on {$date}, consider upgrading?
|
this compiler was built on {$date}; consider upgrading it if it is out of date
|
||||||
|
|
||||||
session_file_is_not_writeable = output file {$file} is not writeable -- check its permissions
|
session_file_is_not_writeable = output file {$file} is not writeable -- check its permissions
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use std::num::NonZeroU32;
|
use std::num::NonZeroU32;
|
||||||
|
|
||||||
use crate::parse::ParseSess;
|
|
||||||
use rustc_ast::token;
|
use rustc_ast::token;
|
||||||
use rustc_ast::util::literal::LitError;
|
use rustc_ast::util::literal::LitError;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
|
@ -10,6 +9,8 @@ use rustc_macros::Diagnostic;
|
||||||
use rustc_span::{BytePos, Span, Symbol};
|
use rustc_span::{BytePos, Span, Symbol};
|
||||||
use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTriple};
|
use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTriple};
|
||||||
|
|
||||||
|
use crate::parse::ParseSess;
|
||||||
|
|
||||||
pub struct FeatureGateError {
|
pub struct FeatureGateError {
|
||||||
pub span: MultiSpan,
|
pub span: MultiSpan,
|
||||||
pub explain: DiagnosticMessage,
|
pub explain: DiagnosticMessage,
|
||||||
|
@ -33,16 +34,18 @@ pub struct FeatureDiagnosticForIssue {
|
||||||
#[derive(Subdiagnostic)]
|
#[derive(Subdiagnostic)]
|
||||||
#[note(session_feature_suggest_upgrade_compiler)]
|
#[note(session_feature_suggest_upgrade_compiler)]
|
||||||
pub struct SuggestUpgradeCompiler {
|
pub struct SuggestUpgradeCompiler {
|
||||||
version: &'static str,
|
|
||||||
date: &'static str,
|
date: &'static str,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SuggestUpgradeCompiler {
|
impl SuggestUpgradeCompiler {
|
||||||
pub fn new() -> Self {
|
pub fn ui_testing() -> Self {
|
||||||
let version = option_env!("CFG_VERSION").unwrap_or("unknown");
|
Self { date: "YYYY-MM-DD" }
|
||||||
let date = option_env!("CFG_VER_DATE").unwrap_or("unknown");
|
}
|
||||||
|
|
||||||
Self { version, date }
|
pub fn new() -> Option<Self> {
|
||||||
|
let date = option_env!("CFG_VER_DATE")?;
|
||||||
|
|
||||||
|
Some(Self { date })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ use crate::errors::{
|
||||||
use crate::lint::{
|
use crate::lint::{
|
||||||
builtin::UNSTABLE_SYNTAX_PRE_EXPANSION, BufferedEarlyLint, BuiltinLintDiagnostics, Lint, LintId,
|
builtin::UNSTABLE_SYNTAX_PRE_EXPANSION, BufferedEarlyLint, BuiltinLintDiagnostics, Lint, LintId,
|
||||||
};
|
};
|
||||||
|
use crate::Session;
|
||||||
use rustc_ast::node_id::NodeId;
|
use rustc_ast::node_id::NodeId;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc};
|
use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc};
|
||||||
|
@ -80,7 +81,7 @@ impl SymbolGallery {
|
||||||
/// The `feature`'s `Symbol` is the one you used in `unstable.rs` and `rustc_span::symbols`.
|
/// The `feature`'s `Symbol` is the one you used in `unstable.rs` and `rustc_span::symbols`.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn feature_err(
|
pub fn feature_err(
|
||||||
sess: &ParseSess,
|
sess: &Session,
|
||||||
feature: Symbol,
|
feature: Symbol,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
explain: impl Into<DiagnosticMessage>,
|
explain: impl Into<DiagnosticMessage>,
|
||||||
|
@ -94,7 +95,7 @@ pub fn feature_err(
|
||||||
/// Almost always, you want to use this for a language feature. If so, prefer `feature_err`.
|
/// Almost always, you want to use this for a language feature. If so, prefer `feature_err`.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn feature_err_issue(
|
pub fn feature_err_issue(
|
||||||
sess: &ParseSess,
|
sess: &Session,
|
||||||
feature: Symbol,
|
feature: Symbol,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
issue: GateIssue,
|
issue: GateIssue,
|
||||||
|
@ -104,12 +105,14 @@ pub fn feature_err_issue(
|
||||||
|
|
||||||
// Cancel an earlier warning for this same error, if it exists.
|
// Cancel an earlier warning for this same error, if it exists.
|
||||||
if let Some(span) = span.primary_span() {
|
if let Some(span) = span.primary_span() {
|
||||||
if let Some(err) = sess.dcx.steal_diagnostic(span, StashKey::EarlySyntaxWarning) {
|
if let Some(err) = sess.parse_sess.dcx.steal_diagnostic(span, StashKey::EarlySyntaxWarning)
|
||||||
|
{
|
||||||
err.cancel()
|
err.cancel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut err = sess.dcx.create_err(FeatureGateError { span, explain: explain.into() });
|
let mut err =
|
||||||
|
sess.parse_sess.dcx.create_err(FeatureGateError { span, explain: explain.into() });
|
||||||
add_feature_diagnostics_for_issue(&mut err, sess, feature, issue, false);
|
add_feature_diagnostics_for_issue(&mut err, sess, feature, issue, false);
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
|
@ -118,7 +121,7 @@ pub fn feature_err_issue(
|
||||||
///
|
///
|
||||||
/// This diagnostic is only a warning and *does not cause compilation to fail*.
|
/// This diagnostic is only a warning and *does not cause compilation to fail*.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn feature_warn(sess: &ParseSess, feature: Symbol, span: Span, explain: &'static str) {
|
pub fn feature_warn(sess: &Session, feature: Symbol, span: Span, explain: &'static str) {
|
||||||
feature_warn_issue(sess, feature, span, GateIssue::Language, explain);
|
feature_warn_issue(sess, feature, span, GateIssue::Language, explain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,13 +135,13 @@ pub fn feature_warn(sess: &ParseSess, feature: Symbol, span: Span, explain: &'st
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
#[allow(rustc::untranslatable_diagnostic)]
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn feature_warn_issue(
|
pub fn feature_warn_issue(
|
||||||
sess: &ParseSess,
|
sess: &Session,
|
||||||
feature: Symbol,
|
feature: Symbol,
|
||||||
span: Span,
|
span: Span,
|
||||||
issue: GateIssue,
|
issue: GateIssue,
|
||||||
explain: &'static str,
|
explain: &'static str,
|
||||||
) {
|
) {
|
||||||
let mut err = sess.dcx.struct_span_warn(span, explain);
|
let mut err = sess.parse_sess.dcx.struct_span_warn(span, explain);
|
||||||
add_feature_diagnostics_for_issue(&mut err, sess, feature, issue, false);
|
add_feature_diagnostics_for_issue(&mut err, sess, feature, issue, false);
|
||||||
|
|
||||||
// Decorate this as a future-incompatibility lint as in rustc_middle::lint::struct_lint_level
|
// Decorate this as a future-incompatibility lint as in rustc_middle::lint::struct_lint_level
|
||||||
|
@ -153,7 +156,7 @@ pub fn feature_warn_issue(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds the diagnostics for a feature to an existing error.
|
/// Adds the diagnostics for a feature to an existing error.
|
||||||
pub fn add_feature_diagnostics(err: &mut Diagnostic, sess: &ParseSess, feature: Symbol) {
|
pub fn add_feature_diagnostics(err: &mut Diagnostic, sess: &Session, feature: Symbol) {
|
||||||
add_feature_diagnostics_for_issue(err, sess, feature, GateIssue::Language, false);
|
add_feature_diagnostics_for_issue(err, sess, feature, GateIssue::Language, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +167,7 @@ pub fn add_feature_diagnostics(err: &mut Diagnostic, sess: &ParseSess, feature:
|
||||||
/// `add_feature_diagnostics`.
|
/// `add_feature_diagnostics`.
|
||||||
pub fn add_feature_diagnostics_for_issue(
|
pub fn add_feature_diagnostics_for_issue(
|
||||||
err: &mut Diagnostic,
|
err: &mut Diagnostic,
|
||||||
sess: &ParseSess,
|
sess: &Session,
|
||||||
feature: Symbol,
|
feature: Symbol,
|
||||||
issue: GateIssue,
|
issue: GateIssue,
|
||||||
feature_from_cli: bool,
|
feature_from_cli: bool,
|
||||||
|
@ -174,14 +177,18 @@ pub fn add_feature_diagnostics_for_issue(
|
||||||
}
|
}
|
||||||
|
|
||||||
// #23973: do not suggest `#![feature(...)]` if we are in beta/stable
|
// #23973: do not suggest `#![feature(...)]` if we are in beta/stable
|
||||||
if sess.unstable_features.is_nightly_build() {
|
if sess.parse_sess.unstable_features.is_nightly_build() {
|
||||||
if feature_from_cli {
|
if feature_from_cli {
|
||||||
err.subdiagnostic(CliFeatureDiagnosticHelp { feature });
|
err.subdiagnostic(CliFeatureDiagnosticHelp { feature });
|
||||||
} else {
|
} else {
|
||||||
err.subdiagnostic(FeatureDiagnosticHelp { feature });
|
err.subdiagnostic(FeatureDiagnosticHelp { feature });
|
||||||
}
|
}
|
||||||
|
|
||||||
err.subdiagnostic(SuggestUpgradeCompiler::new());
|
if sess.opts.unstable_opts.ui_testing {
|
||||||
|
err.subdiagnostic(SuggestUpgradeCompiler::ui_testing());
|
||||||
|
} else if let Some(suggestion) = SuggestUpgradeCompiler::new() {
|
||||||
|
err.subdiagnostic(suggestion);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -318,7 +318,7 @@ impl Session {
|
||||||
if err.code.is_none() {
|
if err.code.is_none() {
|
||||||
err.code(error_code!(E0658));
|
err.code(error_code!(E0658));
|
||||||
}
|
}
|
||||||
add_feature_diagnostics(&mut err, &self.parse_sess, feature);
|
add_feature_diagnostics(&mut err, self, feature);
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -408,7 +408,7 @@ impl<'tcx> OnUnimplementedDirective {
|
||||||
.ok_or_else(|| tcx.dcx().emit_err(EmptyOnClauseInOnUnimplemented { span }))?
|
.ok_or_else(|| tcx.dcx().emit_err(EmptyOnClauseInOnUnimplemented { span }))?
|
||||||
.meta_item()
|
.meta_item()
|
||||||
.ok_or_else(|| tcx.dcx().emit_err(InvalidOnClauseInOnUnimplemented { span }))?;
|
.ok_or_else(|| tcx.dcx().emit_err(InvalidOnClauseInOnUnimplemented { span }))?;
|
||||||
attr::eval_condition(cond, &tcx.sess.parse_sess, Some(tcx.features()), &mut |cfg| {
|
attr::eval_condition(cond, &tcx.sess, Some(tcx.features()), &mut |cfg| {
|
||||||
if let Some(value) = cfg.value
|
if let Some(value) = cfg.value
|
||||||
&& let Err(guar) = parse_value(value, cfg.span)
|
&& let Err(guar) = parse_value(value, cfg.span)
|
||||||
{
|
{
|
||||||
|
@ -682,11 +682,7 @@ impl<'tcx> OnUnimplementedDirective {
|
||||||
|
|
||||||
for command in self.subcommands.iter().chain(Some(self)).rev() {
|
for command in self.subcommands.iter().chain(Some(self)).rev() {
|
||||||
if let Some(ref condition) = command.condition
|
if let Some(ref condition) = command.condition
|
||||||
&& !attr::eval_condition(
|
&& !attr::eval_condition(condition, &tcx.sess, Some(tcx.features()), &mut |cfg| {
|
||||||
condition,
|
|
||||||
&tcx.sess.parse_sess,
|
|
||||||
Some(tcx.features()),
|
|
||||||
&mut |cfg| {
|
|
||||||
let value = cfg.value.map(|v| {
|
let value = cfg.value.map(|v| {
|
||||||
// `with_no_visible_paths` is also used when generating the options,
|
// `with_no_visible_paths` is also used when generating the options,
|
||||||
// so we need to match it here.
|
// so we need to match it here.
|
||||||
|
@ -696,17 +692,12 @@ impl<'tcx> OnUnimplementedDirective {
|
||||||
span: cfg.span,
|
span: cfg.span,
|
||||||
is_diagnostic_namespace_variant: false
|
is_diagnostic_namespace_variant: false
|
||||||
}
|
}
|
||||||
.format(
|
.format(tcx, trait_ref, &options_map)
|
||||||
tcx,
|
|
||||||
trait_ref,
|
|
||||||
&options_map
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
options.contains(&(cfg.name, value))
|
options.contains(&(cfg.name, value))
|
||||||
},
|
})
|
||||||
)
|
|
||||||
{
|
{
|
||||||
debug!("evaluate: skipping {:?} due to condition", command);
|
debug!("evaluate: skipping {:?} due to condition", command);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -65,9 +65,10 @@ pub(crate) fn look_for_custom_classes<'tcx>(cx: &DocContext<'tcx>, item: &Item)
|
||||||
|
|
||||||
if !tests.custom_classes_found.is_empty() {
|
if !tests.custom_classes_found.is_empty() {
|
||||||
let span = item.attr_span(cx.tcx);
|
let span = item.attr_span(cx.tcx);
|
||||||
let sess = &cx.tcx.sess.parse_sess;
|
let sess = &cx.tcx.sess;
|
||||||
let mut err =
|
let mut err = sess
|
||||||
sess.dcx.struct_span_warn(span, "custom classes in code blocks will change behaviour");
|
.dcx()
|
||||||
|
.struct_span_warn(span, "custom classes in code blocks will change behaviour");
|
||||||
add_feature_diagnostics_for_issue(
|
add_feature_diagnostics_for_issue(
|
||||||
&mut err,
|
&mut err,
|
||||||
sess,
|
sess,
|
||||||
|
|
|
@ -1223,7 +1223,7 @@ impl LinkCollector<'_, '_> {
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|| item.attr_span(self.cx.tcx));
|
.unwrap_or_else(|| item.attr_span(self.cx.tcx));
|
||||||
rustc_session::parse::feature_err(
|
rustc_session::parse::feature_err(
|
||||||
&self.cx.tcx.sess.parse_sess,
|
&self.cx.tcx.sess,
|
||||||
sym::intra_doc_pointers,
|
sym::intra_doc_pointers,
|
||||||
span,
|
span,
|
||||||
"linking to associated items of raw pointers is experimental",
|
"linking to associated items of raw pointers is experimental",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue