Skip to content
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

Rollup of 11 pull requests #127665

Merged
merged 29 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
31851d4
Add `-Zdump-mir-exclude-alloc-bytes`
cuviper Jun 14, 2024
1a05cb2
Use `-Zdump-mir-exclude-alloc-bytes` in some mir-opt tests
cuviper Jun 14, 2024
7c3673f
Bless mir-opt for excluded alloc bytes
cuviper Jun 14, 2024
fe5581d
Fix import suggestion ice
chenyukang Jul 4, 2024
87856c4
add lint for inline asm labels that look like binary
asquared31415 Jun 24, 2024
a3ef94e
Fire unsafe_code lint on unsafe extern blocks
spastorino Jul 9, 2024
03bee1e
Suggest using precise capturing for hidden type that captures region
compiler-errors Jul 11, 2024
42653c0
Make it translatable too
compiler-errors Jul 11, 2024
2c8bbee
Remove fully_normalize
compiler-errors Jul 11, 2024
843f5dd
Add rustdoc support for use<> in (local) RPITs
compiler-errors Jul 11, 2024
bd135e4
Add rustdoc-json support for use<>
compiler-errors Jul 11, 2024
cef8a04
rewrite extra-filename-with-temp-outputs to rmake
Oneirical Jul 4, 2024
c6cdbe6
rewrite and rename issue-85019-moved-src-dir to rmake
Oneirical Jul 4, 2024
f768db6
rewrite and rename issue-83045 to rmake
Oneirical Jul 5, 2024
87c7a42
rewrite rustc-macro-dep-files to rmake
Oneirical Jul 5, 2024
fe76650
rewrite env-dep-info to rmake
Oneirical Jul 5, 2024
2772f89
Rename the internal `const_strlen` to just `strlen`
tgross35 Jul 12, 2024
1fd0311
Added the `xop` target feature and `xop_target_feature` gate
sayantn Jul 12, 2024
5d56572
Rollup merge of #126502 - cuviper:dump-mir-exclude-alloc-bytes, r=est…
workingjubilee Jul 12, 2024
fc0136e
Rollup merge of #126922 - asquared31415:asm_binary_label, r=estebank
workingjubilee Jul 12, 2024
a6a7129
Rollup merge of #127209 - sayantn:xop, r=Amanieu
workingjubilee Jul 12, 2024
afb2fbf
Rollup merge of #127310 - chenyukang:yukang-fix-suggest-import-ice, r…
workingjubilee Jul 12, 2024
6cdef05
Rollup merge of #127338 - Oneirical:ready-your-arbatests, r=jieyouxu
workingjubilee Jul 12, 2024
38c314e
Rollup merge of #127381 - Oneirical:testalt-consciousness, r=jieyouxu
workingjubilee Jul 12, 2024
2e0591b
Rollup merge of #127535 - spastorino:unsafe_code-unsafe_extern_blocks…
workingjubilee Jul 12, 2024
20cf4eb
Rollup merge of #127619 - compiler-errors:precise-capturing-better-su…
workingjubilee Jul 12, 2024
4bfc106
Rollup merge of #127631 - compiler-errors:yeet-fully-norm, r=lcnr
workingjubilee Jul 12, 2024
c0d9499
Rollup merge of #127632 - compiler-errors:precise-capturing-rustdoc, …
workingjubilee Jul 12, 2024
8f8734c
Rollup merge of #127660 - tgross35:const_strlen-rename, r=dtolnay
workingjubilee Jul 12, 2024
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
Prev Previous commit
Next Next commit
Fix import suggestion ice
  • Loading branch information
chenyukang committed Jul 4, 2024
commit fe5581dd31eb1b86c915e5c3eaae9ebfdea28037
10 changes: 5 additions & 5 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1989,12 +1989,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
if let Some(candidate) = candidates.get(0) {
let path = {
// remove the possible common prefix of the path
let start_index = (0..failed_segment_idx)
.find(|&i| path[i].ident != candidate.path.segments[i].ident)
let len = candidate.path.segments.len();
let start_index = (0..=failed_segment_idx.min(len - 1))
.find(|&i| path[i].ident.name != candidate.path.segments[i].ident.name)
.unwrap_or_default();
let segments = (start_index..=failed_segment_idx)
.map(|s| candidate.path.segments[s].clone())
.collect();
let segments =
(start_index..len).map(|s| candidate.path.segments[s].clone()).collect();
Path { segments, span: Span::default(), tokens: None }
};
(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
error[E0583]: file not found for module `config`
--> $DIR/suggest-import-ice-issue-127302.rs:3:1
|
LL | mod config;
| ^^^^^^^^^^^
|
= help: to create the module `config`, create file "$DIR/config.rs" or "$DIR/config/mod.rs"
= note: if there is a `mod config` elsewhere in the crate already, import it with `use crate::...` instead

error: format argument must be a string literal
--> $DIR/suggest-import-ice-issue-127302.rs:10:14
|
LL | println!(args.ctx.compiler.display());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: you might be missing a string literal to format with
|
LL | println!("{}", args.ctx.compiler.display());
| +++++

error[E0425]: cannot find value `args` in this scope
--> $DIR/suggest-import-ice-issue-127302.rs:6:12
|
LL | match &args.cmd {
| ^^^^ not found in this scope
|
help: consider importing this function
|
LL + use std::env::args;
|

error[E0532]: expected unit struct, unit variant or constant, found module `crate::config`
--> $DIR/suggest-import-ice-issue-127302.rs:7:9
|
LL | crate::config => {}
| ^^^^^^^^^^^^^ not a unit struct, unit variant or constant

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0425, E0532, E0583.
For more information about an error, try `rustc --explain E0425`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
error[E0583]: file not found for module `config`
--> $DIR/suggest-import-ice-issue-127302.rs:3:1
|
LL | mod config;
| ^^^^^^^^^^^
|
= help: to create the module `config`, create file "$DIR/config.rs" or "$DIR/config/mod.rs"
= note: if there is a `mod config` elsewhere in the crate already, import it with `use crate::...` instead

error: format argument must be a string literal
--> $DIR/suggest-import-ice-issue-127302.rs:10:14
|
LL | println!(args.ctx.compiler.display());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: you might be missing a string literal to format with
|
LL | println!("{}", args.ctx.compiler.display());
| +++++

error[E0425]: cannot find value `args` in this scope
--> $DIR/suggest-import-ice-issue-127302.rs:6:12
|
LL | match &args.cmd {
| ^^^^ not found in this scope
|
help: consider importing this function
|
LL + use std::env::args;
|

error[E0532]: expected unit struct, unit variant or constant, found module `crate::config`
--> $DIR/suggest-import-ice-issue-127302.rs:7:9
|
LL | crate::config => {}
| ^^^^^^^^^^^^^ not a unit struct, unit variant or constant

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0425, E0532, E0583.
For more information about an error, try `rustc --explain E0425`.
12 changes: 12 additions & 0 deletions tests/ui/imports/suggest-import-ice-issue-127302.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//@ revisions: edition2015 edition2021

mod config; //~ ERROR file not found for module

fn main() {
match &args.cmd { //~ ERROR cannot find value `args` in this scope
crate::config => {} //~ ERROR expected unit struct, unit variant or constant, found module `crate::config`
}

println!(args.ctx.compiler.display());
//~^ ERROR format argument must be a string literal
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0433]: failed to resolve: unresolved import
--> $DIR/suggest-import-issue-120074.rs:10:35
--> $DIR/suggest-import-issue-120074.rs:12:35
|
LL | println!("Hello, {}!", crate::bar::do_the_thing);
| ^^^ unresolved import
Expand Down
23 changes: 23 additions & 0 deletions tests/ui/imports/suggest-import-issue-120074.edition2021.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
error[E0433]: failed to resolve: unresolved import
--> $DIR/suggest-import-issue-120074.rs:12:35
|
LL | println!("Hello, {}!", crate::bar::do_the_thing);
| ^^^ unresolved import
|
help: a similar path exists
|
LL | println!("Hello, {}!", crate::foo::bar::do_the_thing);
| ~~~~~~~~
help: consider importing this module
|
LL + use foo::bar;
|
help: if you import `bar`, refer to it directly
|
LL - println!("Hello, {}!", crate::bar::do_the_thing);
LL + println!("Hello, {}!", bar::do_the_thing);
|

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0433`.
2 changes: 2 additions & 0 deletions tests/ui/imports/suggest-import-issue-120074.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ revisions: edition2015 edition2021

pub mod foo {
pub mod bar {
pub fn do_the_thing() -> usize {
Expand Down
Loading