Skip to content

Commit 79b35e9

Browse files
committed
legacy_directory_ownership -> error
1 parent c0056c0 commit 79b35e9

File tree

8 files changed

+9
-53
lines changed

8 files changed

+9
-53
lines changed

src/doc/rustc/src/lints/listing/deny-by-default.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,6 @@ error: defaults for type parameters are only allowed in `struct`, `enum`, `type`
4545
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
4646
```
4747

48-
## legacy-directory-ownership
49-
50-
The legacy_directory_ownership warning is issued when
51-
52-
* There is a non-inline module with a `#[path]` attribute (e.g. `#[path = "foo.rs"] mod bar;`),
53-
* The module's file ("foo.rs" in the above example) is not named "mod.rs", and
54-
* The module's file contains a non-inline child module without a `#[path]` attribute.
55-
56-
The warning can be fixed by renaming the parent module to "mod.rs" and moving
57-
it into its own directory if appropriate.
58-
59-
6048
## missing-fragment-specifier
6149

6250
The missing_fragment_specifier warning is issued when an unused pattern in a

src/librustc/lint/builtin.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -207,17 +207,6 @@ declare_lint! {
207207
};
208208
}
209209

210-
declare_lint! {
211-
pub LEGACY_DIRECTORY_OWNERSHIP,
212-
Deny,
213-
"non-inline, non-`#[path]` modules (e.g., `mod foo;`) were erroneously allowed in some files \
214-
not named `mod.rs`",
215-
@future_incompatible = FutureIncompatibleInfo {
216-
reference: "issue #37872 <https://github.com/rust-lang/rust/issues/37872>",
217-
edition: None,
218-
};
219-
}
220-
221210
declare_lint! {
222211
pub MISSING_FRAGMENT_SPECIFIER,
223212
Deny,
@@ -549,7 +538,6 @@ declare_lint_pass! {
549538
SAFE_EXTERN_STATICS,
550539
SAFE_PACKED_BORROWS,
551540
PATTERNS_IN_FNS_WITHOUT_BODY,
552-
LEGACY_DIRECTORY_OWNERSHIP,
553541
MISSING_FRAGMENT_SPECIFIER,
554542
PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
555543
LATE_BOUND_LIFETIME_ARGUMENTS,

src/librustc_lint/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,8 @@ fn register_builtins(store: &mut lint::LintStore, no_interleave_lints: bool) {
336336
"converted into hard error, see https://github.com/rust-lang/rust/issues/46205");
337337
store.register_removed("legacy_constructor_visibility",
338338
"converted into hard error, see https://github.com/rust-lang/rust/issues/39207");
339+
store.register_removed("legacy_disrectory_ownership",
340+
"converted into hard error, see https://github.com/rust-lang/rust/issues/37872");
339341
}
340342

341343
fn register_internals(store: &mut lint::LintStore) {

src/librustc_passes/ast_validation.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -654,11 +654,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
654654
ItemKind::Mod(_) => {
655655
// Ensure that `path` attributes on modules are recorded as used (cf. issue #35584).
656656
attr::first_attr_value_str_by_name(&item.attrs, sym::path);
657-
if attr::contains_name(&item.attrs, sym::warn_directory_ownership) {
658-
let lint = lint::builtin::LEGACY_DIRECTORY_OWNERSHIP;
659-
let msg = "cannot declare a new module at this location";
660-
self.lint_buffer.buffer_lint(lint, item.id, item.span, msg);
661-
}
662657
}
663658
ItemKind::Union(ref vdata, _) => {
664659
if let VariantData::Tuple(..) | VariantData::Unit(..) = vdata {

src/libsyntax/parse/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub enum DirectoryOwnership {
5151
relative: Option<ast::Ident>,
5252
},
5353
UnownedViaBlock,
54-
UnownedViaMod(bool /* legacy warnings? */),
54+
UnownedViaMod,
5555
}
5656

5757
// A bunch of utility functions of the form `parse_<thing>_from_<source>`

src/libsyntax/parse/parser/module.rs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ pub(super) struct ModulePath {
2121
pub(super) struct ModulePathSuccess {
2222
pub path: PathBuf,
2323
pub directory_ownership: DirectoryOwnership,
24-
warn: bool,
2524
}
2625

2726
impl<'a> Parser<'a> {
@@ -55,17 +54,10 @@ impl<'a> Parser<'a> {
5554
if self.eat(&token::Semi) {
5655
if in_cfg && self.recurse_into_file_modules {
5756
// This mod is in an external file. Let's go get it!
58-
let ModulePathSuccess { path, directory_ownership, warn } =
57+
let ModulePathSuccess { path, directory_ownership } =
5958
self.submod_path(id, &outer_attrs, id_span)?;
60-
let (module, mut attrs) =
59+
let (module, attrs) =
6160
self.eval_src_mod(path, directory_ownership, id.to_string(), id_span)?;
62-
// Record that we fetched the mod from an external file.
63-
if warn {
64-
let attr = attr::mk_attr_outer(
65-
attr::mk_word_item(Ident::with_dummy_span(sym::warn_directory_ownership)));
66-
attr::mark_known(&attr);
67-
attrs.push(attr);
68-
}
6961
Ok((id, ItemKind::Mod(module), Some(attrs)))
7062
} else {
7163
let placeholder = ast::Mod {
@@ -136,17 +128,16 @@ impl<'a> Parser<'a> {
136128
// `#[path]` included and contains a `mod foo;` declaration.
137129
// If you encounter this, it's your own darn fault :P
138130
Some(_) => DirectoryOwnership::Owned { relative: None },
139-
_ => DirectoryOwnership::UnownedViaMod(true),
131+
_ => DirectoryOwnership::UnownedViaMod,
140132
},
141133
path,
142-
warn: false,
143134
});
144135
}
145136

146137
let relative = match self.directory.ownership {
147138
DirectoryOwnership::Owned { relative } => relative,
148139
DirectoryOwnership::UnownedViaBlock |
149-
DirectoryOwnership::UnownedViaMod(_) => None,
140+
DirectoryOwnership::UnownedViaMod => None,
150141
};
151142
let paths = Parser::default_submod_path(
152143
id, relative, &self.directory.path, self.sess.source_map());
@@ -167,12 +158,7 @@ impl<'a> Parser<'a> {
167158
}
168159
Err(err)
169160
}
170-
DirectoryOwnership::UnownedViaMod(warn) => {
171-
if warn {
172-
if let Ok(result) = paths.result {
173-
return Ok(ModulePathSuccess { warn: true, ..result });
174-
}
175-
}
161+
DirectoryOwnership::UnownedViaMod => {
176162
let mut err = self.diagnostic().struct_span_err(id_sp,
177163
"cannot declare a new module at this location");
178164
if !id_sp.is_dummy() {
@@ -250,14 +236,12 @@ impl<'a> Parser<'a> {
250236
directory_ownership: DirectoryOwnership::Owned {
251237
relative: Some(id),
252238
},
253-
warn: false,
254239
}),
255240
(false, true) => Ok(ModulePathSuccess {
256241
path: secondary_path,
257242
directory_ownership: DirectoryOwnership::Owned {
258243
relative: None,
259244
},
260-
warn: false,
261245
}),
262246
(false, false) => Err(Error::FileNotFoundForModule {
263247
mod_name: mod_name.clone(),

src/libsyntax_expand/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
13001300
Some(_) => DirectoryOwnership::Owned {
13011301
relative: Some(item.ident),
13021302
},
1303-
None => DirectoryOwnership::UnownedViaMod(false),
1303+
None => DirectoryOwnership::UnownedViaMod,
13041304
};
13051305
path.pop();
13061306
module.directory = path;

src/libsyntax_pos/symbol.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,6 @@ symbols! {
734734
visible_private_types,
735735
volatile,
736736
warn,
737-
warn_directory_ownership,
738737
wasm_import_module,
739738
wasm_target_feature,
740739
while_let,

0 commit comments

Comments
 (0)