Commit Graph

1174 Commits

Author SHA1 Message Date
León Orell Valerian Liehr
d0b99e3efe
Make #[repr(Rust)] and #[repr(C)] incompatible with one another 2023-10-18 17:25:23 +02:00
Ben Kimock
33b0e4be06 Automatically enable cross-crate inlining for small functions 2023-10-17 19:53:51 -04:00
Arthur Lafrance
52ad8199d5 tweak pass description and fix lint fail post-rebase 2023-10-16 19:50:31 -07:00
Nicholas Nethercote
d284c8a2d7 Rename ACTIVE_FEATURES as UNSTABLE_FEATURES.
It's a better name, and lets "active features" refer to the features
that are active in a particular program, due to being declared or
enabled by the edition.

The commit also renames `Features::enabled` as `Features::active` to
match this; I changed my mind and have decided that "active" is a little
better thatn "enabled" for this, particularly because a number of
pre-existing comments use "active" in this way.

Finally, the commit renames `Status::Stable` as `Status::Accepted`, to
match `ACCEPTED_FEATURES`.
2023-10-16 08:17:23 +11:00
Michael Goulet
b2d2184ede Format all the let chains in compiler 2023-10-13 08:59:36 +00:00
bors
6d05c430d2 Auto merge of #115948 - notriddle:notriddle/logo-lockup, r=fmease
rustdoc: show crate name beside smaller logo

*Blocked on https://github.com/rust-lang/cargo/pull/12800*

## Summary

In this PR, the crate name and version are always shown in the sidebar, even in subpages, and the lateral navigation is always shown in the sidebar, even in modules.

Clicking the crate name does the same thing clicking the logo always did: take you to the crate root (the crate's home page, at least within Rustdoc).

The Rust logo is also no longer shown by default for non-Rust docs.

### Screenshots

<details><summary>Before</summary>

| | Macro | Module |
|--|-------|--------|
| In crate | ![image](https://github.com/rust-lang/rust/assets/1593513/d5db0a46-2bb6-44a2-a3aa-2d915ecb8595) |![image](https://github.com/rust-lang/rust/assets/1593513/61f8c1ee-c298-4e2c-b791-18ecb79ab83b)
| In module[^1] | ![image](https://github.com/rust-lang/rust/assets/1593513/73abca59-0b69-4650-a1e2-7278ca34795c) | ![image](https://github.com/rust-lang/rust/assets/1593513/0baf02c2-2ec7-4674-80e5-a6a74a973376)

[^1]: This PR also includes a bug fix for derive macros not showing up in the lateral navigation part of the sidebar

</details>

#### Whole sidebar screenshots

| | Macro | Module |
|--|-------|--------|
| In crate | ![image](https://github.com/rust-lang/rust/assets/1593513/75d1bd07-41f7-4f11-ba24-fd5476e0586a) | ![image](https://github.com/rust-lang/rust/assets/1593513/52960259-2b65-4131-b380-01826f0a0eb7)
| In module | ![image](https://github.com/rust-lang/rust/assets/1593513/06e57928-8cb0-41bd-b152-be16cc53e5ec) | ![image](https://github.com/rust-lang/rust/assets/1593513/37291c69-2a07-4467-a382-d9b029084a47)

#### Different logo configurations

|         | Short crate name | Long crate name |
|---------|------------------|-----------------|
| Root    | ![short-root]    | ![long-root]
| Subpage | ![short-subpage] | ![long-subpage]

[short-root]: https://github.com/rust-lang/rust/assets/1593513/9e2b4fa8-f581-4106-b562-1e0372c13f79
[short-subpage]: https://github.com/rust-lang/rust/assets/1593513/8331cdb8-fa13-4671-a1e2-dcc1cdca7451
[long-root]: https://github.com/rust-lang/rust/assets/1593513/7d377fec-0f1d-4343-9f82-0e35a8f58056
[long-subpage]: https://github.com/rust-lang/rust/assets/1593513/3b3094a4-63c9-477c-8c15-b6075837df30

##### Without a logo

![image](https://github.com/rust-lang/rust/assets/1593513/66672b79-6c59-4be8-a527-25ef6f0b04ab)

### Preview pages

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/rocket/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/rocket_sync_db_pools/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rust-compiler/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rust/std/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/tokio/index.html

## Motivation

This improves visual information density (the construct with the logo and crate name is *shorter* than the logo on its own, because it's not square) and navigation clarity (we can now see what clicking the Rust logo does, specifically).

Compare this with the layout at [Phoenix's Hexdocs] (which is what this proposal is closely based on), the old proposal on [Internals Discourse] (which always says "Rust standard library" in the sidebar, but doesn't do the side-by-side layout).

[Phoenix's Hexdocs]: https://hexdocs.pm/phoenix/1.7.7/overview.html
[Internals Discourse]: https://internals.rust-lang.org/t/poc-of-a-new-design-for-the-generated-rustdoc/11018

## Guide-level explanation

This PR cleans up some of the sidebar navigation.

It makes the logo in the desktop sidebar a bit smaller, and puts the crate name and version next to it (either beside it, or below it, depending on if there's space), making it clearer what clicking on it does: click the crate name to open the crate's home page. It also removes the Rust logo from non-official-Rust crates, again to make the navigation and supply chain clearer (since the crate name has been added, the logo is no longer necessary for navigation).

It adds a bit more clarifying information for lateral navigation. On items that don't add their own sidebar items, it just shows its siblings directly below the crate name and logo, but for other items, it shows "In crate alloc" instead of just "In alloc". It also shows the lateral navigation tools on module pages, making modules consistent with every other item.

## Drawbacks

While this actually takes up less screen real estate than the old layout on desktop, it takes up more HTML. It's also a bit more visually complex.

## Rationale and alternatives

I could do what the Internals POC did and keep the vertically stacked layout all the time, instead of doing a horizontal stack where possible. It would take up more screen real estate, though.

## Prior art

This design is lifted almost verbatim from Hexdocs. It seems to work for them. [`opentelemetry_process_propagator`], for example, has a long application name.

[`opentelemetry_process_propagator`]: https://hexdocs.pm/opentelemetry_process_propagator/OpentelemetryProcessPropagator.html

## Unresolved questions

Maybe we should encourage crate authors to include their own logo more often? It certainly helps give people a better sense of "place." This seems to be blocked on coming up with an API to do it without requiring them to host the file somewhere.

## Future possibilities

Beyond this, plenty of other changes could be made to improve the layout, like

* Fix things so that clicking an item in the sidebar doesn't cause it to scroll back to the top.
  * The [Internals demo](https://utherii.github.io/new.html) does this right: clicking an item in the sidebar changes the content area, but the sidebar itself does not change. This is nice, because clicking is cheap and I can skim the opening few paragraphs while browsing.
  * The layout of the docs sidebar causes trouble to implement this, because it's different on different pages, but at least fix this on the file browser.
* Come up with a less cluttered way to do disclosure. There's a lot of `[-]` on the page.
  * We don't lack ideas to fix this one. We have *too many*.
* Do a better job of separating local navigation (vec::Vec links to vec::IntoIter) and the table of contents (vec::Vec links to vec::Vec::new).
  * A possibility: add a Back arrow next to the "In [module]" header?
    ![image](https://github.com/rust-lang/rust/assets/1593513/e969faf7-7722-457a-b8c6-8d962e9e1e23)
* Give readers more control of how much rustdoc shows them, and giving doc authors more control of how much it generates. Basically, https://github.com/rust-lang/rust/pull/115660 is great, let's do it too.

But those are mostly orthogonal, not future possibilities unlocked by this change.
2023-10-11 06:28:36 +00:00
Esteban Küber
d23dc2093c Account for macros 2023-10-09 22:48:10 +00:00
Esteban Küber
daac011459 Suggest labeling block if break is in bare block
Fix #103982.
2023-10-09 19:24:05 +00:00
Michael Howell
c6e6ecb1af rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
bors
94bc9c737e Auto merge of #114811 - estebank:impl-ambiguity, r=wesleywiser
Show more information when multiple `impl`s apply

- When there are `impl`s without type params, show only those (to avoid showing overly generic `impl`s).
```
error[E0283]: type annotations needed
  --> $DIR/multiple-impl-apply.rs:34:9
   |
LL |     let y = x.into();
   |         ^     ---- type must be known at this point
   |
note: multiple `impl`s satisfying `_: From<Baz>` found
  --> $DIR/multiple-impl-apply.rs:14:1
   |
LL | impl From<Baz> for Bar {
   | ^^^^^^^^^^^^^^^^^^^^^^
...
LL | impl From<Baz> for Foo {
   | ^^^^^^^^^^^^^^^^^^^^^^
   = note: required for `Baz` to implement `Into<_>`
help: consider giving `y` an explicit type
   |
LL |     let y: /* Type */ = x.into();
   |          ++++++++++++
```

- Lower the importance of `T: Sized`, `T: WellFormed` and coercion errors, to prioritize more relevant errors. The pre-existing deduplication logic deals with hiding redundant errors better that way, and we show errors with more metadata that is useful to the user.

- Show `<SelfTy as Trait>::assoc_fn` suggestion in more cases.
```
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
  --> $DIR/cross-return-site-inference.rs:38:16
   |
LL |     return Err(From::from("foo"));
   |                ^^^^^^^^^^ cannot call associated function of trait
   |
help: use a fully-qualified path to a specific available implementation
   |
LL |     return Err(</* self type */ as From>::from("foo"));
   |                +++++++++++++++++++     +
```

Fix #88284.
2023-10-06 18:44:32 +00:00
bors
2bbb619893 Auto merge of #114417 - chinedufn:fix-expect-unused-in-impl-block-rust-issue-114416, r=cjgillot
Fix multiple `expect` attribs in impl block

Closes #114416
2023-10-04 20:44:38 +00:00
Esteban Küber
91b9ffeab0 Reorder fullfillment errors to keep more interesting ones first
In `report_fullfillment_errors` push back `T: Sized`, `T: WellFormed`
and coercion errors to the end of the list. The pre-existing
deduplication logic eliminates redundant errors better that way, keeping
the resulting output with fewer errors than before, while also having
more detail.
2023-10-04 02:04:14 +00:00
Chinedu Francis Nwafili
bf4df0617f
Tidy 2023-10-02 10:08:03 -04:00
Chinedu Francis Nwafili
9bb55a038f
Tidy 2023-10-02 09:54:45 -04:00
Chinedu Francis Nwafili
67379c4006
Address misc feedback 2023-10-02 08:59:31 -04:00
Nicholas Nethercote
7326cd98b9 Factor out the two entry_point_type functions.
They are very similar, and each one has a comment about the importance
of being kept in sync with the other. This commit removes the
duplication.
2023-10-01 20:45:09 +11:00
bors
6b99cf1d35 Auto merge of #116163 - compiler-errors:lazyness, r=oli-obk
Don't store lazyness in `DefKind::TyAlias`

1. Don't store lazyness of a type alias in its `DefKind`, but instead via a query.
2. This allows us to treat type aliases as lazy if `#[feature(lazy_type_alias)]` *OR* if the alias contains a TAIT, rather than having checks for both in separate parts of the codebase.

r? `@oli-obk` cc `@fmease`
2023-09-27 01:48:53 +00:00
Matthias Krüger
6f4a0a1eb2
Rollup merge of #116162 - fmease:gate-n-validate-rustc_safe_intrinsic, r=Nilstrieb
Gate and validate `#[rustc_safe_intrinsic]`

Copied over from #116159:

> This was added as ungated in https://github.com/rust-lang/rust/pull/100719/files#diff-09c366d3ad3ec9a42125253b610ca83cad6b156aa2a723f6c7e83eddef7b1e8fR502, probably because the author looked at the surrounding attributes, which are ungated because they are gated specially behind the staged_api feature.
>
> I don't think we need to crater this, the attribute is entirely useless without the intrinsics feature, which is already unstable..

r? ``@Nilstrieb``
2023-09-26 15:57:26 +02:00
Michael Goulet
d6ce9ce115 Don't store lazyness in DefKind 2023-09-26 02:53:59 +00:00
León Orell Valerian Liehr
f54db7c3a9
Gate and validate #[rustc_safe_intrinsic] 2023-09-25 22:33:15 +02:00
Michael Goulet
8cfd249198 Allow higher-ranked fn sigs in ValuePairs 2023-09-22 19:47:41 +00:00
bors
8759de0a49 Auto merge of #114776 - fee1-dead-contrib:enable-effects-in-libcore, r=oli-obk
Enable effects for libcore

~~r? `@oli-obk~~`

forgot you are on vacation, oops
2023-09-22 07:00:52 +00:00
bors
aace2dfa37 Auto merge of #115910 - eduardosm:lang-fns-target-features, r=cjgillot
Prevent using `#[target_feature]` on lang item functions

Fixes https://github.com/rust-lang/rust/issues/109411 and also prevents from using `#[target_feature]` on other `fn` lang items to mitigate the concerns from https://github.com/rust-lang/rust/issues/109411#issuecomment-1477030273.
2023-09-22 05:07:45 +00:00
Oli Scherer
9c762b58ba Prevent promotion of const fn calls in inline consts 2023-09-21 09:00:22 +00:00
Deadbeef
7b1b17574b fix bugs with effects fallback 2023-09-20 03:02:14 +00:00
Eduardo Sánchez Muñoz
9102816bc4 Prevent using #[target_feature] on lang item functions 2023-09-18 20:11:01 +02:00
bors
327e6cf55c Auto merge of #114452 - weiznich:feature/diagnostic_on_unimplemented, r=compiler-errors
`#[diagnostic::on_unimplemented]` without filters

This commit adds support for a `#[diagnostic::on_unimplemented]` attribute with the following options:

* `message` to customize the primary error message
* `note` to add a customized note message to an error message
* `label` to customize the label part of the error message

The relevant behavior is specified in [RFC-3366](https://rust-lang.github.io/rfcs/3366-diagnostic-attribute-namespace.html)
2023-09-17 10:00:15 +00:00
bors
635c4a5e61 Auto merge of #114494 - est31:extend_useless_ptr_null_checks, r=jackh726
Make useless_ptr_null_checks smarter about some std functions

This teaches the `useless_ptr_null_checks` lint that some std functions can't ever return null pointers, because they need to point to valid data, get references as input, etc.

This is achieved by introducing an `#[rustc_never_returns_null_ptr]` attribute and adding it to these std functions (gated behind bootstrap `cfg_attr`).

Later on, the attribute could maybe be used to tell LLVM that the returned pointer is never null. I don't expect much impact of that though, as the functions are pretty shallow and usually the input data is already never null.

Follow-up of PR #113657

Fixes #114442
2023-09-16 03:40:20 +00:00
bors
c728bf3963 Auto merge of #114656 - bossmc:rework-no-coverage-attr, r=oli-obk
Rework `no_coverage` to `coverage(off)`

As discussed at the tail of https://github.com/rust-lang/rust/issues/84605 this replaces the `no_coverage` attribute with a `coverage` attribute that takes sub-parameters (currently `off` and `on`) to control the coverage instrumentation.

Allows future-proofing for things like `coverage(off, reason="Tested live", issue="#12345")` or similar.
2023-09-14 01:05:18 +00:00
Georg Semmler
5b8a7a0917
#[diagnostic::on_unimplemented] without filters
This commit adds support for a `#[diagnostic::on_unimplemented]`
attribute with the following options:

* `message` to customize the primary error message
* `note` to add a customized note message to an error message
* `label` to customize the label part of the error message

Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
Co-authored-by: Michael Goulet <michael@errs.io>
2023-09-12 20:03:18 +02:00
Chinedu Francis Nwafili
feb8002502
Fix formatting 2023-09-12 07:55:39 -04:00
Chinedu Francis Nwafili
7db9c3c1a6
Tests passing 2023-09-12 03:11:11 -04:00
yukang
f9a9ff20a2 cleanup on messages 2023-09-12 07:27:17 +08:00
Nicholas Nethercote
64ea8eb1a9 Disentangle Debug and Display for Ty.
The `Debug` impl for `Ty` just calls the `Display` impl for `Ty`. This
is surprising and annoying. In particular, it means `Debug` doesn't show
as much information as `Debug` for `TyKind` does. And `Debug` is used in
some user-facing error messages, which seems bad.

This commit changes the `Debug` impl for `Ty` to call the `Debug` impl
for `TyKind`. It also does a number of follow-up changes to preserve
existing output, many of which involve inserting
`with_no_trimmed_paths!` calls. It also adds `Display` impls for
`UserType` and `Canonical`.

Some tests have changes to expected output:
- Those that use the `rustc_abi(debug)` attribute.
- Those that use the `EMIT_MIR` annotation.

In each case the output is slightly uglier than before. This isn't
ideal, but it's pretty weird (particularly for the attribute) that the
output is using `Debug` in the first place. They're fairly obscure
attributes (I hadn't heard of them) so I'm not worried by this.

For `async-is-unwindsafe.stderr`, there is one line that now lacks a
full path. This is a consistency improvement, because all the other
mentions of `Context` in this test lack a path.
2023-09-11 12:51:07 +10:00
Tomasz Miąsko
d99333e444 Encode only MIR that can be used by other crates
Only reachable items might participate in the code generation in the
downstream crates. Omit redundant optimized MIR of unreachable items
from a crate metadata.

Additionally, include reachable closures in reachable set, so that
unreachable closures can be omitted on the same basis.
2023-09-10 13:55:33 +02:00
Ralf Jung
3bd8bcb8bb better spans for WF errors 2023-09-09 18:00:13 +02:00
Ralf Jung
c2a7e684cd use hir_crate_items(()).definitions() instead of hir().items() 2023-09-09 17:39:53 +02:00
Ralf Jung
a5b0311367 rustc_layout, rustc_abi: make sure the types are well-formed 2023-09-09 17:32:12 +02:00
Andy Caldwell
8e03371fc3
Rework no_coverage to coverage(off) 2023-09-08 12:46:06 +01:00
Ralf Jung
b0cf4c28ea turns out Layout has some more things to worry about -- move ABI comparison into helper function
like is_bool, and some special magic extra fields
2023-09-08 09:14:07 +02:00
Ralf Jung
a53c6ee0ba also ensure that size and alignment are the same 2023-09-08 08:59:55 +02:00
Ralf Jung
c3e14edd8b accept some differences for rustc_abi(assert_eq), so that we can test more things to be compatible 2023-09-08 08:59:55 +02:00
Ralf Jung
8922c0c541 add support for rustc_abi(assert_eq) and use it to test some repr(transparent) cases 2023-09-07 09:14:29 +02:00
Ralf Jung
e66913f8fe rustc_layout/abi: error when attribute is applied to the wrong thing 2023-09-06 11:11:06 +02:00
Ralf Jung
9570cac019 rustc_abi: also support debugging function pointers 2023-09-06 11:11:06 +02:00
Ralf Jung
abe2148aee add rustc_abi debugging attribute 2023-08-27 11:55:49 +02:00
bors
4354192429 Auto merge of #114201 - Centri3:explicit-repr-rust, r=WaffleLapkin
Allow explicit `#[repr(Rust)]`

This is identical to no `repr()` at all. For `Rust, packed` and `Rust, align(x)`, it should be the same as no `Rust` at all (as, afaik, `#[repr(align(16))]` uses the Rust ABI.)

The main use case for this is being able to explicitly say "I want to use the Rust ABI" in very very rare circumstances where the first obvious choice would be the C ABI yet is undesirable, which is already possible with functions as `extern "Rust"`. This would be useful for silencing https://github.com/rust-lang/rust-clippy/pull/11253. It's also more consistent with `extern`.

The lack of this also tripped me up a bit when I was new to Rust, as I expected this to be possible.
2023-08-25 00:02:54 +00:00
bors
18be2728bd Auto merge of #115131 - frank-king:feature/unnamed-fields-lite, r=petrochenkov
Parse unnamed fields and anonymous structs or unions (no-recovery)

It is part of #114782 which implements #49804. Only parse anonymous structs or unions in struct field definition positions.

r? `@petrochenkov`
2023-08-24 12:52:35 +00:00
Frank King
868706d9b5 Parse unnamed fields and anonymous structs or unions
Anonymous structs or unions are only allowed in struct field
definitions.

Co-authored-by: carbotaniuman <41451839+carbotaniuman@users.noreply.github.com>
2023-08-24 11:17:54 +08:00
Tomasz Miąsko
0383131f7f Contents of reachable statics is reachable 2023-08-22 00:00:00 +00:00
Catherine Flores
1f7bad0d12 Clarify that Rust is default repr 2023-08-20 13:22:39 +00:00
Matthias Krüger
269803ee56 remove redundant var rebindings 2023-08-19 14:09:30 +02:00
Matthias Krüger
8db5a6d8ee
Rollup merge of #114819 - estebank:issue-78124, r=compiler-errors
Point at return type when it influences non-first `match` arm

When encountering code like

```rust
fn foo() -> i32 {
    match 0 {
        1 => return 0,
        2 => "",
        _ => 1,
    }
}
```

Point at the return type and not at the prior arm, as that arm has type `!` which isn't influencing the arm corresponding to arm `2`.

Fix #78124.
2023-08-15 20:34:25 +02:00
Chinedu Francis Nwafili
8ad46b49a2
Misc progress 2023-08-15 09:41:43 -04:00
Guillaume Gomez
f0987ab45b
Rollup merge of #114772 - fee1-dead-contrib:typed-did, r=b-naber
Add `{Local}ModDefId` to more strongly type DefIds`

Based on #110862 by `@Nilstrieb`
2023-08-15 14:29:45 +02:00
Esteban Küber
5021dde1a0 Move scrutinee HirId into MatchSource::TryDesugar 2023-08-14 21:43:56 +00:00
Nilstrieb
c75fc573aa Use {Local}ModDefId in many queries 2023-08-14 07:22:48 +00:00
bjorn3
ef2da4a49b Remove reached_eof from ParseSess
It was only ever set in a function which isn't called anywhere.
2023-08-13 13:33:37 +00:00
bors
5f3abbc52f Auto merge of #114723 - petrochenkov:noplugin2, r=davidtwco
rustc: Move `features` from `Session` to `GlobalCtxt`

Removes one more piece of mutable state.
Follow up to #114622.

The rule I used for passing feature in function signatures:
- if a crate already depends on `rustc_middle`, then `Session` is replaced with `TyCtxt`
- otherwise session and features are passed as a pair `sess: &Session, features: &Features`

The code in `rustc_lint` is ultimately used for implementing a trait from `rustc_expand`, so it also doesn't use tcx despite the dependency on `rustc_middle`.
2023-08-13 10:59:36 +00:00
bors
1e836d12d3 Auto merge of #114710 - Urgau:fix-expect-dead_code-114557, r=cjgillot
Respect `#[expect]` the same way `#[allow]` is with the `dead_code` lint

This PR makes the `#[expect]` attribute being respected in the same way the `#[allow]` attribute is with the `dead_code` lint.

The fix is much more involved than I would have liked (and it's not because I didn't tried!), because the implementation took advantage of the fact that firing a lint in a allow context is a nop (for the user, as the lint is suppressed) to not fire-it at all.

And will it's fine for `#[allow]`, it definitively isn't for `#[expect]`, as the presence and absence of the lint is significant. So a big part of the PR is just adding the context information of whenever an item is on the worklist because of an `[allow]`/`#[expect]` or not.

Fixes https://github.com/rust-lang/rust/issues/114557
2023-08-12 15:14:42 +00:00
Vadim Petrochenkov
7353c96be8 rustc: Move features from Session to GlobalCtxt
Removes two pieces of mutable state.
Follow up to #114622.
2023-08-11 16:51:50 +08:00
Urgau
d801a2ff15 Respect #[expect] the same way #[allow] is with the dead_code lint 2023-08-10 22:57:48 +02:00
Vadim Petrochenkov
0b89aac08d rustc: Move crate_types from Session to GlobalCtxt
Removes a piece of mutable state.
Follow up to #114578.
2023-08-09 14:17:54 +08:00
bors
f88a8b71ce Auto merge of #114545 - fee1-dead-contrib:lower-impl-effect, r=oli-obk
correctly lower `impl const` to bind to host effect param

r? `@oli-obk`
2023-08-08 19:23:41 +00:00
Chinedu Francis Nwafili
b56a04975c
Fix multiple expect attribs in impl block
Closes #114416
2023-08-08 08:34:09 -04:00
Matthias Krüger
3cd0a109a8
Rollup merge of #114566 - fmease:type-alias-laziness-is-crate-specific, r=oli-obk
Store the laziness of type aliases in their `DefKind`

Previously, we would treat paths referring to type aliases as *lazy* type aliases if the current crate had lazy type aliases enabled independently of whether the crate which the alias was defined in had the feature enabled or not.

With this PR, the laziness of a type alias depends on the crate it is defined in. This generally makes more sense to me especially if / once lazy type aliases become the default in a new edition and we need to think about *edition interoperability*:

Consider the hypothetical case where the dependency crate has an older edition (and thus eager type aliases), it exports a type alias with bounds & a where-clause (which are void but technically valid), the dependent crate has the latest edition (and thus lazy type aliases) and it uses that type alias. Arguably, the bounds should *not* be checked since at any time, the dependency crate should be allowed to change the bounds at will with a *non*-major version bump & without negatively affecting downstream crates.

As for the reverse case (dependency: lazy type aliases, dependent: eager type aliases), I guess it rules out anything from slight confusion to mild annoyance from upstream crate authors that would be caused by the compiler ignoring the bounds of their type aliases in downstream crates with older editions.

---

This fixes #114468 since before, my assumption that the type alias associated with a given weak projection was lazy (and therefore had its variances computed) did not necessarily hold in cross-crate scenarios (which [I kinda had a hunch about](https://github.com/rust-lang/rust/pull/114253#discussion_r1278608099)) as outlined above. Now it does hold.

`@rustbot` label F-lazy_type_alias
r? `@oli-obk`
2023-08-08 03:30:56 +02:00
Arthur Cohen
bdf4e3de9c check_attrs: Warn when #[macro_export] is used on macros 2.0
The compiler should emit a more specific error when the `#[macro_export]`
attribute is present on a decl macro, instead of silently ignoring it.

This commit adds the required error message in rustc_passes/messages.ftl,
 as well as a note. A new variant is added to the `errors::MacroExport`
enum, specifically for the case where the attribute is added to a macro
2.0.
2023-08-07 21:14:28 +02:00
León Orell Valerian Liehr
5468336d6b
Store the laziness of type aliases in the DefKind 2023-08-07 15:54:31 +02:00
Deadbeef
92f4c59e48 lower impl const to bind to host effect param 2023-08-06 13:34:53 +00:00
est31
8cfa4fe6b2 Add #[rustc_never_returns_null_ptr]
And look for it in the useless_ptr_null_checks lint
2023-08-05 05:16:44 +02:00
Nilstrieb
5706be1854 Improve spans for indexing expressions
Indexing is similar to method calls in having an arbitrary
left-hand-side and then something on the right, which is the main part
of the expression. Method calls already have a span for that right part,
but indexing does not. This means that long method chains that use
indexing have really bad spans, especially when the indexing panics and
that span in coverted into a panic location.

This does the same thing as method calls for the AST and HIR, storing an
extra span which is then put into the `fn_span` field in THIR.
2023-08-04 13:17:39 +02:00
Catherine Flores
f42d361a22 Allow explicit #[repr(Rust)] 2023-07-29 06:58:29 +00:00
León Orell Valerian Liehr
9213aec762
Lower generic const items to HIR 2023-07-28 22:21:40 +02:00
Matthias Krüger
c64ef5e070 inline format!() args from rustc_codegen_llvm to the end (4)
r? @WaffleLapkin
2023-07-25 23:20:28 +02:00
Lukas Markeffsky
637ea3f746 validate doc(masked) 2023-07-24 18:04:35 +02:00
许杰友 Jieyou Xu (Joe)
08c77a6eb4
Add infrastructure #[rustc_confusables] attribute to allow targeted
"no method" errors on standard library types

The standard library developer can annotate methods on e.g.
`BTreeSet::push` with `#[rustc_confusables("insert")]`. When the user
mistypes `btreeset.push()`, `BTreeSet::insert` will be suggested if
there are no other candidates to suggest.
2023-07-16 19:22:03 +08:00
Matthias Krüger
0baf4406da
Rollup merge of #113698 - compiler-errors:rpitit-check, r=spastorino
Make it clearer that we're just checking for an RPITIT

Tiny nit to use `is_impl_trait_in_trait` more, to make it clearer that we're just checking whether a def-id is an RPITIT, rather than doing something meaningful with the `opt_rpitit_info`.

r? `@spastorino`
2023-07-14 19:33:29 +02:00
Michael Goulet
14672eba8b Make it clearer that we're just checking for an RPITIT 2023-07-14 15:18:48 +00:00
Mahdi Dibaiee
e55583c4b8 refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
Mark Rousskov
cc907f80b9 Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
Santiago Pastorino
20429af7a3
Replace RPITIT current impl with new strategy that lowers as a GAT 2023-07-08 18:21:34 -03:00
Nilstrieb
3019c1cb2a Put LayoutError behind reference to shrink result
`LayoutError` is 24 bytes, which is bigger than the `Ok` types, so let's
shrink that.
2023-07-01 21:16:25 +02:00
bors
08fd6f719e Auto merge of #111269 - clubby789:validate-fluent-variables, r=davidtwco
Validate fluent variable references in tests

Closes #101109

Under `cfg(test)`, the `fluent_messages` macro will emit a list of variables referenced by each message and its attributes. The derive attribute will now emit a `#[test]` that checks that each referenced variable exists in the structure it's applied to.
2023-06-28 03:47:02 +00:00
Maybe Waffle
ccb71ff424 hir: Add Become expression kind 2023-06-26 08:56:32 +00:00
Nilstrieb
c6710d15f1
Rollup merge of #112790 - WaffleLapkin:syntactically, r=Nilstrieb
Syntactically accept `become` expressions (explicit tail calls experiment)

This adds `ast::ExprKind::Become`, implements parsing and properly gates the feature.

cc `@scottmcm`
2023-06-21 07:37:02 +02:00
Michael Goulet
ca68cf0d46 Merge attrs, better validation 2023-06-20 04:38:55 +00:00
Maybe Waffle
d7713feb99 Syntatically accept become expressions 2023-06-19 12:54:34 +00:00
Matthias Krüger
129a57a9f6
Rollup merge of #112081 - obeis:doc-test-literal, r=compiler-errors
Avoid ICE on `#![doc(test(...)]` with literal parameter

Close #109066

r? `@compiler-errors`
2023-06-05 23:47:57 +02:00
Camille GILLOT
ca4d0d4c24 Separate AnonConst from ConstBlock in HIR. 2023-06-02 21:25:18 +00:00
Deadbeef
4f83717cf7 Use translatable diagnostics in rustc_const_eval 2023-06-01 14:45:18 +00:00
Obei Sideg
70bbcceaec Add test for #![doc(test(...)] with literal parameter 2023-05-29 22:33:46 +03:00
Obei Sideg
33eef8221d Avoid ICE on #![doc(test(...)] with literal parameter 2023-05-29 22:29:50 +03:00
clubby789
220bb61b33 Fix diagnostics with errors 2023-05-26 10:44:18 +00:00
clubby789
f97fddab91 Ensure Fluent messages are in alphabetical order 2023-05-25 23:49:35 +00:00
Maybe Waffle
307799a711 Use is_some_and/is_ok_and in less obvious spots 2023-05-24 14:33:43 +00:00
Maybe Waffle
fb0f74a8c9 Use Option::is_some_and and Result::is_ok_and in the compiler 2023-05-24 14:20:41 +00:00
Michael Woerister
927e1efaaf Don't sort output of debugger_visualizer query because it already is in deterministic order. 2023-05-17 16:02:22 +02:00
Michael Woerister
d623668551 Move DebuggerVisualizerFile types from rustc_span to rustc_middle 2023-05-16 21:03:28 +02:00
Michael Woerister
a7d48800f9 Turn debugger_visualizers from feed- into regular query. 2023-05-16 18:50:36 +02:00
Michael Woerister
7f01893900 Fix dependency tracking for debugger visualizers 2023-05-16 18:50:26 +02:00