Commit Graph

227778 Commits

Author SHA1 Message Date
Augie Fackler
d94d17c0bb tests: be more permissive on attributes in one test 2023-06-22 18:03:23 -04:00
Josh Triplett
2748efaba3 style-guide: Add language disclaiming any effects on non-default Rust styles
Make it clear that the style guide saying "must" doesn't forbid
developers from doing differently (as though any power on this Earth
could do that) and doesn't forbid tools from allowing any particular
configuration options.
2023-06-22 14:44:33 -07:00
Josh Triplett
fcc23a3bfd style-guide: Avoid referring to the style team in the past tense
We live!
2023-06-22 14:06:43 -07:00
Josh Triplett
f972e09f76 style-guide: Define what an item is 2023-06-22 14:06:43 -07:00
Josh Triplett
5d637219e4 style-guide: Make link text in SUMMARY.md match the headings in the linked pages 2023-06-22 14:02:52 -07:00
Josh Triplett
a9d1db3145 style-guide: Avoid hyphenating "semicolon" 2023-06-22 14:02:52 -07:00
Josh Triplett
3e2449c2b1 style-guide: Rephrase a confusingly ordered, ambiguous sentence (and fix a typo)
This sentence had a parenthetical without a closing parenthesis, and had
the phrase "which doesn't require special formatting" ambiguously at the
end of a list when it only applied to the last item of the list.
2023-06-22 14:02:52 -07:00
Josh Triplett
c930b21bcd style-guide: Reword an awkwardly phrased recommendation (and fix a typo) 2023-06-22 14:02:52 -07:00
Tshepang Mbambo
2828c5605e
typo 2023-06-22 23:01:48 +02:00
Josh Triplett
fec28b26b5 style-guide: Clarify advice on names matching keywords
In particular, specify what this advice is an alternative to (creative
misspellings such as `krate`).
2023-06-22 13:22:44 -07:00
Josh Triplett
6f8f83f66d style-guide: Avoid normative recommendations for formatting tool configurability
It's not within the scope of the style guide to tell formatting tools
whether, or how, to allow configurability of non-default formatting.
2023-06-22 13:19:05 -07:00
Josh Triplett
20f2828bbd style-guide: Update cargo.md for authors being optional and not recommended
Change an example using the authors field to use a long feature list instead.

Change the conventions for the authors field to say "if present".
2023-06-22 13:13:48 -07:00
Josh Triplett
c5f8b2c7a9 style-guide: Define (and capitalize) "ASCIIbetically"
The style guide didn't give any definition for it.
2023-06-22 13:02:24 -07:00
Josh Triplett
d270af3197 style-guide: Remove inaccurate statement about rustfmt
rustfmt does include a mechanism to distinguish standard library
imports, which it does syntactically by crate name. Avoid making a
misleading statement that implies it cannot do this.
2023-06-22 12:49:57 -07:00
Josh Triplett
4c5bb06a97 style-guide: Consistently refer to rustfmt as rustfmt 2023-06-22 12:49:49 -07:00
Josh Triplett
2c0dd90936 style-guide: s/right-ward/rightward/
We already use the word "rightward" elsewhere; avoid the unnecessarily
hyphenated "right-ward".
2023-06-22 12:42:57 -07:00
Josh Triplett
92805672c3 style-guide: Move and expand text about trailing commas
`principles.md` includes some high-level guiding principles for
formatting, but also includes a few specific formatting provisions.
While those provisions apply in many places, the same holds true for
other high-level guidance. Move the text about trailing commas to
`README.md`, so that `principles.md` can focus on guiding principles
while the top level of the style guide gives concrete formatting
recommendations.
2023-06-22 12:41:30 -07:00
Josh Triplett
3747d7f593 style-guide: Move text about block vs visual indent to indentation section
`principles.md` includes some high-level guiding principles for
formatting, but also includes a few specific formatting provisions.
While those provisions apply in many places, the same holds true for
other high-level guidance, such as the indentation section. Move the
text about using block indent rather than visual indent to the
indentation section, so that `principles.md` can focus on guiding
principles while the top level of the style guide gives concrete
formatting recommendations.
2023-06-22 12:30:14 -07:00
Noah Lev
a8fa961696 Align search results horizontally for easy scanning
The recent PR #110688 added info about an item's kind before its name in
search results. However, because the kind and name are inline with no
alignment, it's now hard to visually scan downward through the search
results, looking at item names. This PR fixes that by horizontally
aligning search results such that there are now two columns of
information.
2023-06-22 12:16:48 -07:00
Josh Triplett
9637d44014 style-guide: Fix typo
"does done fit" should have been "does not fit".
2023-06-22 11:53:49 -07:00
Michael Goulet
471830b3a4 migrate inferred_outlives_of to Clause 2023-06-22 18:34:24 +00:00
Michael Goulet
2fa796a3c7 Expect clause more 2023-06-22 18:34:24 +00:00
Michael Goulet
46a650f4e0 Migrate item_bounds to ty::Clause 2023-06-22 18:34:23 +00:00
Augie Fackler
34d0cffcdf switch to using a target property to control plt default 2023-06-22 14:29:22 -04:00
Augie Fackler
dfc5218dc8 rustc_session: default to -Z plt=yes on non-x86_64
Per the discussion in #106380 plt=no isn't a great default, and
rust-lang/compiler-team#581 decided that the default should be PLT=yes
for everything except x86_64. Not everyone agrees about the x86_64 part
of this change, but this at least is an improvement in the state of
things without changing the x86_64 situation, so I've attempted making
this change in the name of not letting the perfect be the enemy of the
good.
2023-06-22 14:29:21 -04:00
bors
04075b3202 Auto merge of #112686 - estebank:sealed-traits, r=petrochenkov
Account for sealed traits in privacy and trait bound errors

On trait bound errors caused by super-traits, identify if the super-trait is publicly accessibly and if not, explain "sealed traits".

```
error[E0277]: the trait bound `S: Hidden` is not satisfied
  --> $DIR/sealed-trait-local.rs:17:20
   |
LL | impl a::Sealed for S {}
   |                    ^ the trait `Hidden` is not implemented for `S`
   |
note: required by a bound in `Sealed`
  --> $DIR/sealed-trait-local.rs:3:23
   |
LL |     pub trait Sealed: self:🅱️:Hidden {
   |                       ^^^^^^^^^^^^^^^ required by this bound in `Sealed`
   = note: `Sealed` is a "sealed trait", because to implement it you also need to implelement `a:🅱️:Hidden`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it
```

Deduplicate privacy errors that point to the same path segment even if their deduplication span are different.

When encountering a path that is not reachable due to privacy constraints path segments other than the last, keep metadata for the last path segment's `Res` in order to look for alternative import paths for that item to suggest. If there are none, be explicit that the item is not accessible.

```
error[E0603]: module `b` is private
  --> $DIR/re-exported-trait.rs:11:9
   |
LL | impl a:🅱️:Trait for S {}
   |         ^ private module
   |
note: the module `b` is defined here
  --> $DIR/re-exported-trait.rs:5:5
   |
LL |     mod b {
   |     ^^^^^
help: consider importing this trait through its public re-export instead
   |
LL | impl a::Trait for S {}
   |      ~~~~~~~~
```

```
error[E0603]: module `b` is private
  --> $DIR/private-trait.rs:8:9
   |
LL | impl a:🅱️:Hidden for S {}
   |         ^  ------ trait `b` is not publicly reachable
   |         |
   |         private module
   |
note: the module `b` is defined here
  --> $DIR/private-trait.rs:2:5
   |
LL |     mod b {
   |     ^^^^^
```
2023-06-22 18:23:19 +00:00
Takayuki Maeda
c8960622a2 avoid &format in error message code 2023-06-23 02:17:39 +09:00
Esteban Küber
7dffd24da5 Tweak privacy errors to account for reachable items
Suggest publicly accessible paths for items in private mod:

  When encountering a path in non-import situations that are not reachable
  due to privacy constraints, search for any public re-exports that the
  user could use instead.

Track whether an import suggestion is offering a re-export.

When encountering a path with private segments, mention if the item at
the final path segment is not publicly accessible at all.

Add item visibility metadata to privacy errors from imports:

  On unreachable imports, record the item that was being imported in order
  to suggest publicly available re-exports or to be explicit that the item
  is not available publicly from any path.

  In order to allow this, we add a mode to `resolve_path` that will not
  add new privacy errors, nor return early if it encounters one. This way
  we can get the `Res` corresponding to the final item in the import,
  which is used in the privacy error machinery.
2023-06-22 16:50:31 +00:00
Esteban Küber
717c481739 Account for sealed traits in trait bound errors
When implementing a public trait with a private super-trait, we now emit
a note that the missing bound is not going to be able to be satisfied,
and we explain the concept of a sealed trait.
2023-06-22 16:50:21 +00:00
Oli Scherer
27b386ad17 Only walk the identity substituted version of struct fields 2023-06-22 15:51:20 +00:00
Oli Scherer
b323f587fc Handle weak type aliases by immediately resolving them to their aliased type 2023-06-22 15:51:19 +00:00
Oli Scherer
b0b4a07959 ICE on types that should not be defining opaque types 2023-06-22 15:51:19 +00:00
Oli Scherer
0af4a211be Document what is going on in opaque_types_defined_by 2023-06-22 15:51:19 +00:00
Oli Scherer
cb161e77ba Move some field extraction logic onto a method on Node 2023-06-22 15:51:19 +00:00
Oli Scherer
30ff127036 Re-use error code for duplicate error 2023-06-22 15:51:14 +00:00
Guillaume Gomez
b858a4745c Update existing snapshot and add more snapshots of where clause indentation 2023-06-22 17:39:23 +02:00
Guillaume Gomez
9202caaec5 Fix indentation for where clause in rustdoc pages 2023-06-22 17:38:19 +02:00
Oli Scherer
d6e1b20623 Fix a codegen test 2023-06-22 15:36:46 +00:00
Oli Scherer
a71628c114 Treat opaque types failing the signature defining scope check as defining, as we already errored and can hide subsequent errors this way. 2023-06-22 15:36:42 +00:00
Oli Scherer
41881aece2 Stop failing eagerly, and collect all opaque types even if some are erroneous. 2023-06-22 15:08:18 +00:00
bors
2efe091705 Auto merge of #112913 - nnethercote:avoid-Lrc-Box-dyn-CodegenBackend, r=compiler-errors
Avoid `Lrc<Box<dyn CodegenBackend>>`.

Because `Lrc<Box<T>>` is silly. (Clippy warns about `Rc<Box<T>>` and `Arc<Box<T>>`, and it would warn here if (a) we used Clippy with rustc, and (b) Clippy knew about `Lrc`.)

r? `@bjorn3`
2023-06-22 15:06:03 +00:00
Oli Scherer
326a9fa8e8 Add tests showcasing our short circuiting behaviour in the signature checks for defining scopes 2023-06-22 15:02:44 +00:00
Oli Scherer
12243ec415 Point to argument/return type instead of the whole function header 2023-06-22 15:00:12 +00:00
Wesley Wiser
da05ed3683
Remove extra trailing newline 2023-06-22 10:37:51 -04:00
Oli Scherer
bae645451e Only create the opaque collector once and visit it many times 2023-06-22 14:31:15 +00:00
Oli Scherer
c8979e587b Move opaque_type_origin_unchecked onto TyCtxt and re-use it where it was open coded 2023-06-22 14:31:15 +00:00
Oli Scherer
aacd702895 Stop hiding const eval limit in external macros 2023-06-22 14:11:10 +00:00
bors
fa06a371b7 Auto merge of #112695 - nnethercote:inline-before-merging-cgus, r=wesleywiser
Inline before merging cgus

Because CGU merging relies on CGU sizes, but the CGU sizes before inlining aren't accurate.

This change doesn't have much effect on compile perf, but it makes follow-on changes that involve more sophisticated reasoning about CGU sizes much easier.

r? `@wesleywiser`
2023-06-22 08:34:32 +00:00
bors
0928a1f757 Auto merge of #112914 - matthiaskrgr:rollup-f0kdqh9, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #112876 (Don't substitute a GAT that has mismatched generics in `OpaqueTypeCollector`)
 - #112906 (rustdoc: render the body of associated types before the where-clause)
 - #112907 (Update cargo)
 - #112908 (Print def_id on EarlyBoundRegion debug)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-22 05:42:01 +00:00
Matthias Krüger
b13c9417cf
Rollup merge of #112908 - spastorino:add-def-id-to-early-bound-region-debug, r=compiler-errors
Print def_id on EarlyBoundRegion debug

It's not the first time that I can't make sense out of the default debug print on `EarlyBoundRegion`. As I was working on #112682 I needed this.

I was doing some git archeology and found that we used to print everything dfbc9608ce/src/librustc/util/ppaux.rs (L425-L430) but we lost the ability in some refactor midway.
2023-06-22 06:29:34 +02:00