Skip to content

Rollup of 7 pull requests #97126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b712135
rustdoc-json-types: Improve docs for HRTB fields
Enselic May 2, 2022
1f15ce5
rustdoc-json: Fix HRTBs for WherePredicate::BoundPredicate
Enselic May 2, 2022
774b525
rustdoc-json: Add tests for all three HRTB fields
Enselic May 4, 2022
7f11749
rustdoc: don't build `rayon` for non-windows targets
klensy May 6, 2022
03007de
Omit unnecessary help to add `#[cfg(test)]` when already annotated
ken-matsui May 2, 2022
17f2893
Types with reachable constructors are reachable
tmiasko May 17, 2022
658be0d
Add tmm_reg clobbers
chorman0773 May 17, 2022
50ce367
add clobbers
chorman0773 May 17, 2022
89ab77b
Handle tmm_reg in rustc_codegen_gcc
chorman0773 May 17, 2022
6354bfc
Add ABI clobbers
chorman0773 May 17, 2022
eabe851
fix clobber_abi tests
chorman0773 May 17, 2022
e170d87
Update browser-ui-test version to 0.9.2
GuillaumeGomez May 16, 2022
d765b73
Fix duplicated "in" in the search result text
GuillaumeGomez May 17, 2022
5601044
Add GUI test for search result "title"
GuillaumeGomez May 17, 2022
0f8b3f4
Fix display of search crate filter select
GuillaumeGomez May 17, 2022
440bbce
Add GUI test for search crate filter select CSS properties
GuillaumeGomez May 17, 2022
501f5d0
interpret/validity: reject references to uninhabited types
RalfJung May 17, 2022
201750d
bless 32bit
RalfJung May 17, 2022
ce49ce2
Rollup merge of #96647 - Enselic:fix-hrtb-for-wherepredicate, r=Craft…
JohnTitor May 17, 2022
78c709c
Rollup merge of #96651 - ken-matsui:omit-unnecessary-help-to-add-cfg-…
JohnTitor May 17, 2022
e9f3733
Rollup merge of #96761 - klensy:no-rayon-here, r=CraftSpider
JohnTitor May 17, 2022
f597846
Rollup merge of #97096 - tmiasko:reachable-constructor, r=petrochenkov
JohnTitor May 17, 2022
7361b22
Rollup merge of #97097 - chorman0773:add_tmm_clobers, r=joshtriplett
JohnTitor May 17, 2022
b8dd270
Rollup merge of #97113 - GuillaumeGomez:search-ui-fixes, r=notriddle
JohnTitor May 17, 2022
248890c
Rollup merge of #97116 - RalfJung:ref-validity, r=oli-obk
JohnTitor May 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions compiler/rustc_resolve/src/check_unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,21 +315,28 @@ impl Resolver<'_> {
"remove the unused import"
};

let parent_module = visitor.r.get_nearest_non_block_module(
visitor.r.local_def_id(unused.use_tree_id).to_def_id(),
);
let test_module_span = match module_to_string(parent_module) {
Some(module)
if module == "test"
|| module == "tests"
|| module.starts_with("test_")
|| module.starts_with("tests_")
|| module.ends_with("_test")
|| module.ends_with("_tests") =>
{
Some(parent_module.span)
// If we are in the `--test` mode, suppress a help that adds the `#[cfg(test)]`
// attribute; however, if not, suggest adding the attribute. There is no way to
// retrieve attributes here because we do not have a `TyCtxt` yet.
let test_module_span = if visitor.r.session.opts.test {
None
} else {
let parent_module = visitor.r.get_nearest_non_block_module(
visitor.r.local_def_id(unused.use_tree_id).to_def_id(),
);
match module_to_string(parent_module) {
Some(module)
if module == "test"
|| module == "tests"
|| module.starts_with("test_")
|| module.starts_with("tests_")
|| module.ends_with("_test")
|| module.ends_with("_tests") =>
{
Some(parent_module.span)
}
_ => None,
}
_ => None,
};

visitor.r.lint_buffer.buffer_lint_with_diagnostic(
Expand Down
84 changes: 84 additions & 0 deletions src/test/ui/imports/unused-imports-in-test-mode.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// compile-flags: --test

#![deny(unused_imports)]

use std::io::BufRead; //~ ERROR unused import: `std::io::BufRead`

fn a() {}
fn b() {}

mod test {
use super::a; //~ ERROR unused import: `super::a`

fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
}
}

mod tests {
use super::a; //~ ERROR unused import: `super::a`

fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
}
}

mod test_a {
use super::a; //~ ERROR unused import: `super::a`

fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
}
}

mod a_test {
use super::a; //~ ERROR unused import: `super::a`

fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
}
}

mod tests_a {
use super::a; //~ ERROR unused import: `super::a`

fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
}
}

mod a_tests {
use super::a; //~ ERROR unused import: `super::a`

fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
}
}

mod fastest_search {
use super::a; //~ ERROR unused import: `super::a`

fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
}
}

#[cfg(test)]
mod test_has_attr {
use super::a; //~ ERROR unused import: `super::a`

fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
}
}

mod test_has_no_attr {
#[cfg(test)]
use super::a; //~ ERROR unused import: `super::a`

fn foo() {
use crate::b; //~ ERROR unused import: `crate::b`
}
}

fn main() {}
122 changes: 122 additions & 0 deletions src/test/ui/imports/unused-imports-in-test-mode.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
error: unused import: `std::io::BufRead`
--> $DIR/unused-imports-in-test-mode.rs:5:5
|
LL | use std::io::BufRead;
| ^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/unused-imports-in-test-mode.rs:3:9
|
LL | #![deny(unused_imports)]
| ^^^^^^^^^^^^^^

error: unused import: `super::a`
--> $DIR/unused-imports-in-test-mode.rs:11:9
|
LL | use super::a;
| ^^^^^^^^

error: unused import: `crate::b`
--> $DIR/unused-imports-in-test-mode.rs:14:13
|
LL | use crate::b;
| ^^^^^^^^

error: unused import: `super::a`
--> $DIR/unused-imports-in-test-mode.rs:19:9
|
LL | use super::a;
| ^^^^^^^^

error: unused import: `crate::b`
--> $DIR/unused-imports-in-test-mode.rs:22:13
|
LL | use crate::b;
| ^^^^^^^^

error: unused import: `super::a`
--> $DIR/unused-imports-in-test-mode.rs:27:9
|
LL | use super::a;
| ^^^^^^^^

error: unused import: `crate::b`
--> $DIR/unused-imports-in-test-mode.rs:30:13
|
LL | use crate::b;
| ^^^^^^^^

error: unused import: `super::a`
--> $DIR/unused-imports-in-test-mode.rs:35:9
|
LL | use super::a;
| ^^^^^^^^

error: unused import: `crate::b`
--> $DIR/unused-imports-in-test-mode.rs:38:13
|
LL | use crate::b;
| ^^^^^^^^

error: unused import: `super::a`
--> $DIR/unused-imports-in-test-mode.rs:43:9
|
LL | use super::a;
| ^^^^^^^^

error: unused import: `crate::b`
--> $DIR/unused-imports-in-test-mode.rs:46:13
|
LL | use crate::b;
| ^^^^^^^^

error: unused import: `super::a`
--> $DIR/unused-imports-in-test-mode.rs:51:9
|
LL | use super::a;
| ^^^^^^^^

error: unused import: `crate::b`
--> $DIR/unused-imports-in-test-mode.rs:54:13
|
LL | use crate::b;
| ^^^^^^^^

error: unused import: `super::a`
--> $DIR/unused-imports-in-test-mode.rs:59:9
|
LL | use super::a;
| ^^^^^^^^

error: unused import: `crate::b`
--> $DIR/unused-imports-in-test-mode.rs:62:13
|
LL | use crate::b;
| ^^^^^^^^

error: unused import: `super::a`
--> $DIR/unused-imports-in-test-mode.rs:68:9
|
LL | use super::a;
| ^^^^^^^^

error: unused import: `crate::b`
--> $DIR/unused-imports-in-test-mode.rs:71:13
|
LL | use crate::b;
| ^^^^^^^^

error: unused import: `super::a`
--> $DIR/unused-imports-in-test-mode.rs:77:9
|
LL | use super::a;
| ^^^^^^^^

error: unused import: `crate::b`
--> $DIR/unused-imports-in-test-mode.rs:80:13
|
LL | use crate::b;
| ^^^^^^^^

error: aborting due to 19 previous errors