Commit Graph

72 Commits

Author SHA1 Message Date
bohan 93feaa6685 mark binding undetermined if target name exist and not obtained 2024-06-07 21:23:56 +08:00
bohan f67a0eb2b7 resolve: mark it undetermined if single import is not has any bindings 2024-06-04 12:40:41 +08:00
Oneirical 8c8d0db02d rewrite and rename issue-37893 to rmake 2024-05-29 11:38:47 -04:00
Oneirical 22953b3f52 convert simple-dylib to ui test 2024-05-29 11:34:39 -04:00
许杰友 Jieyou Xu (Joe) 7e93a632a8
Rollup merge of #125638 - Oneirical:lets-find-some-tests, r=jieyouxu
Rewrite `lto-smoke`, `simple-rlib` and `mixing-deps` `run-make` tests in `rmake.rs` format

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).
2024-05-29 03:25:10 +01:00
许杰友 Jieyou Xu (Joe) bc1a069ec5
Rollup merge of #125381 - estebank:issue-96799, r=petrochenkov
Silence some resolve errors when there have been glob import errors

When encountering `use foo::*;` where `foo` fails to be found, and we later encounter resolution errors, we silence those later errors.

A single case of the above, for an *existing* import on a big codebase would otherwise have a huge number of knock-down spurious errors.

Ideally, instead of a global flag to silence all subsequent resolve errors, we'd want to introduce an unnameable binding in the appropriate rib as a sentinel when there's a failed glob import, so when we encounter a resolve error we can search for that sentinel and if found, and only then, silence that error. The current approach is just a quick proof of concept to iterate over.

Partially address #96799.
2024-05-29 03:25:08 +01:00
Oneirical cc97376ade Rewrite simple-rlib to rmake 2024-05-28 11:41:53 -04:00
Esteban Küber 37c54db477 Silence some resolve errors when there have been glob import errors
When encountering `use foo::*;` where `foo` fails to be found, and we later
encounter resolution errors, we silence those later errors.

A single case of the above, for an *existing* import on a big codebase would
otherwise have a huge number of knock-down spurious errors.

Ideally, instead of a global flag to silence all subsequent resolve errors,
we'd want to introduce an unameable binding in the appropriate rib as a
sentinel when there's a failed glob import, so when we encounter a resolve
error we can search for that sentinel and if found, and only then, silence
that error. The current approach is just a quick proof of concept to
iterate over.

Partially address #96799.
2024-05-28 14:45:21 +00:00
Ben Kimock 18b0a07d49 Handle a few more simple tests 2024-05-20 11:13:10 -04:00
Urgau d4e26fbb53 compiletest: add enable-by-default check-cfg 2024-05-04 11:30:38 +02:00
klensy 411607bec4 tests: remove some trailing ws 2024-04-27 10:54:31 +03:00
Michael Goulet 0db2a4010a Silence unused_imports lint for redundant imports 2024-04-11 14:38:21 -04:00
León Orell Valerian Liehr ccab2b16d3
Rollup merge of #122954 - fmease:defined-by-extern-prelude, r=petrochenkov
Be more specific when flagging imports as redundant due to the extern prelude

There are multiple distinct kinds of [preludes](https://doc.rust-lang.org/reference/names/preludes.html). Be more specific when flagging imports as redundant due to the [extern prelude](https://doc.rust-lang.org/reference/names/preludes.html#extern-prelude).

r? Nilstrieb or compiler
2024-04-11 01:56:24 +02:00
León Orell Valerian Liehr 8a24ddf64b
Be more specific when flagging imports that are redundant due to the extern prelude 2024-04-08 17:34:06 +02:00
Urgau c4a97d9407 Unify all the always-false cfgs under the `FALSE` cfg 2024-04-07 01:16:45 +02:00
bors aa029ce4d8 Auto merge of #122113 - matthiaskrgr:rollup-5d1jnwi, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #121958 (Fix redundant import errors for preload extern crate)
 - #121976 (Add an option to have an external download/bootstrap cache)
 - #122022 (loongarch: add frecipe and relax target feature)
 - #122026 (Do not try to format removed files)
 - #122027 (Uplift some feeding out of `associated_type_for_impl_trait_in_impl` and into queries)
 - #122063 (Make the lowering of `thir::ExprKind::If` easier to follow)
 - #122074 (Add missing PartialOrd trait implementation doc for array)
 - #122082 (remove outdated fixme comment)
 - #122091 (Note why we're using a new thread in `test_get_os_named_thread`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-07 02:30:40 +00:00
yukang 5a4ff2779e Fix redundant import errors for preload extern crate 2024-03-06 21:29:33 +08:00
bohan 7303014381 avoid overlapping privacy suggestion for single nested imports 2024-03-06 21:17:12 +08:00
Matthias Krüger 152b69054c
Rollup merge of #121846 - bvanjoi:fix-121760, r=petrochenkov
only compare ambiguity item that have hard error

Fixes #121760

An easy fix, r? ``@petrochenkov``
2024-03-05 19:53:20 +01:00
Matthias Krüger 3c89280684
Rollup merge of #120305 - clubby789:unused-import-line, r=estebank
Delete line if suggestion would replace it with an empty line

Fixes #120296
2024-03-01 22:38:45 +01:00
Matthias Krüger 58825b4ea9
Rollup merge of #121580 - Suyashtnt:issue-121502-fix, r=michaelwoerister
make unused_imports less assertive in test modules

closes #121502

This is a fairly small change and I used the fix suggested in the example expected error message.
Not sure if I should've rather used the alternatives but this one seems the most descriptive.

Some alternatives:
- if this is meant to be a test module, add `#[cfg(test)]` to the containing module
- try adding #[cfg(test)] to this test module
- consider adding #[allow(unused_imports)] if you want to silent the lint on the unused import
- consider removing the unused import
2024-03-01 17:51:29 +01:00
clubby789 367126d49a If suggestion would leave an empty line, delete it 2024-03-01 13:48:20 +00:00
bohan 89954e55e1 only compare ambiguity item that have hard error 2024-03-01 19:41:46 +08:00
Guillaume Gomez c5dafe66ba
Rollup merge of #121226 - chenyukang:yukang-fix-import-alias, r=davidtwco
Fix issues in suggesting importing extern crate paths

Fixes #121168

r? ``@petrochenkov``
2024-02-28 16:04:49 +01:00
bors b0d3e04ca9 Auto merge of #120393 - Urgau:rfc3373-non-local-defs, r=WaffleLapkin
Implement RFC 3373: Avoid non-local definitions in functions

This PR implements [RFC 3373: Avoid non-local definitions in functions](https://github.com/rust-lang/rust/issues/120363).
2024-02-25 19:11:06 +00:00
Suyashtnt 748c6151be
make unused_imports less assertive in test modules
closes #121502
2024-02-25 09:37:57 +02:00
yukang 3bcef2dc1b Fix issues in suggesting importing extern crate paths 2024-02-25 11:29:13 +08:00
Esteban Küber caa216d245 Tweak wording of "implemented trait isn't imported" suggestion 2024-02-22 18:05:27 +00:00
Urgau 80c81c53ac Allow newly added non_local_definitions lint in tests 2024-02-17 13:59:45 +01:00
许杰友 Jieyou Xu (Joe) ec2cc761bc
[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
Vadim Petrochenkov 8b6b9c5efc ast_lowering: Fix regression in `use ::{}` imports. 2024-02-09 20:17:48 +03:00
Nicholas Nethercote 4225a1e186 Don't hash lints differently to non-lints.
`Diagnostic::keys`, which is used for hashing and equating diagnostics,
has a surprising behaviour: it ignores children, but only for lints.
This was added in #88493 to fix some duplicated diagnostics, but it
doesn't seem necessary any more.

This commit removes the special case and only four tests have changed
output, with additional errors. And those additional errors aren't
exact duplicates, they're just similar. For example, in
src/tools/clippy/tests/ui/same_name_method.rs we currently have this
error:
```
error: method's name is the same as an existing method in a trait
  --> $DIR/same_name_method.rs:75:13
   |
LL |             fn foo() {}
   |             ^^^^^^^^^^^
   |
note: existing `foo` defined here
  --> $DIR/same_name_method.rs:79:9
   |
LL |         impl T1 for S {}
   |         ^^^^^^^^^^^^^^^^
```
and with this change we also get this error:
```
error: method's name is the same as an existing method in a trait
  --> $DIR/same_name_method.rs:75:13
   |
LL |             fn foo() {}
   |             ^^^^^^^^^^^
   |
note: existing `foo` defined here
  --> $DIR/same_name_method.rs:81:9
   |
LL |         impl T2 for S {}
   |         ^^^^^^^^^^^^^^^^
```
I think printing this second argument is reasonable, possibly even
preferable to hiding it. And the other cases are similar.
2024-01-31 08:25:29 +11:00
yukang 492df34eea Supress unhelpful diagnostics for unresolved top level attributes 2024-01-29 17:43:07 +08:00
bohan 851d4c4e24 add several resolution test cases 2024-01-24 00:01:59 +08:00
bohan 9c3091e9cf exclude unexported macro bindings from extern crate 2024-01-21 20:24:40 +08:00
George-lewis d56cdd48cb Bless tests
Update tests
2024-01-13 12:46:58 -05:00
Esteban Küber beaf31581a Structured `use` suggestion on privacy error
When encoutering a privacy error on an item through a re-export that is
accessible in an alternative path, provide a structured suggestion with
that path.

```
error[E0603]: module import `mem` is private
  --> $DIR/private-std-reexport-suggest-public.rs:4:14
   |
LL |     use foo::mem;
   |              ^^^ private module import
   |
note: the module import `mem` is defined here...
  --> $DIR/private-std-reexport-suggest-public.rs:8:9
   |
LL |     use std::mem;
   |         ^^^^^^^^
note: ...and refers to the module `mem` which is defined here
  --> $SRC_DIR/std/src/lib.rs:LL:COL
   |
   = note: you could import this
help: import `mem` through the re-export
   |
LL |     use std::mem;
   |         ~~~~~~~~
```

Fix #42909.
2023-12-04 22:26:08 +00:00
bohan d0941f92d7 vis note for no pub reexports glob import 2023-12-01 12:10:07 +08:00
Nilstrieb 41e8d152dc Show number in error message even for one error
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-24 19:15:52 +01:00
Esteban Küber 27919ceba7 Tweak suggestion spans for invalid crate-level inner attribute
CC #89566.
2023-10-26 18:35:09 +00:00
Matthias Krüger 2a027faf68
Rollup merge of #117009 - fmease:diag-disambig-sugg-crate, r=b-naber
On unresolved imports, suggest a disambiguated path if necessary to avoid collision with local items

Fixes #116970.
2023-10-25 23:37:10 +02:00
bohan 482275b194 use visibility to check unused imports and delete some stmts 2023-10-22 21:27:46 +08:00
León Orell Valerian Liehr 4aaf8e03e1
on unresolved import disambiguate suggested path if it would collide 2023-10-21 15:40:32 +02:00
Alex Macleod 5453a9f34d Add a note to duplicate diagnostics 2023-10-05 01:04:41 +00:00
bohan f1536507e1 resolve: determined binding after parent module macro expand 2023-09-13 16:38:05 +08:00
bohan 107152141b fix(resolve): update def if binding is warning ambiguity 2023-08-31 20:00:04 +08:00
Nilstrieb ddda3fa0b0
Rollup merge of #114166 - Enselic:libc-unavailable, r=Nilstrieb
Add regression test for resolving `--extern libc=test.rlib`

Closes #26043

I could not find a test for this particular use case. The closest I got was [`tests/ui/imports/issue-37887.rs`](https://github.com/rust-lang/rust/blob/master/tests/ui/imports/issue-37887.rs), but that is a regression test for a different use case (see https://github.com/rust-lang/rust/issues/37887).
2023-08-02 13:46:54 +02:00
Matthias Krüger 2de51cce90
Rollup merge of #113920 - bvanjoi:fix-81413, r=petrochenkov
fix(resolve): report unresolved imports firstly

Fixes #81413

An easy fix, r? ```@petrochenkov```
2023-07-31 22:49:50 +02:00
Martin Nordholts 7dd5e3c1cd Add regression test for resolving `--extern libc=test.rlib`
I could not find a test for this particular use case. The closest I got
was `tests/ui/imports/issue-37887.rs`, but that is a regression test
for a different use case.
2023-07-29 08:51:17 +02:00
bohan cac0bd0bef fix(resolve): update the ambiguity glob binding as warning recursively 2023-07-29 00:19:50 +08:00