Commit Graph

13205 Commits

Author SHA1 Message Date
Miguel Guarniz
2e98879403 change back to using tcx.hir() visit-item method
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
f975d05116 rename visit item-like methods
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
7e44078e9a update comments about visitor strategy
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
93616dd539 remove ItemLikeVisitor and DeepVisitor
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
0b7dd95475 remove HirVisitor
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
885b90bb34 remove DebuggerVisualizerCollector
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
cdba1dcef6 add module_items
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
e166409f0d remove Visitor impl for PrivateItemsInPublicInterfacesChecker
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
e8ef5bf464 remove TraitVisitor
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
eea16de9f7 replace hir().def_kind for def_kind query in rustc_passes
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:05 -04:00
Miguel Guarniz
90685c6333 check def_kind before fetching item
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:05 -04:00
Miguel Guarniz
0a029e2ed0 remove CollectPrivateImplItemsVisitor
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:05 -04:00
Miguel Guarniz
45c37da0f7 remove LayoutTest
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:05 -04:00
Miguel Guarniz
0ef16feb72 remove OuterVisitor
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:05 -04:00
Miguel Guarniz
b1f0209cd1 optimize find_item to fetch Item only when needed
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:05 -04:00
Miguel Guarniz
fb73ae2c8a remove ItemLikeVisitor impl for EntryContext
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:05 -04:00
Miguel Guarniz
dab0e75911 remove DiagnosticItemCollector
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:05 -04:00
Miguel Guarniz
52f833a254 remove LifeSeeder
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:05 -04:00
Miguel Guarniz
00260347e3 replace usage of visit_item_likes_in_modules with hir_module_items query
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:05 -04:00
Miguel Guarniz
bd2b210c59 Remove CheckConstTraitVisitor
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:05 -04:00
bors
a7d6408b05 Auto merge of #96899 - oli-obk:closure_wf_check_bounds, r=nikomatsakis
Check that closures satisfy their where bounds

fixes https://github.com/rust-lang/rust/issues/53092
fixes https://github.com/rust-lang/rust/issues/90409

based on https://github.com/rust-lang/rust/pull/96736
2022-05-13 11:18:01 +00:00
Oli Scherer
7a4ac84a90 For non-defining opaque type usage errors, don't try to also prove all trait bounds 2022-05-13 10:09:11 +00:00
Oli Scherer
253408b409 Check that closures satisfy their where bounds 2022-05-13 10:09:11 +00:00
bors
1c80ac003b Auto merge of #96930 - ayrtonm:mips32-tmp-file, r=petrochenkov
Fix e_flags for 32-bit MIPS targets in generated object file

In #95604 the compiler started generating a temporary symbols.o which is added to the linker invocation. This object file has an `e_flags` which is invalid for 32-bit MIPS targets. Even though symbols.o doesn't contain code, linking these targets with [lld fails](https://github.com/llvm/llvm-project/blob/main/lld/ELF/Arch/MipsArchTree.cpp#L76-L79) with
```
rust-lld: error: foo-cgu.0.rcgu.o: ABI 'o32' is incompatible with target ABI 'n64'
```
because it omits the ABI bits (`EF_MIPS_ABI_O32`) so lld assumes it's using the N64 ABI. This breaks linking on nightly for the out-of-tree [mipsel-sony-psx target](https://github.com/ayrtonm/psx-sdk-rs/issues/9), the builtin mipsel-sony-psp target (cc `@overdrivenpotato)` and probably any other 32-bit MIPS target using lld.

This PR sets the ABI in `e_flags` to O32 since that's the only ABI for 32-bit MIPS that LLVM supports. It also sets other `e_flags` bits based on the target to avoid similar issues with the object file arch and PIC. I had to bump the object crate version since some of these constants were [added recently](https://github.com/gimli-rs/object/pull/433). I'm not sure if this PR needs a test, but I can confirm that it fixes the linking issue on both targets I mentioned.
2022-05-13 08:48:31 +00:00
bors
97d48bec2d Auto merge of #96965 - oli-obk:flaky_inliner_ice, r=cjgillot
Gracefully handle normalization failures in the prospective inliner cycle detector

Preliminary work for adding the regression test in #96950 to our test suite (it was flaky on glacier).

If this PR solves the flakiness on glacier, we can then merge #96950
2022-05-13 06:20:56 +00:00
Matthias Krüger
f2100daf32
Rollup merge of #96989 - cjgillot:defpath-use, r=davidtwco
Be more precise than DefPathData::Misc.

This variant was used for two unrelated things. Let's make this cleaner.
2022-05-13 05:33:13 +02:00
Camille GILLOT
ecbda428ec Correct comment. 2022-05-12 20:16:11 +02:00
Camille GILLOT
dde7bff574 Replace DefPathData::Misc by two appropriately-named variants. 2022-05-12 20:12:35 +02:00
bors
c6499fd998 Auto merge of #96974 - matthiaskrgr:rollup-jd4otnc, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #95896 (Note the contacts for the nvptx64 target(s))
 - #96860 (openbsd: convert futex timeout managment to Timespec usage)
 - #96939 (Fix settings page CSS)
 - #96941 (update graphviz links)
 - #96968 (Add tests for #96806)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-12 15:07:35 +00:00
Matthias Krüger
47e4c9efdc
Rollup merge of #96941 - nannany:master, r=lcnr,JohnTitor
update graphviz links

Update graphviz links.
2022-05-12 16:41:05 +02:00
bors
481db40311 Auto merge of #95562 - lcnr:attr-no-encode, r=davidtwco
don't encode only locally used attrs

Part of https://github.com/rust-lang/compiler-team/issues/505.

We now filter builtin attributes before encoding them in the crate metadata in case they should only be used in the local crate. To prevent accidental misuse `get_attrs` now requires the caller to state which attribute they are interested in. For places where that isn't trivially possible, I've added a method `fn get_attrs_unchecked` which I intend to remove in a followup PR.

After this pull request landed, we can then slowly move all attributes to only be used in the local crate while being certain that we don't accidentally try to access them from extern crates.

cc https://github.com/rust-lang/rust/pull/94963#issuecomment-1082924289
2022-05-12 12:48:30 +00:00
bors
18bd2dd5cd Auto merge of #96853 - davidtwco:diagnostic-translation-unit-and-more-porting, r=oli-obk
diagnostics: port more diagnostics to derive + support for `()` fields

- Extend diagnostic derive so that spanless subdiagnostics (e.g. some uses of `help`/`note`) can be applied via attributes to fields of type `()` (currently spanless subdiagnostics are applied via attributes on the diagnostic struct itself). A consequence of this is that `Option<()>` fields can be used to represent optional spanless subdiagnostics, which are sometimes useful (e.g. for a `help` that should only show on nightly builds).
- Simplify the "explicit generic args with impl trait" diagnostic struct (from #96760) using support for `Option<()>` spanless subdiagnostics.
- Change `DiagnosticBuilder::set_arg`, used to provide context for Fluent messages, so that it takes anything that implements `IntoDiagnosticArg`, rather than `DiagnosticArgValue` - this improves the ergonomics of manual implementations of `SessionDiagnostic` which are translatable.
- Port "the type parameter `T` must be explicitly specified", "manual implementations of `X` are experimental", "could not resolve substs on overridden impl" diagnostics to diagnostic structs.
- When testing macros from `rustc_macros` in `ui-fulldeps` tests, sometimes paths from the compiler source tree can be shown in error messages - these need to be normalized in `compiletest`.

r? `@oli-obk`
cc `@pvdrz`
2022-05-12 10:22:07 +00:00
Oli Scherer
e02129fec0 Use IndexSet for deterministic order 2022-05-12 10:03:41 +00:00
minami.yoshihiko
2c604f63fc update graphviz links
add subdomain
2022-05-12 18:31:42 +09:00
Oli Scherer
af0a464311 Gracefully handle normalization failures in the prospective inliner cycle detector 2022-05-12 08:22:36 +00:00
bors
4f8e2e3ad9 Auto merge of #96940 - TaKO8Ki:stop-suggesting-wrong-fully-qualified-path, r=estebank
Stop suggesting non-existing fully qualified paths

This patch fixes a part of #96295.

r? `@estebank`
2022-05-12 07:44:31 +00:00
David Wood
47582471c6 typeck: port "no resolve overridden impl substs"
Port "could not resolve substs on overridden impl" diagnostic to use the
diagnostic derive.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-05-12 07:21:51 +01:00
David Wood
664733efd5 typeck: port "manual implementations"
Port the "manual implementations of `X` are experimental" diagnostic to
use the diagnostic derive.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-05-12 07:21:51 +01:00
David Wood
78cc331bd7 typeck: port "missing type params"
Port the "the type parameter `T` must be explicitly specified"
diagnostic to using a diagnostic struct.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-05-12 07:21:51 +01:00
David Wood
de3e8ca2f3 errors: set_arg takes IntoDiagnosticArg
Manual implementors of translatable diagnostics will need to call
`set_arg`, not just the derive, so make this function a bit more
ergonomic by taking `IntoDiagnosticArg` rather than
`DiagnosticArgValue`.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-05-12 07:21:51 +01:00
David Wood
5685abc96b typeck: simplify error type using () field
Using new support for spanless subdiagnostics from `()` fields in the
diagnostic derive, simplify the "explicit generic args with impl trait"
diagnostic's struct.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-05-12 07:21:51 +01:00
David Wood
7b7061dd89 macros: spanless subdiagnostics from () fields
Type attributes could previously be used to support spanless
subdiagnostics but these couldn't easily be made optional in the same
way that spanned subdiagnostics could by using a field attribute on a
field with an `Option<Span>` type. Spanless subdiagnostics can now be
specified on fields with `()` type or `Option<()>` type.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-05-12 07:21:51 +01:00
bors
3a08bd7873 Auto merge of #96889 - Aaron1011:place-ref-remove, r=compiler-errors
Remove `PartialOrd`/`Ord` impl for `PlaceRef`

This is a new attempt at #93315. It removes one usage
of the `Ord` impl for `DefId`, which should make it easier
to eventually remove that impl.
2022-05-12 05:03:48 +00:00
bors
1d2ea98cff Auto merge of #95837 - scottmcm:ptr-offset-from-unsigned, r=oli-obk
Add `sub_ptr` on pointers (the `usize` version of `offset_from`)

We have `add`/`sub` which are the `usize` versions of `offset`, this adds the `usize` equivalent of `offset_from`.  Like how `.add(d)` replaced a whole bunch of `.offset(d as isize)`, you can see from the changes here that it's fairly common that code actually knows the order between the pointers and *wants* a `usize`, not an `isize`.

As a bonus, this can do `sub nuw`+`udiv exact`, rather than `sub`+`sdiv exact`, which can be optimized slightly better because it doesn't have to worry about negatives.  That's why the slice iterators weren't using `offset_from`, though I haven't updated that code in this PR because slices are so perf-critical that I'll do it as its own change.

This is an intrinsic, like `offset_from`, so that it can eventually be allowed in CTFE.  It also allows checking the extra safety condition -- see the test confirming that CTFE catches it if you pass the pointers in the wrong order.
2022-05-12 02:49:00 +00:00
Scott McMurray
003b954a43 Apply CR suggestions; add real tracking issue 2022-05-11 17:16:25 -07:00
Scott McMurray
4bb15b3797 Add a debug check for ordering, and check for isize overflow in CTFE 2022-05-11 17:16:25 -07:00
Scott McMurray
e76b3f3b5b Rename unsigned_offset_from to sub_ptr 2022-05-11 17:16:25 -07:00
Scott McMurray
89a18cb600 Add unsigned_offset_from on pointers
Like we have `add`/`sub` which are the `usize` version of `offset`, this adds the `usize` equivalent of `offset_from`.  Like how `.add(d)` replaced a whole bunch of `.offset(d as isize)`, you can see from the changes here that it's fairly common that code actually knows the order between the pointers and *wants* a `usize`, not an `isize`.

As a bonus, this can do `sub nuw`+`udiv exact`, rather than `sub`+`sdiv exact`, which can be optimized slightly better because it doesn't have to worry about negatives.  That's why the slice iterators weren't using `offset_from`, though I haven't updated that code in this PR because slices are so perf-critical that I'll do it as its own change.

This is an intrinsic, like `offset_from`, so that it can eventually be allowed in CTFE.  It also allows checking the extra safety condition -- see the test confirming that CTFE catches it if you pass the pointers in the wrong order.
2022-05-11 17:16:25 -07:00
bors
0cd939e36c Auto merge of #96150 - est31:unused_macro_rules, r=petrochenkov
Implement a lint to warn about unused macro rules

This implements a new lint to warn about unused macro rules (arms/matchers), similar to the `unused_macros` lint added by #41907 that warns about entire macros.

```rust
macro_rules! unused_empty {
    (hello) => { println!("Hello, world!") };
    () => { println!("empty") }; //~ ERROR: 1st rule of macro `unused_empty` is never used
}

fn main() {
    unused_empty!(hello);
}
```

Builds upon #96149 and #96156.

Fixes #73576
2022-05-12 00:08:08 +00:00
bors
cb9cb4d4e1 Auto merge of #96806 - cjgillot:codegen-fulfill-nice, r=oli-obk
Gracefully fail to resolve associated items instead of `delay_span_bug`.

`codegen_fulfill_obligation` is used during instance resolution for trait items.

In case of insufficient normalization issues during MIR inlining, it caused ICEs.
It's better to gracefully refuse to resolve the associated item, and let the caller decide what to do with this.

Split from https://github.com/rust-lang/rust/pull/91743
Closes #69121
Closes #73021
Closes #88599
Closes #93008
Closes #93248
Closes #94680
Closes #96170
r? `@oli-obk`
2022-05-11 21:39:02 +00:00