legacy_directory_ownership -> error
This commit is contained in:
parent
c0056c04f6
commit
79b35e90f1
8 changed files with 9 additions and 53 deletions
|
@ -45,18 +45,6 @@ error: defaults for type parameters are only allowed in `struct`, `enum`, `type`
|
||||||
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
|
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
|
||||||
```
|
```
|
||||||
|
|
||||||
## legacy-directory-ownership
|
|
||||||
|
|
||||||
The legacy_directory_ownership warning is issued when
|
|
||||||
|
|
||||||
* There is a non-inline module with a `#[path]` attribute (e.g. `#[path = "foo.rs"] mod bar;`),
|
|
||||||
* The module's file ("foo.rs" in the above example) is not named "mod.rs", and
|
|
||||||
* The module's file contains a non-inline child module without a `#[path]` attribute.
|
|
||||||
|
|
||||||
The warning can be fixed by renaming the parent module to "mod.rs" and moving
|
|
||||||
it into its own directory if appropriate.
|
|
||||||
|
|
||||||
|
|
||||||
## missing-fragment-specifier
|
## missing-fragment-specifier
|
||||||
|
|
||||||
The missing_fragment_specifier warning is issued when an unused pattern in a
|
The missing_fragment_specifier warning is issued when an unused pattern in a
|
||||||
|
|
|
@ -207,17 +207,6 @@ declare_lint! {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_lint! {
|
|
||||||
pub LEGACY_DIRECTORY_OWNERSHIP,
|
|
||||||
Deny,
|
|
||||||
"non-inline, non-`#[path]` modules (e.g., `mod foo;`) were erroneously allowed in some files \
|
|
||||||
not named `mod.rs`",
|
|
||||||
@future_incompatible = FutureIncompatibleInfo {
|
|
||||||
reference: "issue #37872 <https://github.com/rust-lang/rust/issues/37872>",
|
|
||||||
edition: None,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
declare_lint! {
|
declare_lint! {
|
||||||
pub MISSING_FRAGMENT_SPECIFIER,
|
pub MISSING_FRAGMENT_SPECIFIER,
|
||||||
Deny,
|
Deny,
|
||||||
|
@ -549,7 +538,6 @@ declare_lint_pass! {
|
||||||
SAFE_EXTERN_STATICS,
|
SAFE_EXTERN_STATICS,
|
||||||
SAFE_PACKED_BORROWS,
|
SAFE_PACKED_BORROWS,
|
||||||
PATTERNS_IN_FNS_WITHOUT_BODY,
|
PATTERNS_IN_FNS_WITHOUT_BODY,
|
||||||
LEGACY_DIRECTORY_OWNERSHIP,
|
|
||||||
MISSING_FRAGMENT_SPECIFIER,
|
MISSING_FRAGMENT_SPECIFIER,
|
||||||
PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
|
PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
|
||||||
LATE_BOUND_LIFETIME_ARGUMENTS,
|
LATE_BOUND_LIFETIME_ARGUMENTS,
|
||||||
|
|
|
@ -336,6 +336,8 @@ fn register_builtins(store: &mut lint::LintStore, no_interleave_lints: bool) {
|
||||||
"converted into hard error, see https://github.com/rust-lang/rust/issues/46205");
|
"converted into hard error, see https://github.com/rust-lang/rust/issues/46205");
|
||||||
store.register_removed("legacy_constructor_visibility",
|
store.register_removed("legacy_constructor_visibility",
|
||||||
"converted into hard error, see https://github.com/rust-lang/rust/issues/39207");
|
"converted into hard error, see https://github.com/rust-lang/rust/issues/39207");
|
||||||
|
store.register_removed("legacy_disrectory_ownership",
|
||||||
|
"converted into hard error, see https://github.com/rust-lang/rust/issues/37872");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_internals(store: &mut lint::LintStore) {
|
fn register_internals(store: &mut lint::LintStore) {
|
||||||
|
|
|
@ -654,11 +654,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||||
ItemKind::Mod(_) => {
|
ItemKind::Mod(_) => {
|
||||||
// Ensure that `path` attributes on modules are recorded as used (cf. issue #35584).
|
// Ensure that `path` attributes on modules are recorded as used (cf. issue #35584).
|
||||||
attr::first_attr_value_str_by_name(&item.attrs, sym::path);
|
attr::first_attr_value_str_by_name(&item.attrs, sym::path);
|
||||||
if attr::contains_name(&item.attrs, sym::warn_directory_ownership) {
|
|
||||||
let lint = lint::builtin::LEGACY_DIRECTORY_OWNERSHIP;
|
|
||||||
let msg = "cannot declare a new module at this location";
|
|
||||||
self.lint_buffer.buffer_lint(lint, item.id, item.span, msg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ItemKind::Union(ref vdata, _) => {
|
ItemKind::Union(ref vdata, _) => {
|
||||||
if let VariantData::Tuple(..) | VariantData::Unit(..) = vdata {
|
if let VariantData::Tuple(..) | VariantData::Unit(..) = vdata {
|
||||||
|
|
|
@ -51,7 +51,7 @@ pub enum DirectoryOwnership {
|
||||||
relative: Option<ast::Ident>,
|
relative: Option<ast::Ident>,
|
||||||
},
|
},
|
||||||
UnownedViaBlock,
|
UnownedViaBlock,
|
||||||
UnownedViaMod(bool /* legacy warnings? */),
|
UnownedViaMod,
|
||||||
}
|
}
|
||||||
|
|
||||||
// A bunch of utility functions of the form `parse_<thing>_from_<source>`
|
// A bunch of utility functions of the form `parse_<thing>_from_<source>`
|
||||||
|
|
|
@ -21,7 +21,6 @@ pub(super) struct ModulePath {
|
||||||
pub(super) struct ModulePathSuccess {
|
pub(super) struct ModulePathSuccess {
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
pub directory_ownership: DirectoryOwnership,
|
pub directory_ownership: DirectoryOwnership,
|
||||||
warn: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Parser<'a> {
|
impl<'a> Parser<'a> {
|
||||||
|
@ -55,17 +54,10 @@ impl<'a> Parser<'a> {
|
||||||
if self.eat(&token::Semi) {
|
if self.eat(&token::Semi) {
|
||||||
if in_cfg && self.recurse_into_file_modules {
|
if in_cfg && self.recurse_into_file_modules {
|
||||||
// This mod is in an external file. Let's go get it!
|
// This mod is in an external file. Let's go get it!
|
||||||
let ModulePathSuccess { path, directory_ownership, warn } =
|
let ModulePathSuccess { path, directory_ownership } =
|
||||||
self.submod_path(id, &outer_attrs, id_span)?;
|
self.submod_path(id, &outer_attrs, id_span)?;
|
||||||
let (module, mut attrs) =
|
let (module, attrs) =
|
||||||
self.eval_src_mod(path, directory_ownership, id.to_string(), id_span)?;
|
self.eval_src_mod(path, directory_ownership, id.to_string(), id_span)?;
|
||||||
// Record that we fetched the mod from an external file.
|
|
||||||
if warn {
|
|
||||||
let attr = attr::mk_attr_outer(
|
|
||||||
attr::mk_word_item(Ident::with_dummy_span(sym::warn_directory_ownership)));
|
|
||||||
attr::mark_known(&attr);
|
|
||||||
attrs.push(attr);
|
|
||||||
}
|
|
||||||
Ok((id, ItemKind::Mod(module), Some(attrs)))
|
Ok((id, ItemKind::Mod(module), Some(attrs)))
|
||||||
} else {
|
} else {
|
||||||
let placeholder = ast::Mod {
|
let placeholder = ast::Mod {
|
||||||
|
@ -136,17 +128,16 @@ impl<'a> Parser<'a> {
|
||||||
// `#[path]` included and contains a `mod foo;` declaration.
|
// `#[path]` included and contains a `mod foo;` declaration.
|
||||||
// If you encounter this, it's your own darn fault :P
|
// If you encounter this, it's your own darn fault :P
|
||||||
Some(_) => DirectoryOwnership::Owned { relative: None },
|
Some(_) => DirectoryOwnership::Owned { relative: None },
|
||||||
_ => DirectoryOwnership::UnownedViaMod(true),
|
_ => DirectoryOwnership::UnownedViaMod,
|
||||||
},
|
},
|
||||||
path,
|
path,
|
||||||
warn: false,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let relative = match self.directory.ownership {
|
let relative = match self.directory.ownership {
|
||||||
DirectoryOwnership::Owned { relative } => relative,
|
DirectoryOwnership::Owned { relative } => relative,
|
||||||
DirectoryOwnership::UnownedViaBlock |
|
DirectoryOwnership::UnownedViaBlock |
|
||||||
DirectoryOwnership::UnownedViaMod(_) => None,
|
DirectoryOwnership::UnownedViaMod => None,
|
||||||
};
|
};
|
||||||
let paths = Parser::default_submod_path(
|
let paths = Parser::default_submod_path(
|
||||||
id, relative, &self.directory.path, self.sess.source_map());
|
id, relative, &self.directory.path, self.sess.source_map());
|
||||||
|
@ -167,12 +158,7 @@ impl<'a> Parser<'a> {
|
||||||
}
|
}
|
||||||
Err(err)
|
Err(err)
|
||||||
}
|
}
|
||||||
DirectoryOwnership::UnownedViaMod(warn) => {
|
DirectoryOwnership::UnownedViaMod => {
|
||||||
if warn {
|
|
||||||
if let Ok(result) = paths.result {
|
|
||||||
return Ok(ModulePathSuccess { warn: true, ..result });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let mut err = self.diagnostic().struct_span_err(id_sp,
|
let mut err = self.diagnostic().struct_span_err(id_sp,
|
||||||
"cannot declare a new module at this location");
|
"cannot declare a new module at this location");
|
||||||
if !id_sp.is_dummy() {
|
if !id_sp.is_dummy() {
|
||||||
|
@ -250,14 +236,12 @@ impl<'a> Parser<'a> {
|
||||||
directory_ownership: DirectoryOwnership::Owned {
|
directory_ownership: DirectoryOwnership::Owned {
|
||||||
relative: Some(id),
|
relative: Some(id),
|
||||||
},
|
},
|
||||||
warn: false,
|
|
||||||
}),
|
}),
|
||||||
(false, true) => Ok(ModulePathSuccess {
|
(false, true) => Ok(ModulePathSuccess {
|
||||||
path: secondary_path,
|
path: secondary_path,
|
||||||
directory_ownership: DirectoryOwnership::Owned {
|
directory_ownership: DirectoryOwnership::Owned {
|
||||||
relative: None,
|
relative: None,
|
||||||
},
|
},
|
||||||
warn: false,
|
|
||||||
}),
|
}),
|
||||||
(false, false) => Err(Error::FileNotFoundForModule {
|
(false, false) => Err(Error::FileNotFoundForModule {
|
||||||
mod_name: mod_name.clone(),
|
mod_name: mod_name.clone(),
|
||||||
|
|
|
@ -1300,7 +1300,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
|
||||||
Some(_) => DirectoryOwnership::Owned {
|
Some(_) => DirectoryOwnership::Owned {
|
||||||
relative: Some(item.ident),
|
relative: Some(item.ident),
|
||||||
},
|
},
|
||||||
None => DirectoryOwnership::UnownedViaMod(false),
|
None => DirectoryOwnership::UnownedViaMod,
|
||||||
};
|
};
|
||||||
path.pop();
|
path.pop();
|
||||||
module.directory = path;
|
module.directory = path;
|
||||||
|
|
|
@ -734,7 +734,6 @@ symbols! {
|
||||||
visible_private_types,
|
visible_private_types,
|
||||||
volatile,
|
volatile,
|
||||||
warn,
|
warn,
|
||||||
warn_directory_ownership,
|
|
||||||
wasm_import_module,
|
wasm_import_module,
|
||||||
wasm_target_feature,
|
wasm_target_feature,
|
||||||
while_let,
|
while_let,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue