提交 77f2a2fe 编写于 作者: V Vadim Petrochenkov

Turn the error for module-relative access to macro-expanded `macro_export`...

Turn the error for module-relative access to macro-expanded `macro_export` macros into a deprecation lint
上级 7a8b7268
......@@ -331,6 +331,13 @@
via the module system"
}
declare_lint! {
pub MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
Deny,
"macro-expanded `macro_export` macros from the current crate \
cannot be referred to by absolute paths"
}
/// Some lints that are buffered from `libsyntax`. See `syntax::early_buffered_lints`.
pub mod parser {
declare_lint! {
......@@ -398,6 +405,7 @@ fn get_lints(&self) -> LintArray {
WHERE_CLAUSES_OBJECT_SAFETY,
PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
MACRO_USE_EXTERN_CRATE,
MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
parser::QUESTION_MARK_MACRO_SEP,
)
}
......@@ -412,6 +420,7 @@ pub enum BuiltinLintDiagnostics {
AbsPathWithModule(Span),
DuplicatedMacroExports(ast::Ident, Span, Span),
ProcMacroDeriveResolutionFallback(Span),
MacroExpandedMacroExportsAccessedByAbsolutePaths(Span),
ElidedLifetimesInPaths(usize, Span, bool, Span, String),
}
......@@ -453,6 +462,9 @@ pub fn run(self, sess: &Session, db: &mut DiagnosticBuilder) {
db.span_label(span, "names from parent modules are not \
accessible without an explicit import");
}
BuiltinLintDiagnostics::MacroExpandedMacroExportsAccessedByAbsolutePaths(span_def) => {
db.span_note(span_def, "the macro is defined here");
}
BuiltinLintDiagnostics::ElidedLifetimesInPaths(
n, path_span, incl_angl_brckt, insertion_span, anon_lts
) => {
......
......@@ -334,7 +334,12 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
id: LintId::of(QUESTION_MARK_MACRO_SEP),
reference: "issue #48075 <https://github.com/rust-lang/rust/issues/48075>",
edition: Some(Edition::Edition2018),
}
},
FutureIncompatibleInfo {
id: LintId::of(MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS),
reference: "issue #52234 <https://github.com/rust-lang/rust/issues/52234>",
edition: None,
},
]);
// Register renamed and removed lints
......
......@@ -4477,9 +4477,12 @@ fn report_errors(&mut self, krate: &Crate) {
for &(span_use, span_def) in &self.macro_expanded_macro_export_errors {
let msg = "macro-expanded `macro_export` macros from the current crate \
cannot be referred to by absolute paths";
self.session.struct_span_err(span_use, msg)
.span_note(span_def, "the macro is defined here")
.emit();
self.session.buffer_lint_with_diagnostic(
lint::builtin::MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
CRATE_NODE_ID, span_use, msg,
lint::builtin::BuiltinLintDiagnostics::
MacroExpandedMacroExportsAccessedByAbsolutePaths(span_def),
);
}
for &AmbiguityError { span, name, b1, b2, lexical } in &self.ambiguity_errors {
......
......@@ -22,9 +22,11 @@
mod m {
use exported;
//~^ ERROR macro-expanded `macro_export` macros from the current crate cannot
//~| WARN this was previously accepted
}
fn main() {
::exported!();
//~^ ERROR macro-expanded `macro_export` macros from the current crate cannot
//~| WARN this was previously accepted
}
......@@ -4,6 +4,9 @@ error: macro-expanded `macro_export` macros from the current crate cannot be ref
LL | use exported;
| ^^^^^^^^
|
= note: #[deny(macro_expanded_macro_exports_accessed_by_absolute_paths)] on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #52234 <https://github.com/rust-lang/rust/issues/52234>
note: the macro is defined here
--> $DIR/local-modularized-tricky-fail-3.rs:15:5
|
......@@ -16,11 +19,13 @@ LL | define_exported!();
| ------------------- in this macro invocation
error: macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths
--> $DIR/local-modularized-tricky-fail-3.rs:28:5
--> $DIR/local-modularized-tricky-fail-3.rs:29:5
|
LL | ::exported!();
| ^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #52234 <https://github.com/rust-lang/rust/issues/52234>
note: the macro is defined here
--> $DIR/local-modularized-tricky-fail-3.rs:15:5
|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册