Commit Graph

209449 Commits

Author SHA1 Message Date
Guillaume Gomez
1123852d08 Fix merge of attributes for reexports of local items 2022-11-02 17:36:35 +01:00
yukang
7df9d818ab deprecate DelaySpanBugEmitted and use ErrorGuaranteed directly 2022-11-02 23:15:49 +08:00
Oli Scherer
ecea616052 Simplify astconv item def id handling 2022-11-02 12:03:59 +00:00
bors
c0a7612728 Auto merge of #103690 - GuillaumeGomez:visibility-on-demand, r=notriddle
Make rustdoc Item::visibility computed on-demand

This is a take-over of https://github.com/rust-lang/rust/pull/91408.

Helps with https://github.com/rust-lang/rust/issues/90852 (needs to use `ty::Visibility` directly too).

cc `@camelid`
r? `@notriddle`
2022-11-02 10:32:08 +00:00
viandoxdev
1bc2bfa44c
prevent open with json 2022-11-02 11:28:31 +01:00
viandoxdev
972d075aa6
merge JsonStd and Std steps 2022-11-02 11:23:42 +01:00
bors
822f8c22f5 Auto merge of #103649 - petrochenkov:docnotrait, r=GuillaumeGomez
rustdoc: Do not add external traits to the crate in `register_res`

It's not clear why it was done, and apparently it's no longer necessary now.
Such additions are unpredictable for early doc link resolution and would force us to collect all doc links from all external traits.

Fixes https://github.com/rust-lang/rust/issues/103463
2022-11-02 07:47:10 +00:00
Takayuki Maeda
b96ad1c096 return const_error when ty has errors 2022-11-02 14:47:48 +09:00
bors
a876a4df32 Auto merge of #103857 - Manishearth:rollup-709fui6, r=Manishearth
Rollup of 8 pull requests

Successful merges:

 - #103072 (compiletest: set the dylib path when gathering target cfg)
 - #103084 (Derive `Eq` and `Hash` for `ControlFlow`)
 - #103575 (Change #[suggestion_*] attributes to use style="...")
 - #103637 (Use stdio in UWP apps)
 - #103638 (Add `multivalue` target feature to WASM target)
 - #103781 (Detect unused files in `src/test/mir-opt` and error on them in tidy.)
 - #103837 (Migrate sidebar-links-color GUI test to functions)
 - #103839 (Print valid `--print` requests if request is invalid)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-11-02 04:27:48 +00:00
Michael Goulet
41e4218d2a Use TraitEngine less 2022-11-02 04:11:05 +00:00
Michael Goulet
5e016b8801 Remove some return-type booleans from FnCtxt 2022-11-02 02:03:09 +00:00
Michael Goulet
a9881f5213 Use ObligationCtxt in fully_normalize 2022-11-02 00:48:58 +00:00
Michael Goulet
20bb56ebfd Use codegen_select in vtable_trait_upcasting_coercion_new_vptr_slot 2022-11-02 00:39:08 +00:00
Manish Goregaokar
c2affd5049
Rollup merge of #103839 - Nilstrieb:print-list, r=compiler-errors
Print valid `--print` requests if request is invalid

When someone makes a typo, it can be useful to see the valid options. This is also useful if someone wants to find out about all the options.
2022-11-01 20:00:40 -04:00
Manish Goregaokar
617f246e21
Rollup merge of #103837 - GuillaumeGomez:migrate-sidebar-links-color-gui-test, r=notriddle
Migrate sidebar-links-color GUI test to functions

r? `@notriddle`
2022-11-01 20:00:40 -04:00
Manish Goregaokar
e2a6d283be
Rollup merge of #103781 - JakobDegen:mir-opt-tidy, r=jyn514
Detect unused files in `src/test/mir-opt` and error on them in tidy.

Closes #97564 .

Determining which files are generated by a given mir opt test is somewhat difficult. Because of this, we extract the logic for doing it out into a common crate that both compiletest and tidy can depend on. This avoids making compiletest a dependency of tidy which would negatively impact compile times for tidy.

Testing for this is that it catches 5 files that violated this lint (and removes them).
2022-11-01 20:00:39 -04:00
Manish Goregaokar
2cfab1f643
Rollup merge of #103638 - ia0:multivalue, r=nagisa
Add `multivalue` target feature to WASM target

This PR is similar to #99643 and #97808. It addresses #96472 for the `multivalue` target feature.

The problem I am trying to fix is to remove the following warning when compiling with `-C target-feature=+multivalue` for `--target=wasm32-unknown-unknown`.

```
warning: unknown feature specified for `-Ctarget-feature`: `multivalue`
  |
  = note: it is still passed through to the codegen backend
  = note: consider filing a feature request
```
2022-11-01 20:00:39 -04:00
Manish Goregaokar
65d63caf8d
Rollup merge of #103637 - ChrisDenton:stdio-uwp, r=thomcc
Use stdio in UWP apps

Fixes #103233

This has been supported since Windows 10.0.16299. See https://learn.microsoft.com/en-us/uwp/win32-and-com/win32-apis#apis-from-api-ms-win-core-console-l1-1-0dll
2022-11-01 20:00:38 -04:00
Manish Goregaokar
69e705564d
Rollup merge of #103575 - Xiretza:suggestions-style-attr, r=davidtwco
Change #[suggestion_*] attributes to use style="..."

As discussed [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20tool_only_span_suggestion), this changes `#[(multipart_)suggestion_{short,verbose,hidden}(...)]` attributes to plain `#[(multipart_)suggestion(...)]` attributes with a `style = "{short,verbose,hidden}"` parameter.

It also adds a new style, `tool-only`, that corresponds to `tool_only_span_suggestion`/`tool_only_multipart_suggestion` and causes the suggestion to not be shown in human-readable output at all.

Best reviewed commit-by-commit, there's a bit of noise in there.

cc #100717 `@compiler-errors`
r? `@davidtwco`
2022-11-01 20:00:38 -04:00
Manish Goregaokar
d4bd794f5e
Rollup merge of #103084 - inquisitivecrystal:control-flow, r=scottmcm
Derive `Eq` and `Hash` for `ControlFlow`

There's really no reason for `ControlFlow` not to derive these traits. This is the part of #96416 that no one objected to, but that PR seems stale. The `Eq` derive was also [requested](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/.60ControlFlow.3A.20Eq.60/near/303610659) by `@lcnr` on Zulip to allow for pattern matching.

This change requires an FCP because it's insta-stable.

Closes #96416.
2022-11-01 20:00:37 -04:00
Manish Goregaokar
3aae004281
Rollup merge of #103072 - cuviper:compiletest-path, r=Mark-Simulacrum
compiletest: set the dylib path when gathering target cfg

If the compiler is built with `rpath = false`, then it won't find its
own libraries unless the library search path is set. We already do that
while running the actual compiletests, but #100260 added another rustc
command for getting the target cfg.

    Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    thread 'main' panicked at 'error: failed to get cfg info from "[...]/build/x86_64-unknown-linux-gnu/stage1/bin/rustc"
    --- stdout

    --- stderr
    [...]/build/x86_64-unknown-linux-gnu/stage1/bin/rustc: error while loading shared libraries: librustc_driver-a2a76dc626cd02d2.so: cannot open shared object file: No such file or directory
    ', src/tools/compiletest/src/common.rs:476:13

Now the library path is set here as well, so it works without rpath.
2022-11-01 20:00:37 -04:00
Michael Howell
82c68cae18 rustdoc: simplify mobile item-table CSS
Using flexbox in column direction is needlessly complicated, since no
special flex powers are being used here. Just use regular block layout.

This should result in no visible changes.
2022-11-01 16:28:58 -07:00
Samuel Moelius
e604327286 Reorder walk_ functions in intravisit.rs 2022-11-01 19:02:45 -04:00
Zhixing Zhang
744fa610eb fix(generic_const_exprs): Fix predicate inheritance for children of opaque types 2022-11-01 15:41:16 -07:00
viandoxdev
ffd4078264
fix json running all the time 2022-11-01 22:18:19 +01:00
bors
11ebe6512b Auto merge of #103217 - mejrs:track, r=eholk
Track where diagnostics were created.

This implements the `-Ztrack-diagnostics` flag, which uses `#[track_caller]` to track where diagnostics are created. It is meant as a debugging tool much like `-Ztreat-err-as-bug`.

For example, the following code...

```rust
struct A;
struct B;

fn main(){
    let _: A = B;
}
```
...now emits the following error message:

```
error[E0308]: mismatched types
 --> src\main.rs:5:16
  |
5 |     let _: A = B;
  |            -   ^ expected struct `A`, found struct `B`
  |            |
  |            expected due to this
-Ztrack-diagnostics: created at compiler\rustc_infer\src\infer\error_reporting\mod.rs:2275:31
```
2022-11-01 21:09:45 +00:00
viandoxdev
6e1361f358
Fixes #103816 make --json work 2022-11-01 21:50:28 +01:00
Michael Goulet
e24df2778f Format dyn Trait better in type_name intrinsic 2022-11-01 20:41:47 +00:00
Guillaume Gomez
a1dfefaded Remove unneeded "rustdoc-preferred-dark-theme" setting 2022-11-01 19:47:12 +01:00
Guillaume Gomez
2024f70379 Migrate sidebar-links-color GUI test to functions 2022-11-01 19:46:42 +01:00
Jakub Beránek
f00d2c9c90
Revert "ci: Bring back ninja for dist builders" 2022-11-01 19:36:25 +01:00
bors
ab5a2bc731 Auto merge of #103841 - Dylan-DPC:rollup-rff2x1l, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #84022 (Make PROC_MACRO_DERIVE_RESOLUTION_FALLBACK a hard error)
 - #103760 (resolve: Turn the binding from `#[macro_export]` into a proper `Import`)
 - #103813 (rustdoc: remove unnecessary CSS `.search-results { clear: both }`)
 - #103817 (rustdoc: rename syntax highlighting CSS class `attribute` to `attr`)
 - #103833 (⬆️ rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-11-01 18:15:32 +00:00
Cameron Steffen
10a5e75537 Add track_caller to some Lock methods 2022-11-01 12:28:14 -05:00
Dylan DPC
2b10891b96
Rollup merge of #103833 - lnicola:rust-analyzer-2022-11-01, r=lnicola
⬆️ rust-analyzer

r? `@ghost`
2022-11-01 22:01:37 +05:30
Dylan DPC
2b0ead3126
Rollup merge of #103817 - notriddle:notriddle/attribute-css, r=GuillaumeGomez
rustdoc: rename syntax highlighting CSS class `attribute` to `attr`

Link classes use the abbreviation `attr` ...

2afca78a0b/src/librustdoc/html/static/css/rustdoc.css (L255-L259)

... so why does syntax highlighting use the full word?

2afca78a0b/src/librustdoc/html/static/css/rustdoc.css (L1095-L1097)
2022-11-01 22:01:37 +05:30
Dylan DPC
db200d01cd
Rollup merge of #103813 - notriddle:notriddle/search-results-clear-both, r=GuillaumeGomez
rustdoc: remove unnecessary CSS `.search-results { clear: both }`

Since the tabs use flexbox instead of float as of 44d9b8d070, clearing does nothing.
2022-11-01 22:01:36 +05:30
Dylan DPC
68afa32985
Rollup merge of #103760 - petrochenkov:macimp, r=cjgillot
resolve: Turn the binding from `#[macro_export]` into a proper `Import`

Continuation of https://github.com/rust-lang/rust/pull/91795.

```rust
#[macro_export]
macro_rules! m { /*...*/ }
```
is desugared to something like
```rust
macro_rules! m { /*...*/ } // Non-modularized macro_rules item

pub use m; // It's modularized reexport
```

This PR adjusts the internal representation to better match this model.
2022-11-01 22:01:36 +05:30
Dylan DPC
9f603feaee
Rollup merge of #84022 - Aaron1011:remove-derive-res-fallback, r=petrochenkov
Make PROC_MACRO_DERIVE_RESOLUTION_FALLBACK a hard error

r? `@ghost`
2022-11-01 22:01:35 +05:30
nils
b20d969516
Print valid --print requests if request is invalid
When someone makes a typo, it can be useful to see the valid options.
This is also useful if someone wants to find out about all the options.
2022-11-01 16:24:01 +01:00
bors
4c736a21ae Auto merge of #103496 - petrochenkov:effvisdoc2, r=lqd
rustc_metadata: Encode even less doc comments

The fact that `def_id` is in the `tcx.privacy_access_levels(())` table is not very meaningful, especially after https://github.com/rust-lang/rust/pull/102026, `is_exported` (or `is_reachable` in the worst case) is what you need.

Follow up to https://github.com/rust-lang/rust/pull/98450.
r? `@GuillaumeGomez` `@lqd`
2022-11-01 15:05:14 +00:00
bors
e70cbef0c5 Auto merge of #103590 - compiler-errors:ocx-more, r=lcnr
(almost) Always use `ObligationCtxt` when dealing with canonical queries

Hope this is a step in the right direction. cc rust-lang/types-team#50.

r? `@lcnr`
2022-11-01 12:15:10 +00:00
Laurențiu Nicola
0b3e75e1cd ⬆️ rust-analyzer 2022-11-01 11:31:31 +02:00
bors
c493bae0d8 Auto merge of #103832 - Dylan-DPC:rollup-maw3kmx, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #103061 (Rewrite implementation of `#[alloc_error_handler]`)
 - #103584 (Remove bounds check when array is indexed by enum)
 - #103706 (Fix E0433 No Typo Suggestions)
 - #103729 (interpret: fix align_of_val on packed types)
 - #103759 (Use `adt_def` during type collection.)
 - #103809 (Fix a typo in std::net mod doc comment)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-11-01 09:01:12 +00:00
Dylan DPC
5d30bfc431
Rollup merge of #103809 - tyggja:patch-1, r=JohnTitor
Fix a typo in std::net mod doc comment

net-doc syntax
2022-11-01 14:12:27 +05:30
Dylan DPC
09f4f7c8f0
Rollup merge of #103759 - cjgillot:adt-collect, r=davidtwco
Use `adt_def` during type collection.

This removes a wrapper which is close to what `adt_def` does.
2022-11-01 14:12:27 +05:30
Dylan DPC
20528baac4
Rollup merge of #103729 - RalfJung:align-of-val-packed, r=oli-obk
interpret: fix align_of_val on packed types

Fixes https://github.com/rust-lang/miri/issues/2632

r? `@oli-obk`
2022-11-01 14:12:26 +05:30
Dylan DPC
7dc3ace6a9
Rollup merge of #103706 - zbyrn:issue-101637-fix, r=estebank
Fix E0433 No Typo Suggestions

Fixes #48676
Fixes #87791
Fixes #96625
Fixes #95462
Fixes #101637
Follows up PR #72923

Several open issues refer to the problem that E0433 does not suggest typos like other errors normally do. This fix augments the implementation of PR #72923.

**Background**
When the path of a function call, e.g. `Struct::foo()`, involves names that cannot be resolved, there are two errors that could be emitted by the compiler:
 - If `Struct` is not found, it is ``E0433: failed to resolve: use of undeclared type `Struct` ``.
 - If `foo` is not found in `Struct`, it is ``E0599: no function or associated item named `foo` found for struct `Struct` in the current scope``

When a name is used as a type, `e.g. fn foo() -> Struct`, and the name cannot be resolved, it is ``E0412: cannot find type `Struct` in this scope``.

Before #72923, `E0433` does not implement any suggestions, and the PR introduces suggestions for missing `use`s. When a resolution error occurs in the path of a function call, it tries to smart resolve just the type part of the path, e.g. `module::Struct` of a call to `module::Struct::foo()`. However, along with the suggestions, the smart-resolve function will report `E0412` since it only knows that it is a type that we cannot resolve instead of being a part of the path. So, the original implementation swap out `E0412` errors returned by the smart-resolve function with the real `E0433` error, but keeps the "missing `use`" suggestions to be reported to the programmer.

**Issue**
The current implementation only reports if there are "missing `use`" suggestions returned by the smart-resolve function; otherwise, it would fall back the normal reporting, which does not emit suggestions. But the smart-resolve function could also produce typo suggestions, which are omitted currently.

Also, it seems like that not all info has been swapped out when there are missing suggestions. The error message underlining the name in the snippet still says ``not found in this scope``, which is a `E0412` messages, if there are `use` suggestions, but says the normal `use of undeclared type` otherwise.

**Fixes**
This fix swaps out all fields in `Diagnostic` returned by the smart-resolve function except for `suggestions` with the current error, and merges the `suggestions` of the returned error and that of the current error together. If there are `use` suggestions, the error is saved to `use_injection` to be reported at the end; otherwise, the error is emitted immediately as `Resolver::report_error` does.

Some tests are updated to use the correct underlining error messages, and one additional test for typo suggestion is added to the test suite.

r? rust-lang/diagnostics
2022-11-01 14:12:26 +05:30
Dylan DPC
94241e7eaf
Rollup merge of #103584 - ouz-a:issue-102303, r=oli-obk
Remove bounds check when array is indexed by enum

As the title says, this reverts the behavior introduced with 1.64.

Fixes #102303

r? `@oli-obk`
2022-11-01 14:12:25 +05:30
Dylan DPC
43634675f6
Rollup merge of #103061 - Amanieu:rewrite_alloc_error_handler, r=bjorn3
Rewrite implementation of `#[alloc_error_handler]`

The new implementation doesn't use weak lang items and instead changes `#[alloc_error_handler]` to an attribute macro just like `#[global_allocator]`.

The attribute will generate the `__rg_oom` function which is called by the compiler-generated `__rust_alloc_error_handler`. If no `__rg_oom` function is defined in any crate then the compiler shim will call `__rdl_oom` in the alloc crate which will simply panic.

This also fixes link errors with `-C link-dead-code` with `default_alloc_error_handler`: `__rg_oom` was previously defined in the alloc crate and would attempt to reference the `oom` lang item, even if it didn't exist. This worked as long as `__rg_oom` was excluded from linking since it was not called.

This is a prerequisite for the stabilization of `default_alloc_error_handler` (#102318).
2022-11-01 14:12:25 +05:30
yukang
749afe57c3 fix #103751: Fix capacity overflow issue during transmutability check 2022-11-01 15:46:58 +08:00