Commit Graph

241295 Commits

Author SHA1 Message Date
Michael Goulet
32907c72eb Remove the lint outright 2023-12-16 01:28:06 +00:00
Michael Goulet
629d3511b7 Make IMPLIED_BOUNDS_ENTAILMENT into a hard error from a lint 2023-12-16 01:28:05 +00:00
bors
ca5c68a110 Auto merge of #119002 - workingjubilee:rollup-dbfet7s, r=workingjubilee
Rollup of 5 pull requests

Successful merges:

 - #118396 (Collect lang items from AST, get rid of `GenericBound::LangItemTrait`)
 - #118727 (Don't pass lint back out of lint decorator)
 - #118956 (Make CStr documentation consistent ("nul" instead of "null"))
 - #118981 (Remove an unneeded allocation)
 - #118998 (Link to is_benchmark from the Ipv6Addr::is_global documentation)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-12-15 22:09:47 +00:00
Jubilee
4b447b8bb7
Rollup merge of #118998 - jstasiak:improve-doc, r=workingjubilee
Link to is_benchmark from the Ipv6Addr::is_global documentation

All other relevant is_* methods are mentioned in the list of addresses here, is_benchmarking has been the only one missing.
2023-12-15 14:08:18 -08:00
Jubilee
3d94fc9dfe
Rollup merge of #118981 - krtab:onelessalloc, r=compiler-errors
Remove an unneeded allocation

This removes an unneeded allocation in `<&[hir::GenericParam<'_>] as NextTypeParamName>::next_type_param_name`
2023-12-15 14:08:17 -08:00
Jubilee
5e85fece3a
Rollup merge of #118956 - danielhuang:patch-2, r=workingjubilee
Make CStr documentation consistent ("nul" instead of "null")

"nul" is used in method names and appears more often in the documentation than "null", so make all instances "nul" to keep it consistent.
2023-12-15 14:08:16 -08:00
Jubilee
58353fa458
Rollup merge of #118727 - compiler-errors:lint-decorate, r=WaffleLapkin
Don't pass lint back out of lint decorator

Change the decorator function in the signature of the `emit_lint`/`span_lint`/etc family of methods from `impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>` to `impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>)`. I consider it easier to read this way, especially when there's control flow involved.

r? nnethercote though feel free to reassign
2023-12-15 14:08:16 -08:00
Jubilee
1d54949765
Rollup merge of #118396 - compiler-errors:ast-lang-items, r=cjgillot
Collect lang items from AST, get rid of `GenericBound::LangItemTrait`

r? `@cjgillot`
cc #115178

Looking forward, the work to remove `QPath::LangItem` will also be significantly more difficult, but I plan on doing it as well. Specifically, we have to change:
1. A lot of `rustc_ast_lowering` for things like expr `..`
2. A lot of astconv, since we actually instantiate lang and non-lang paths quite differently.
3. A ton of diagnostics and clippy lints that are special-cased via `QPath::LangItem`

Meanwhile, it was pretty easy to remove `GenericBound::LangItemTrait`, so I just did that here.
2023-12-15 14:08:15 -08:00
Jakub Stasiak
47282799da Add link to is_benchmark from the Ipv6Addr::is_global documentation
All other relevant is_* methods are mentioned in the list of addresses
here, is_benchmarking has been the only one missing.
2023-12-15 20:53:54 +01:00
bors
a96d57bdb6 Auto merge of #118996 - matthiaskrgr:rollup-n6x2lc7, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #117824 (Stabilize `ptr::{from_ref, from_mut}`)
 - #118234 (Stabilize `type_name_of_val`)
 - #118944 (Move type relations into submodule `relate` in rustc_infer, and notify when it has changed)
 - #118977 (Simplify `src-script.js` code)
 - #118985 (Remove `@JohnTitor` from diagnostics pings)
 - #118986 (Simplify JS code a little bit)
 - #118988 (rustdoc: add regression test for JS data file loading)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-12-15 19:32:17 +00:00
Matthias Krüger
5fc9ff5619
Rollup merge of #118988 - notriddle:notriddle/varconst, r=GuillaumeGomez
rustdoc: add regression test for JS data file loading

Follow up for #118961
2023-12-15 20:19:56 +01:00
Matthias Krüger
b377babd2b
Rollup merge of #118986 - GuillaumeGomez:simplify-js-inline, r=notriddle
Simplify JS code a little bit

As mentioned, JS code can be simplified a little bit.

r? ``@notriddle``
2023-12-15 20:19:55 +01:00
Matthias Krüger
39b6f458c3
Rollup merge of #118985 - JohnTitor:rm-jtitor-diag-pings, r=compiler-errors
Remove @JohnTitor from diagnostics pings

I've been inactive around diagnostics for a while so would like to remove myself from the diagnostics-related ping groups for now.
2023-12-15 20:19:55 +01:00
Matthias Krüger
ae9e08e65e
Rollup merge of #118977 - GuillaumeGomez:simplifysrc-script, r=notriddle
Simplify `src-script.js` code

Instead of keeping this value in the global scope and still use it in the function in case it wasn't used outside, let's just use it inside the function.

r? ``@notriddle``
2023-12-15 20:19:54 +01:00
Matthias Krüger
d5213cf52e
Rollup merge of #118944 - compiler-errors:relate, r=lcnr
Move type relations into submodule `relate` in rustc_infer, and notify when it has changed

r? lcnr
2023-12-15 20:19:54 +01:00
Matthias Krüger
ea6daca3cb
Rollup merge of #118234 - tgross35:type_name_of_value, r=dtolnay
Stabilize `type_name_of_val`

Make the following API stable:

```rust
// in core::any
pub fn type_name_of_val<T: ?Sized>(_val: &T) -> &'static str
```

This is a convenience method to get the type name of a value, as opposed to `type_name` that takes a type as a generic.

Const stability is not added because this relies on `type_name` which is also not const. That has a blocking issue https://github.com/rust-lang/rust/issues/97156.

Wording was also changed to direct most of the details to `type_name` so we don't have as much duplicated documentation.

Fixes tracking issue #66359.

There were two main concerns in the tracking issue:

1. Naming: `type_name_of` and `type_name_of_val` seem like the only mentioned options. Differences in opinion here come from `std::mem::{size_of, align_of, size_of_val, align_of_val}`. This PR leaves the name as `type_name_of_val`, but I can change if desired since it is pretty verbose.
2. What this displays for `&dyn`: I don't think that having `type_name_of_val` function resolve those is worth the headache it would be, see https://github.com/rust-lang/rust/issues/66359#issuecomment-1718480774 for some workarounds. I also amended the docs wording to leave it open-ended, in case we have means to change that behavior in the future.

``@rustbot`` label -T-libs +T-libs-api +needs-fcp
r? libs-api
2023-12-15 20:19:53 +01:00
Matthias Krüger
8ad8f29ae0
Rollup merge of #117824 - WaffleLapkin:ptr_from_ref_stab, r=dtolnay
Stabilize `ptr::{from_ref, from_mut}`

I propose to stabilize the following APIs:

```rust
// mod core::ptr

pub const fn from_ref<T: ?Sized>(r: &T) -> *const T;
pub const fn from_mut<T: ?Sized>(r: &mut T) -> *mut T;
```

Tracking issue: https://github.com/rust-lang/rust/issues/106116

---

``@RalfJung`` what do you think we should do with `from_mut`? Stabilize it as const, given that you can't call it anyway (no way to get `&mut` in `const fn`)? Defer stabilizing it as const leaving the same issue/feature? Change issue/feature? Change issue/feature to the "`&mut` in const fn" one?
2023-12-15 20:19:53 +01:00
Michael Goulet
0184c7616e Move nll_relate to relate::nll submodule 2023-12-15 18:13:40 +00:00
Michael Goulet
807cd85dfa Add higher_ranked to relate submodule 2023-12-15 18:13:40 +00:00
Michael Goulet
18bf0caa5a Notify lcnr and errs when relations change 2023-12-15 18:13:40 +00:00
Michael Goulet
5b0b7cd8f9 Move type relations into submodule in rustc_infer 2023-12-15 18:13:40 +00:00
bors
3f39cae119 Auto merge of #115165 - davidtwco:issue-9228-describe-item-member-visibility, r=wesleywiser
codegen_llvm: set `DW_AT_accessibility`

Fixes #9228.
Based on #74778.

Sets the accessibility of types and fields in DWARF using `DW_AT_accessibility` attribute.

`DW_AT_accessibility` (public/protected/private) isn't exactly right for Rust,  but neither is `DW_AT_visibility` (local/exported/qualified), and there's no way to set `DW_AT_visbility` in LLVM's API. Debuggers will special-case the handling of these per-language anyway.

r? `@wesleywiser` (visited in wg-debugging triage)
2023-12-15 17:13:04 +00:00
Maybe Waffle
b863e9ba57
Stabilize ptr::{from_ref, from_mut} 2023-12-15 08:34:59 -08:00
Michael Goulet
bc1ca6b528 Fix enforcement of generics for associated items 2023-12-15 16:17:28 +00:00
Cameron Steffen
04fafd69de Cfg remove lang items in doctest 2023-12-15 16:17:28 +00:00
Michael Goulet
553c3c44b2 Appease the tools: clippy, rustdoc 2023-12-15 16:17:27 +00:00
Michael Goulet
653ca5ad3b Simplify instantiate_poly_trait_ref 2023-12-15 16:17:27 +00:00
Michael Goulet
fc010de26b banish hir::GenericBound::LangItemTrait 2023-12-15 16:17:27 +00:00
Michael Goulet
ad00641b74 Collect lang items from AST 2023-12-15 16:12:27 +00:00
Michael Goulet
252d99a54b Fix comments 2023-12-15 16:08:26 +00:00
Michael Goulet
7f565ed282 Don't pass lint back out of lint decorator 2023-12-15 16:05:36 +00:00
Michael Howell
6bbbff5189 rustdoc: add regression test for JS data file loading
Follow up for #118961
2023-12-15 08:56:49 -07:00
Guillaume Gomez
028a3135c8 Simplify JS code a little bit 2023-12-15 16:56:11 +01:00
Yuki Okushi
c3dd266f47
Remove @JohnTitor from diagnostics pings
I've been inactive around diagnostics for a while so would like to remove myself from the diagnostics-related ping groups for now.
2023-12-16 00:15:15 +09:00
bors
e6707df0de Auto merge of #118982 - matthiaskrgr:rollup-xoraxf4, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #118962 (Annotate some bugs)
 - #118969 (coverage: Use `Waker::noop` in async tests)
 - #118974 (Annotate panic! reasons during enum layout)

Failed merges:

 - #111658 (Refactor pre-getopts command line argument handling)
 - #117449 (Avoid silencing relevant follow-up errors)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-12-15 15:01:55 +00:00
Matthias Krüger
88a9619d74
Rollup merge of #118974 - workingjubilee:why-worry-about-enum-abi, r=davidtwco
Annotate panic! reasons during enum layout

Add some reasons to the panics, and use more exhaustive matches.

Also see: #118955
2023-12-15 15:53:52 +01:00
Matthias Krüger
b9a6f19f19
Rollup merge of #118969 - Zalathar:waker-noop, r=compiler-errors
coverage: Use `Waker::noop` in async tests

Inspired by #118948.

---

`@rustbot` label +A-code-coverage
2023-12-15 15:53:51 +01:00
Matthias Krüger
2f8867e03c
Rollup merge of #118962 - compiler-errors:bugs, r=TaKO8Ki
Annotate some bugs

Gives a semi-helpful message to some `bug!()`/`unreachable!()`/`panic!()`. This also works around some other bugs/panics/etc that weren't needed, and also makes some of them into `span_bug!`s so they also have a useful span.

Note to reviewer: best to disable whitespace when comparing for some cases where indentation changed.

cc #118955
2023-12-15 15:53:51 +01:00
Michael Goulet
1cc0d7d56c Annotate some more bugs 2023-12-15 14:45:06 +00:00
Michael Goulet
70b9dad3dc Annotate some bugs 2023-12-15 14:45:06 +00:00
Arthur Carcano
8142e8555a Remove an unneeded allocation 2023-12-15 15:01:49 +01:00
bors
4d1bd0db7f Auto merge of #118975 - GuillaumeGomez:rollup-0emhjx0, r=GuillaumeGomez
Rollup of 4 pull requests

Successful merges:

 - #113091 (Don't merge cfg and doc(cfg) attributes for re-exports)
 - #115660 (rustdoc: allow resizing the sidebar / hiding the top bar)
 - #118863 (rustc_mir_build: Enforce `rustc::potential_query_instability` lint)
 - #118909 (Some cleanup and improvement for invalid ref casting impl)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-12-15 12:49:36 +00:00
Wesley Wiser
ce290514df
Adapt debug-accessibility tests for msvc-style enums 2023-12-15 11:45:03 +00:00
David Wood
07931c5a08
codegen_llvm: set DW_AT_accessibility
Sets the accessibility of types and fields in DWARF using
`DW_AT_accessibility` attribute.

`DW_AT_accessibility` (public/protected/private) isn't exactly right for
Rust,  but neither is `DW_AT_visibility` (local/exported/qualified), and
there's no way to set `DW_AT_visbility` in LLVM's API.

Signed-off-by: David Wood <david@davidtw.co>
2023-12-15 11:36:41 +00:00
Guillaume Gomez
552143c875 Simplify src-script.js code 2023-12-15 12:26:09 +01:00
Guillaume Gomez
25216b65f4
Rollup merge of #118909 - Urgau:cleanup-improvement-invalid_ref_casting, r=est31
Some cleanup and improvement for invalid ref casting impl

This PR makes some cleanups and improvements to the `invalid_reference_casting` implementation in preparation for linting on new patterns, while reusing most of the logic.

r? `@est31` (feel free to re-assign)
2023-12-15 11:51:24 +01:00
Guillaume Gomez
d3d0287330
Rollup merge of #118863 - Enselic:rustc_mir-build-query-stability, r=michaelwoerister
rustc_mir_build: Enforce `rustc::potential_query_instability` lint

Stop allowing `rustc::potential_query_instability` on all of `rustc_mir_build` and instead allow it on a case-by-case basis if it is safe to do so. In this crate there was only one instance of the lint, and it was safe to allow.

Part of https://github.com/rust-lang/rust/issues/84447 which is E-help-wanted.
2023-12-15 11:51:24 +01:00
Guillaume Gomez
f8b92697a1
Rollup merge of #115660 - notriddle:notriddle/sidebar-resize, r=GuillaumeGomez
rustdoc: allow resizing the sidebar / hiding the top bar

Fixes #97306

Preview: http://notriddle.com/rustdoc-html-demo-4/sidebar-resize/std/index.html

![image](https://github.com/rust-lang/rust/assets/1593513/a2f40ea2-0436-4e44-99e8-d160dab2a680)

## Summary

This feature adds:

1. A checkbox to the Settings popover to hide the persistent navigation bar (the sidebar on large viewports and the top bar on small ones).
2. On large viewports, it adds a resize handle to the persistent sidebar. Resizing it into nothing is equivalent to turning off the persistent navigation bar checkbox in Settings.
3. If the navigation bar is hidden, a toolbar button to the left of the search appears. Clicking it brings the navigation bar back.

## Motivation

While "mobile mode" is definitely a good default, it's not the only reason people have wanted to hide the sidebar:

* Some people use tiling window managers, and don't like rustdoc's current breakpoints. Changing the breakpoints might help with that, but there's no perfect solution, because there's a gap between "huge screen" and "smartphone" where reasonable people can disagree about whether it makes sense for the sidebar to be on-screen. https://github.com/rust-lang/rust/issues/97306

* Some people ask for ways to reduce on-screen clutter because it makes it easier to focus. There's not a media query for that (and if there was, privacy-conscious users would turn it off). https://github.com/rust-lang/rust/issues/59829

This feature is designed to avoid these problems. Resizing the sidebar especially helps, because it provides a way to hide the sidebar without adding a new top-level button (which would add clutter), and it provides a way to make rustdoc play nicer in complex, custom screen layouts.

## Guide and Reference-level explanation

On a desktop or laptop with a mouse, resize the sidebar by dragging its right edge.

On any browser, including mobile phones, the sticky top bar or side bar can be hidden from the Settings area (the button with the cog wheel, next to the search bar). When it's hidden, a convenient button will appear on the search bar's left.

## Drawbacks

This adds more JavaScript code to the render blocking area.

## Rationale and alternatives

The most obvious way to allow people to hide the sidebar would have been to let them "manually enter mobile mode." The upside is that it's a feature we already have. The downside is that it's actually really hard to come up with a terse description. Is it:

* A Setting that forces desktop viewers to always have the mobile-style top bar? If so, how do we label it? Should it be visible on mobile, and, if so, does it just not do anything?
* A persistent hide/show sidebar button, present on desktop, just like on mobile? That's clutter that I'd like to avoid.

## Prior art

* The new file browser in GitHub uses a similar divider with a mouse-over indicator
* mdBook and macOS Finder both allow you to resize the sidebar to nothing as a gesture to hide it
* https://www.nngroup.com/articles/drag-drop/

## Future possibilities

https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Table.20of.20contents proposes a new, second sidebar (a table of contents). How should it fit in with this feature? Should it be resizeable? Hideable? Can it be accessed on mobile?
2023-12-15 11:51:23 +01:00
Guillaume Gomez
ec0008a915
Rollup merge of #113091 - GuillaumeGomez:prevent-cfg-merge-reexport, r=rustdoc
Don't merge cfg and doc(cfg) attributes for re-exports

Fixes #112881.

## Explanations

When re-exporting things with different `cfg`s there are two things that can happen:

 * The re-export uses a subset of `cfg`s, this subset is sufficient so that the item will appear exactly with the subset
 * The re-export uses a non-subset of `cfg`s (e.g. like the example I posted just above where the re-export is ungated), if the non-subset `cfg`s are active (e.g. compiling that example on windows) then this will be a compile error as the item doesn't exist to re-export, if the subset `cfg`s are active it behaves like 1.

### Glob re-exports?

**This only applies to non-glob inlined re-exports.** For glob re-exports the item may or may not exist to be re-exported (potentially the `cfg`s on the path up until the glob can be removed, and only `cfg`s on the globbed item itself matter), for non-inlined re-exports see https://github.com/rust-lang/rust/issues/85043.

cc `@Nemo157`
r? `@notriddle`
2023-12-15 11:51:23 +01:00
bors
96df494340 Auto merge of #118961 - notriddle:notriddle/varconst, r=GuillaumeGomez
rustdoc-search: fix a race condition in search index loading

`var` declare it in the global scope, and `const` does not. It needs to be declared in global scope.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const

> const declarations do not create properties on [globalThis](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis) when declared at the top level of a script.

Fixes a regression introduced by https://github.com/rust-lang/rust/pull/118910
2023-12-15 10:50:09 +00:00