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 8 pull requests #125689

Closed
wants to merge 25 commits into from
Closed
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
ac59bdc
Add `--print=check-cfg` to get the expected configs
Urgau Apr 22, 2024
8693064
miri: avoid making a full copy of all new allocations
RalfJung May 27, 2024
d9d013b
rewrite lto-smoke to rmake
Oneirical May 28, 2024
634270e
rewrite mixing-deps in rmake
Oneirical May 28, 2024
b119e42
Add run-make-support to x doc
ChrisDenton May 28, 2024
ef9e6ca
Fix run-make-support doc errors
ChrisDenton May 28, 2024
d82be82
Enable a few tests on macOS
madsmtm May 27, 2024
37ae2b6
Disable stack overflow handler tests on iOS-like platforms
madsmtm May 16, 2024
e6b9bb7
Make more of the test suite run on Mac Catalyst
madsmtm May 27, 2024
37c54db
Silence some resolve errors when there have been glob import errors
estebank May 21, 2024
89f3651
Get rid of manual Trace calls
compiler-errors May 28, 2024
cc97376
Rewrite simple-rlib to rmake
Oneirical May 28, 2024
2bd5050
Remove Trace
compiler-errors May 28, 2024
459ce3f
Add an intrinsic for `ptr::metadata`
scottmcm Apr 21, 2024
7150839
Add custom mir support for `PtrMetadata`
scottmcm May 25, 2024
5a8c1f3
Add Miri tests for `PtrMetadata` UB
scottmcm May 26, 2024
57948c8
Add Miri smoke pass test for ptr_metadata intrinsic
scottmcm May 27, 2024
7c82b4d
Rollup merge of #124251 - scottmcm:unop-ptr-metadata, r=oli-obk
jieyouxu May 28, 2024
ddcc5bd
Rollup merge of #124320 - Urgau:print-check-cfg, r=petrochenkov
jieyouxu May 28, 2024
c7b4ddd
Rollup merge of #125226 - madsmtm:fix-mac-catalyst-tests, r=workingju…
jieyouxu May 28, 2024
7c4faa0
Rollup merge of #125381 - estebank:issue-96799, r=petrochenkov
jieyouxu May 28, 2024
dcd5d7e
Rollup merge of #125633 - RalfJung:miri-no-copy, r=saethlin
jieyouxu May 28, 2024
0425153
Rollup merge of #125638 - Oneirical:lets-find-some-tests, r=jieyouxu
jieyouxu May 28, 2024
2fcf99c
Rollup merge of #125639 - ChrisDenton:run-make-support-doc, r=onur-ozkan
jieyouxu May 28, 2024
093791c
Rollup merge of #125664 - compiler-errors:trace-tweaks, r=lcnr
jieyouxu May 28, 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
22 changes: 15 additions & 7 deletions compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
let determined_imports = mem::take(&mut self.determined_imports);
let indeterminate_imports = mem::take(&mut self.indeterminate_imports);

let mut glob_error = false;
for (is_indeterminate, import) in determined_imports
.iter()
.map(|i| (false, i))
Expand All @@ -548,6 +549,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
self.import_dummy_binding(*import, is_indeterminate);

if let Some(err) = unresolved_import_error {
glob_error |= import.is_glob();

if let ImportKind::Single { source, ref source_bindings, .. } = import.kind {
if source.name == kw::SelfLower {
// Silence `unresolved import` error if E0429 is already emitted
Expand All @@ -563,7 +566,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
{
// In the case of a new import line, throw a diagnostic message
// for the previous line.
self.throw_unresolved_import_error(errors);
self.throw_unresolved_import_error(errors, glob_error);
errors = vec![];
}
if seen_spans.insert(err.span) {
Expand All @@ -574,7 +577,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}

if !errors.is_empty() {
self.throw_unresolved_import_error(errors);
self.throw_unresolved_import_error(errors, glob_error);
return;
}

Expand All @@ -600,9 +603,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}
}

if !errors.is_empty() {
self.throw_unresolved_import_error(errors);
}
self.throw_unresolved_import_error(errors, glob_error);
}

pub(crate) fn check_hidden_glob_reexports(
Expand Down Expand Up @@ -672,7 +673,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}
}

fn throw_unresolved_import_error(&mut self, errors: Vec<(Import<'_>, UnresolvedImportError)>) {
fn throw_unresolved_import_error(
&mut self,
errors: Vec<(Import<'_>, UnresolvedImportError)>,
glob_error: bool,
) {
if errors.is_empty() {
return;
}
Expand Down Expand Up @@ -751,7 +756,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}
}

diag.emit();
let guar = diag.emit();
if glob_error {
self.glob_error = Some(guar);
}
}

/// Attempts to resolve the given import, returning:
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4033,9 +4033,12 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
}

#[inline]
/// If we're actually rustdoc then avoid giving a name resolution error for `cfg()` items.
/// If we're actually rustdoc then avoid giving a name resolution error for `cfg()` items or
// an invalid `use foo::*;` was found, which can cause unbounded ammounts of "item not found"
// errors. We silence them all.
fn should_report_errs(&self) -> bool {
!(self.r.tcx.sess.opts.actually_rustdoc && self.in_func_body)
&& !self.r.glob_error.is_some()
}

// Resolve in alternative namespaces if resolution in the primary namespace fails.
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
use rustc_data_structures::intern::Interned;
use rustc_data_structures::steal::Steal;
use rustc_data_structures::sync::{FreezeReadGuard, Lrc};
use rustc_errors::{Applicability, Diag, ErrCode};
use rustc_errors::{Applicability, Diag, ErrCode, ErrorGuaranteed};
use rustc_expand::base::{DeriveResolution, SyntaxExtension, SyntaxExtensionKind};
use rustc_feature::BUILTIN_ATTRIBUTES;
use rustc_hir::def::Namespace::{self, *};
Expand Down Expand Up @@ -1048,6 +1048,7 @@ pub struct Resolver<'a, 'tcx> {

/// Maps glob imports to the names of items actually imported.
glob_map: FxHashMap<LocalDefId, FxHashSet<Symbol>>,
glob_error: Option<ErrorGuaranteed>,
visibilities_for_hashing: Vec<(LocalDefId, ty::Visibility)>,
used_imports: FxHashSet<NodeId>,
maybe_unused_trait_imports: FxIndexSet<LocalDefId>,
Expand Down Expand Up @@ -1417,6 +1418,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
ast_transform_scopes: FxHashMap::default(),

glob_map: Default::default(),
glob_error: None,
visibilities_for_hashing: Default::default(),
used_imports: FxHashSet::default(),
maybe_unused_trait_imports: Default::default(),
Expand Down
12 changes: 12 additions & 0 deletions tests/ui/imports/import-from-missing-star-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
mod foo {
use spam::*; //~ ERROR unresolved import `spam` [E0432]
}

fn main() {
// Expect this to pass because the compiler knows there's a failed `*` import in `foo` that
// might have caused it.
foo::bar();
// FIXME: these two should *fail* because they can't be fixed by fixing the glob import in `foo`
ham(); // should error but doesn't
eggs(); // should error but doesn't
}
11 changes: 11 additions & 0 deletions tests/ui/imports/import-from-missing-star-2.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0432]: unresolved import `spam`
--> $DIR/import-from-missing-star-2.rs:2:9
|
LL | use spam::*;
| ^^^^ maybe a missing crate `spam`?
|
= help: consider adding `extern crate spam` to use the `spam` crate

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0432`.
43 changes: 43 additions & 0 deletions tests/ui/imports/import-from-missing-star-3.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
mod foo {
use spam::*; //~ ERROR unresolved import `spam` [E0432]

fn x() {
// Expect these to pass because the compiler knows there's a failed `*` import that might
// fix it.
eggs();
foo::bar();
}
}

mod bar {
fn z() {}
fn x() {
// Expect these to pass because the compiler knows there's a failed `*` import that might
// fix it.
foo::bar();
z();
// FIXME: should error but doesn't because as soon as there's a single glob import error, we
// silence all resolve errors.
eggs();
}
}

mod baz {
fn x() {
use spam::*; //~ ERROR unresolved import `spam` [E0432]
fn qux() {}
qux();
// Expect this to pass because the compiler knows there's a local failed `*` import that
// might have caused it.
eggs();
// Expect this to pass because the compiler knows there's a failed `*` import in `foo` that
// might have caused it.
foo::bar();
}
}

fn main() {
// FIXME: should error but doesn't because as soon as there's a single glob import error, we
// silence all resolve errors.
ham();
}
19 changes: 19 additions & 0 deletions tests/ui/imports/import-from-missing-star-3.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0432]: unresolved import `spam`
--> $DIR/import-from-missing-star-3.rs:2:9
|
LL | use spam::*;
| ^^^^ maybe a missing crate `spam`?
|
= help: consider adding `extern crate spam` to use the `spam` crate

error[E0432]: unresolved import `spam`
--> $DIR/import-from-missing-star-3.rs:27:13
|
LL | use spam::*;
| ^^^^ maybe a missing crate `spam`?
|
= help: consider adding `extern crate spam` to use the `spam` crate

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0432`.
10 changes: 10 additions & 0 deletions tests/ui/imports/import-from-missing-star.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use spam::*; //~ ERROR unresolved import `spam` [E0432]

fn main() {
// Expect these to pass because the compiler knows there's a failed `*` import that might have
// caused it.
ham();
eggs();
// Even this case, as we might have expected `spam::foo` to exist.
foo::bar();
}
11 changes: 11 additions & 0 deletions tests/ui/imports/import-from-missing-star.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0432]: unresolved import `spam`
--> $DIR/import-from-missing-star.rs:1:5
|
LL | use spam::*;
| ^^^^ maybe a missing crate `spam`?
|
= help: consider adding `extern crate spam` to use the `spam` crate

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0432`.
2 changes: 1 addition & 1 deletion tests/ui/imports/issue-31212.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mod foo {
}

fn main() {
foo::f(); //~ ERROR cannot find function `f` in module `foo`
foo::f(); // cannot find function `f` in module `foo`, but silenced
}
11 changes: 2 additions & 9 deletions tests/ui/imports/issue-31212.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ error[E0432]: unresolved import `self::*`
LL | pub use self::*;
| ^^^^^^^ cannot glob-import a module into itself

error[E0425]: cannot find function `f` in module `foo`
--> $DIR/issue-31212.rs:9:10
|
LL | foo::f();
| ^ not found in `foo`

error: aborting due to 2 previous errors
error: aborting due to 1 previous error

Some errors have detailed explanations: E0425, E0432.
For more information about an error, try `rustc --explain E0425`.
For more information about this error, try `rustc --explain E0432`.