]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAuto merge of #91164 - Badel2:usefulness-stack-overflow, r=davidtwco
bors [Fri, 26 Nov 2021 13:42:35 +0000 (13:42 +0000)]
Auto merge of #91164 - Badel2:usefulness-stack-overflow, r=davidtwco

Fix stack overflow in `usefulness.rs`

Fix #88747

Applied the suggestion from `@nbdd0121,` not sure if this has any drawbacks. The first call to `ensure_sufficient_stack` is not needed to fix the test case, but I added it to be safe.

2 years agoAuto merge of #91205 - Aaron1011:visit_param_env, r=lcnr
bors [Fri, 26 Nov 2021 09:55:06 +0000 (09:55 +0000)]
Auto merge of #91205 - Aaron1011:visit_param_env, r=lcnr

Visit `param_env` field in Obligation's `TypeFoldable` impl

This oversight appears to have gone unnoticed for a long time
without causing issues, but it should still be fixed.

2 years agoAuto merge of #91181 - GuillaumeGomez:improve-rustdoc-gui-ci, r=jsha
bors [Fri, 26 Nov 2021 06:44:00 +0000 (06:44 +0000)]
Auto merge of #91181 - GuillaumeGomez:improve-rustdoc-gui-ci, r=jsha

Improve rustdoc-gui CI

As commented [here](https://github.com/rust-lang/rust/pull/91179#discussion_r756023009):

When the text isn't displayed, the color returned by puppeteer is always `rgba(0,0,0,0)`, which is definitely not the right value. To prevent this error from happening again, `browser-ui-test` will now fail if a CSS color check is run when the text isn't displayed.

Either this PR or #91179 is merged first, they'll conflict because I made changes to the same test file.

cc `@jyn514`
r? `@jsha`

2 years agoAuto merge of #85102 - estebank:point-at-assignment, r=oli-obk
bors [Fri, 26 Nov 2021 03:57:55 +0000 (03:57 +0000)]
Auto merge of #85102 - estebank:point-at-assignment, r=oli-obk

Diagnostic tweaks

* On type mismatch caused by assignment, point at the source of the expectation
* Hide redundant errors
* Suggest `while let` when `let` is missing in some cases

2 years agoAuto merge of #91037 - c410-f3r:testsssssss, r=petrochenkov
bors [Thu, 25 Nov 2021 23:53:02 +0000 (23:53 +0000)]
Auto merge of #91037 - c410-f3r:testsssssss, r=petrochenkov

Move some tests to more reasonable directories - 10

cc #73494
r? `@petrochenkov`

2 years agoVisit `param_env` field in Obligation's `TypeFoldable` impl
Aaron Hill [Wed, 24 Nov 2021 23:20:52 +0000 (17:20 -0600)]
Visit `param_env` field in Obligation's `TypeFoldable` impl

This oversight appears to have gone unnoticed for a long time
without causing issues, but it should still be fixed.

2 years agoAuto merge of #90580 - cjgillot:no-ee-upvar, r=Aaron1011
bors [Thu, 25 Nov 2021 19:43:56 +0000 (19:43 +0000)]
Auto merge of #90580 - cjgillot:no-ee-upvar, r=Aaron1011

Remove eval_always from upvars.

Split off https://github.com/rust-lang/rust/pull/86056
r? `@ghost`

2 years agoFix clippy test
Esteban Kuber [Thu, 25 Nov 2021 18:39:32 +0000 (18:39 +0000)]
Fix clippy test

2 years agoAccount for type obligation coming from `const` and `static`
Esteban Kuber [Sun, 21 Nov 2021 01:49:51 +0000 (01:49 +0000)]
Account for type obligation coming from `const` and `static`

2 years agoOn type mismatch caused by assignment, point at assignee
Esteban Küber [Fri, 7 May 2021 02:09:35 +0000 (19:09 -0700)]
On type mismatch caused by assignment, point at assignee

* Do not emit unnecessary E0308 after E0070
* Show fewer errors on `while let` missing `let`
* Hide redundant E0308 on `while let` missing `let`
* Point at binding definition when possible on invalid assignment
* do not point at closure twice
* do not suggest `if let` for literals in lhs
* account for parameter types

2 years agoAuto merge of #91221 - matthiaskrgr:rollup-iuz3gxq, r=matthiaskrgr
bors [Thu, 25 Nov 2021 16:12:04 +0000 (16:12 +0000)]
Auto merge of #91221 - matthiaskrgr:rollup-iuz3gxq, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #89359 (Various fixes for const_trait_impl)
 - #90499 (Link with default MACOSX_DEPLOYMENT_TARGET if not otherwise specified.)
 - #91096 (Print associated types on opaque `impl Trait` types)
 - #91111 (Do not visit attributes in `ItemLowerer`.)
 - #91162 (explain why CTFE/Miri perform truncation on shift offset)
 - #91185 (Remove `-Z force-overflow-checks`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #91185 - camelid:rm-force-overflow-checks, r=wesleywiser
Matthias Krüger [Thu, 25 Nov 2021 14:05:40 +0000 (15:05 +0100)]
Rollup merge of #91185 - camelid:rm-force-overflow-checks, r=wesleywiser

Remove `-Z force-overflow-checks`

It was replaced several years ago by the stable option `-C overflow-checks`.
The goal was to delete the `-Z` flag once users had migrated [1].
Now that it's been several years, it makes sense to delete the old flag.

See also the discussion on Zulip [2].

[1]: https://github.com/rust-lang/rust/issues/33134#issuecomment-280484097
[2]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/overflow.20checks/near/262497224

r? ```@wesleywiser```
cc ```@RalfJung```

2 years agoRollup merge of #91162 - RalfJung:miri-shift-truncation, r=oli-obk
Matthias Krüger [Thu, 25 Nov 2021 14:05:39 +0000 (15:05 +0100)]
Rollup merge of #91162 - RalfJung:miri-shift-truncation, r=oli-obk

explain why CTFE/Miri perform truncation on shift offset

Closes https://github.com/rust-lang/miri/issues/1920

2 years agoRollup merge of #91111 - cjgillot:hir-no-lower-attrs, r=michaelwoerister
Matthias Krüger [Thu, 25 Nov 2021 14:05:38 +0000 (15:05 +0100)]
Rollup merge of #91111 - cjgillot:hir-no-lower-attrs, r=michaelwoerister

Do not visit attributes in `ItemLowerer`.

By default, AST visitors visit expressions that appear in key-value attributes.
Those expressions should not be lowered to HIR, as they do not correspond to actually compiled code.

Since an attribute cannot produce meaningful HIR, just skip them altogether.

Fixes https://github.com/rust-lang/rust/issues/81886
Fixes https://github.com/rust-lang/rust/issues/90873
r? `@michaelwoerister`

2 years agoRollup merge of #91096 - compiler-errors:elaborate_opaque_trait, r=estebank
Matthias Krüger [Thu, 25 Nov 2021 14:05:37 +0000 (15:05 +0100)]
Rollup merge of #91096 - compiler-errors:elaborate_opaque_trait, r=estebank

Print associated types on opaque `impl Trait` types

This PR generalizes #91021, printing associated types for all opaque `impl Trait` types instead of just special-casing for future.

before:
```
error[E0271]: type mismatch resolving `<impl Iterator as Iterator>::Item == u32`
```

after:
```
error[E0271]: type mismatch resolving `<impl Iterator<Item = usize> as Iterator>::Item == u32`
```

---

Questions:
1. I'm kinda lost in binders hell with this one. Is all of the `rebind`ing necessary?
2. Is there a map collection type that will give me a stable iteration order? Doesn't seem like TraitRef is Ord, so I can't just sort later..
3. I removed the logic that suppresses printing generator projection types. It creates outputs like this [gist](https://gist.github.com/compiler-errors/d6f12fb30079feb1ad1d5f1ab39a3a8d). Should I put that back?
4. I also added spaces between traits, `impl A+B` -> `impl A + B`. I quite like this change, but is there a good reason to keep it like that?

r? ````@estebank````

2 years agoRollup merge of #90499 - rusticstuff:macos-target-fixes, r=petrochenkov
Matthias Krüger [Thu, 25 Nov 2021 14:05:36 +0000 (15:05 +0100)]
Rollup merge of #90499 - rusticstuff:macos-target-fixes, r=petrochenkov

Link with default MACOSX_DEPLOYMENT_TARGET if not otherwise specified.

This PR sets the MACOSX_DEPLOYMENT_TARGET environment variable during the linking stage to our default, if it is not specified. This way it matches the deployment target we pass to llvm. If not set the the linker uses Xcode or Xcode commandline tools default which varies by version.

Fixes #90342, #91082.

Drive-by fixes to make Rust behave more like clang:
* Default to 11.0 deployment target for ARM64 which is the earliest version that had support for it.
* Set the llvm target to `arm64-apple-macosx<deployment target>` instead of `aarch64-apple-macosx<deployment target>`.

2 years agoRollup merge of #89359 - fee1-dead:const-it, r=oli-obk
Matthias Krüger [Thu, 25 Nov 2021 14:05:35 +0000 (15:05 +0100)]
Rollup merge of #89359 - fee1-dead:const-it, r=oli-obk

Various fixes for const_trait_impl

A few problems I found while making `Iterator` easier to const-implement.

1. More generous `~const Drop` check.

We check for nested fields with caller bounds.

For example, an ADT type with fields of types `A`, `B`, `C`, check if all of them are either:
 - Bounded (`A: ~const Drop`, `B: Copy`)
 - Known to be able to destruct at compile time (`C = i32`, `struct C(i32)`, `C = some_fn`)

2. Don't treat trait functions marked with `#[default_method_body_is_const]` as stable const fns when checking `const_for` and `const_try` feature gates.

I think anyone can review this, so no r? this time.

2 years agoImprove tests
Guillaume Gomez [Wed, 24 Nov 2021 17:01:34 +0000 (18:01 +0100)]
Improve tests

2 years agoUpdate browser-ui-test version to enforce that text is displayed before checking...
Guillaume Gomez [Wed, 24 Nov 2021 17:01:20 +0000 (18:01 +0100)]
Update browser-ui-test version to enforce that text is displayed before checking colors

2 years agoAuto merge of #91195 - camelid:path-did, r=jyn514
bors [Thu, 25 Nov 2021 13:11:35 +0000 (13:11 +0000)]
Auto merge of #91195 - camelid:path-did, r=jyn514

rustdoc: Remove `ResolvedPath.did`

`ResolvedPath.did` was not actually the same as `.path.def_id()`. Instead,
`.did` referred to the `DefId` of the page to be used as a hyperlink target.
For example, a link to `Struct::method()` would use `Struct`'s `DefId` as its
`.did` field. This behavior is confusing, easy to accidentally misuse, and can
instead be obtained on-demand when computing hyperlink targets. It's also likely
part of the reason `kind_side_channel` exists. I'm currently working on some
experimental refactorings in `collect_intra_doc_links` that I believe require --
or at least benefit from -- removing `.did`.

r? `@jyn514`

2 years agoMove some tests to more reasonable directories
Caio [Fri, 19 Nov 2021 10:18:00 +0000 (07:18 -0300)]
Move some tests to more reasonable directories

2 years agoAuto merge of #88781 - estebank:emoji-idents, r=oli-obk
bors [Thu, 25 Nov 2021 08:16:08 +0000 (08:16 +0000)]
Auto merge of #88781 - estebank:emoji-idents, r=oli-obk

Tokenize emoji as if they were valid identifiers

In the lexer, consider emojis to be valid identifiers and reject
them later to avoid knock down parse errors.

Partially address #86102.

2 years agoSet MACOSX_DEPLOYMENT_TARGET env var to default for linking if not set.
Hans Kratz [Tue, 2 Nov 2021 12:52:47 +0000 (13:52 +0100)]
Set MACOSX_DEPLOYMENT_TARGET env var to default for linking if not set.

2 years agoSet the default deployment target for Macos ARM64 to 11.0.
Hans Kratz [Tue, 2 Nov 2021 11:41:56 +0000 (12:41 +0100)]
Set the default deployment target for Macos ARM64 to 11.0.

11.0 (Big Sur) is the first version which supports ARM64 so we use
that as default.

2 years agoThe correct LLVM target for aarch64-apple-darwin is arm64-... (as with ios)
Hans Kratz [Tue, 2 Nov 2021 10:46:06 +0000 (11:46 +0100)]
The correct LLVM target for aarch64-apple-darwin is arm64-... (as with ios)

2 years agoAuto merge of #85346 - estebank:issue-84946, r=nagisa,varkor
bors [Thu, 25 Nov 2021 05:09:51 +0000 (05:09 +0000)]
Auto merge of #85346 - estebank:issue-84946, r=nagisa,varkor

Account for incorrect `impl Foo<const N: ty> {}` syntax

Fix #84946

2 years agoUpdate cargo to fix tokenizer test affected by tokenizing emoji
Esteban Kuber [Thu, 25 Nov 2021 00:19:50 +0000 (00:19 +0000)]
Update cargo to fix tokenizer test affected by tokenizing emoji

2 years agoUpdate comment
Noah Lev [Wed, 24 Nov 2021 23:32:03 +0000 (18:32 -0500)]
Update comment

Co-authored-by: Joshua Nelson <github@jyn.dev>
2 years agoDo not visit attributes in `LateResolutionVisitor`.
Camille GILLOT [Wed, 24 Nov 2021 22:07:13 +0000 (23:07 +0100)]
Do not visit attributes in `LateResolutionVisitor`.

2 years agoAuto merge of #91203 - GuillaumeGomez:rollup-kwtqvb1, r=GuillaumeGomez
bors [Wed, 24 Nov 2021 23:09:42 +0000 (23:09 +0000)]
Auto merge of #91203 - GuillaumeGomez:rollup-kwtqvb1, r=GuillaumeGomez

Rollup of 7 pull requests

Successful merges:

 - #89542 (Partially stabilize `duration_consts_2`)
 - #90044 (Restrict aarch64 outline atomics to glibc for now.)
 - #90420 (Create rustdoc_internals feature gate)
 - #91075 (Reduce prominence of item-infos)
 - #91151 (Fix test in std::process on android)
 - #91179 (Fix more <a> color)
 - #91199 (rustdoc: Add test for mixing doc comments and attrs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoTweak span and add more tests
Esteban Kuber [Wed, 24 Nov 2021 20:24:14 +0000 (20:24 +0000)]
Tweak span and add more tests

2 years agoRollup merge of #91199 - camelid:test-mixing-docs, r=GuillaumeGomez
Guillaume Gomez [Wed, 24 Nov 2021 21:56:40 +0000 (22:56 +0100)]
Rollup merge of #91199 - camelid:test-mixing-docs, r=GuillaumeGomez

rustdoc: Add test for mixing doc comments and attrs

This is a step toward adding more test coverage to make it easier to
remove the distinction between collapsed and uncollapsed doc values.

2 years agoRollup merge of #91179 - GuillaumeGomez:a-color, r=jsha
Guillaume Gomez [Wed, 24 Nov 2021 21:56:39 +0000 (22:56 +0100)]
Rollup merge of #91179 - GuillaumeGomez:a-color, r=jsha

Fix more <a> color

Fixes #91175.

Another bug I saw is:

![Screenshot from 2021-11-24 11-41-27](https://user-images.githubusercontent.com/3050060/143239845-f173cfeb-8f5c-4215-a5af-b71d4e1bcd84.png)

I fixed it as well.

r? ``@jsha``

2 years agoRollup merge of #91151 - name1e5s:chore/process_test, r=m-ou-se
Guillaume Gomez [Wed, 24 Nov 2021 21:56:38 +0000 (22:56 +0100)]
Rollup merge of #91151 - name1e5s:chore/process_test, r=m-ou-se

Fix test in std::process on android

closes #10380

2 years agoRollup merge of #91075 - jsha:chill-item-info, r=GuillaumeGomez
Guillaume Gomez [Wed, 24 Nov 2021 21:56:37 +0000 (22:56 +0100)]
Rollup merge of #91075 - jsha:chill-item-info, r=GuillaumeGomez

Reduce prominence of item-infos

Fixes #59853

 - Remove border.
 - Reduce size of emoji slightly.
 - Remove details disclosure for unstable reason. This was inconsistent with our other details disclosures, and the detail revealed was usually better explained by clicking on the issue link.

Demo: https://rustdoc.crud.net/jsha/chill-item-info/std/mem/union.MaybeUninit.html#method.slice_assume_init_ref

Compare vs: https://doc.rust-lang.org/nightly/std/mem/union.MaybeUninit.html#method.slice_assume_init_ref

<img src="https://user-images.githubusercontent.com/220205/142717815-09828c9e-6ff4-445a-8ccc-31e028fd4985.png" width=700>

2 years agoRollup merge of #90420 - GuillaumeGomez:rustdoc-internals-feature, r=camelid
Guillaume Gomez [Wed, 24 Nov 2021 21:56:37 +0000 (22:56 +0100)]
Rollup merge of #90420 - GuillaumeGomez:rustdoc-internals-feature, r=camelid

Create rustdoc_internals feature gate

As suggested by ``@camelid`` [here](https://github.com/rust-lang/rust/pull/90398#issuecomment-955093851), since `doc_keyword` and `doc_primitive` aren't meant to be stabilized, we could put them behind a same feature flag.

This is pretty much what it would look like (needs to update the tests too).

The tracking issue is https://github.com/rust-lang/rust/issues/90418.

What do you think ``@rust-lang/rustdoc`` ?

2 years agoRollup merge of #90044 - rusticstuff:disable_arm_outline_atomics_for_musl, r=workingj...
Guillaume Gomez [Wed, 24 Nov 2021 21:56:36 +0000 (22:56 +0100)]
Rollup merge of #90044 - rusticstuff:disable_arm_outline_atomics_for_musl, r=workingjubilee

Restrict aarch64 outline atomics to glibc for now.

The introduced dependency on `getauxval` causes linking problems with musl, making compiling any binaries for `aarch64-unknown-linux-musl` impossible without workarounds such as using lld or adding liblibc.rlib again to the linker invocation, see #89626.

This is a workaround until libc>0.2.108 is merged.

2 years agoRollup merge of #89542 - jhpratt:stabilize-duration-const-fns, r=oli-obk
Guillaume Gomez [Wed, 24 Nov 2021 21:56:35 +0000 (22:56 +0100)]
Rollup merge of #89542 - jhpratt:stabilize-duration-const-fns, r=oli-obk

Partially stabilize `duration_consts_2`

Methods that were only blocked on `const_panic` have been stabilized.
The remaining methods of `duration_consts_2` are all related to floats,
and as such have been placed behind the `duration_consts_float` feature
gate.

2 years agorustdoc: Add test for mixing doc comments and attrs
Noah Lev [Wed, 24 Nov 2021 21:16:10 +0000 (13:16 -0800)]
rustdoc: Add test for mixing doc comments and attrs

This is a step toward adding more test coverage to make it easier to
remove the distinction between collapsed and uncollapsed doc values.

2 years agoAdd test for merged features
Guillaume Gomez [Wed, 17 Nov 2021 20:09:45 +0000 (21:09 +0100)]
Add test for merged features

2 years agoUpdate error message for doc(keyword)
Guillaume Gomez [Mon, 8 Nov 2021 19:00:22 +0000 (20:00 +0100)]
Update error message for doc(keyword)

2 years agoAdd feature gate test for "rustdoc_internal" feature
Guillaume Gomez [Mon, 8 Nov 2021 16:27:56 +0000 (17:27 +0100)]
Add feature gate test for "rustdoc_internal" feature

2 years agoCreate rustdoc_internals feature gate
Guillaume Gomez [Sat, 30 Oct 2021 15:44:50 +0000 (17:44 +0200)]
Create rustdoc_internals feature gate

2 years agoRemove `ResolvedPath.did`
Noah Lev [Thu, 11 Nov 2021 23:45:45 +0000 (15:45 -0800)]
Remove `ResolvedPath.did`

2 years agoAuto merge of #91188 - jsha:fix-click-items, r=Manishearth
bors [Wed, 24 Nov 2021 20:03:33 +0000 (20:03 +0000)]
Auto merge of #91188 - jsha:fix-click-items, r=Manishearth

Fix clicking on anchors inside summary tags

Fixes #91184

r? `@camelid`

2 years agoChange how the fn params span is calculated
Esteban Kuber [Wed, 24 Nov 2021 17:11:15 +0000 (17:11 +0000)]
Change how the fn params span is calculated

Use the available Generics span field to avoid issues with `T: Fn()` bounds.

This is necessary to land #85346.

2 years agoAccount for incorrect `impl Foo<const N: ty> {}` syntax
Esteban Küber [Sat, 15 May 2021 21:56:28 +0000 (14:56 -0700)]
Account for incorrect `impl Foo<const N: ty> {}` syntax

Fix #84946

2 years agoUse `path.def_id()` in `Type::inner_def_id()`
Noah Lev [Thu, 11 Nov 2021 23:35:10 +0000 (15:35 -0800)]
Use `path.def_id()` in `Type::inner_def_id()`

2 years agoReturn the actual `DefId` for assoc. items in `register_res`
Noah Lev [Thu, 11 Nov 2021 23:05:25 +0000 (15:05 -0800)]
Return the actual `DefId` for assoc. items in `register_res`

Before, if `register_res` were called on an associated item or enum
variant, it would return the parent's `DefId`. Now, it returns the
actual `DefId`.

This change is a step toward removing `Type::ResolvedPath.did` and
potentially removing `kind_side_channel` in rustdoc. It also just
simplifies rustdoc's behavior.

2 years agoFix clicking on anchors inside summary tags.
Jacob Hoffman-Andrews [Wed, 24 Nov 2021 18:43:58 +0000 (10:43 -0800)]
Fix clicking on anchors inside summary tags.

2 years agoRemove `-Z force-overflow-checks`
Noah Lev [Wed, 24 Nov 2021 18:19:23 +0000 (10:19 -0800)]
Remove `-Z force-overflow-checks`

It was replaced several years ago by the stable option `-C
overflow-checks`. The goal was to delete the `-Z` flag once users had
migrated [1]. Now that it's been several years, it makes sense to delete
the old flag.

See also the discussion on Zulip [2].

[1]: https://github.com/rust-lang/rust/issues/33134#issuecomment-280484097
[2]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/overflow.20checks/near/262497224

2 years agoAuto merge of #90491 - Mark-Simulacrum:push-pred-faster, r=matthewjasper
bors [Wed, 24 Nov 2021 15:51:46 +0000 (15:51 +0000)]
Auto merge of #90491 - Mark-Simulacrum:push-pred-faster, r=matthewjasper

Optimize live point computation

This refactors the live-point computation to lower per-MIR-instruction costs by operating on a largely per-block level. This doesn't fundamentally change the number of operations necessary, but it greatly improves the practical performance by aggregating bit manipulation into ranges rather than single-bit; this scales much better with larger blocks.

On the benchmark provided in #90445, with 100,000 array elements, walltime for a check build is improved from 143 seconds to 15.

I consider the tiny losses here acceptable given the many small wins on real world benchmarks and large wins on stress tests. The new code scales much better, but on some subset of inputs the slightly higher constant overheads decrease performance somewhat. Overall though, this is expected to be a big win for pathological cases (as illustrated by the test case motivating this work) and largely not material for non-pathological cases. I consider the new code somewhat easier to follow, too.

2 years agoUpdate GUI tests for <a> color
Guillaume Gomez [Wed, 24 Nov 2021 12:35:25 +0000 (13:35 +0100)]
Update GUI tests for <a> color

2 years agoFix more <a> color
Guillaume Gomez [Wed, 24 Nov 2021 12:35:15 +0000 (13:35 +0100)]
Fix more <a> color

2 years agoAuto merge of #90579 - cjgillot:no-ee-ii, r=Aaron1011
bors [Wed, 24 Nov 2021 12:51:19 +0000 (12:51 +0000)]
Auto merge of #90579 - cjgillot:no-ee-ii, r=Aaron1011

Remove eval_always for inherent_impls.

Split off https://github.com/rust-lang/rust/pull/86056
r? `@ghost`

2 years agoAuto merge of #91171 - jsha:fix-rustdoc-gui-test, r=GuillaumeGomez
bors [Wed, 24 Nov 2021 09:43:47 +0000 (09:43 +0000)]
Auto merge of #91171 - jsha:fix-rustdoc-gui-test, r=GuillaumeGomez

Fix toggle-click-deadspace rustdoc-gui test

In #91103 I introduced a rustdoc-gui test for clicks on toggles. I introduced some documentation on a method in lib2/struct.Foo.html so there would be something to toggle, but accidentally left the test checking test_docs/struct.Foo.html. That caused the test to reliably fail.

I'm not sure how that test got past GitHub Actions and bors, but it's manifesting in test failures at https://github.com/rust-lang/rust/pull/91062#issuecomment-977589705 and https://github.com/rust-lang/rust/pull/91170#issuecomment-977636159.

This fixes by pointing at the right file.

r? `@GuillaumeGomez`

2 years agoFix toggle-click-deadspace rustdoc-gui test
Jacob Hoffman-Andrews [Wed, 24 Nov 2021 08:58:07 +0000 (00:58 -0800)]
Fix toggle-click-deadspace rustdoc-gui test

2 years agoAdd impl polarity to fields
Deadbeef [Wed, 24 Nov 2021 08:07:38 +0000 (16:07 +0800)]
Add impl polarity to fields

2 years agoAllow features like const_try in d_m_b_i_c
Deadbeef [Wed, 29 Sep 2021 12:15:35 +0000 (12:15 +0000)]
Allow features like const_try in d_m_b_i_c

2 years agoAllow more cases to match ~const Drop.
Deadbeef [Wed, 29 Sep 2021 12:15:17 +0000 (12:15 +0000)]
Allow more cases to match ~const Drop.

2 years agoDebug
Deadbeef [Wed, 29 Sep 2021 12:12:21 +0000 (12:12 +0000)]
Debug

2 years agodocument BinOp behavior quirks in the corresponding enum
Ralf Jung [Wed, 24 Nov 2021 01:30:26 +0000 (20:30 -0500)]
document BinOp behavior quirks in the corresponding enum

2 years agoAuto merge of #91149 - notriddle:notriddle/rustdoc-doctest-semicolon, r=jyn514
bors [Tue, 23 Nov 2021 23:48:55 +0000 (23:48 +0000)]
Auto merge of #91149 - notriddle:notriddle/rustdoc-doctest-semicolon, r=jyn514

fix(doctest): detect extern crate items in statement doctests

This partially reverts #91026, because rustdoc needs to detect the extern statements, even when they appear inside implicit `main()`. It does not entirely revert it, so the old bug is still fixed, by duplicating some of the logic from `parse_mod` instead of trying to use it directly.

Fixes #91134

2 years agoFix stack overflow in `usefulness.rs`
Badel2 [Tue, 23 Nov 2021 21:55:48 +0000 (22:55 +0100)]
Fix stack overflow in `usefulness.rs`

2 years agoDo not visit attributes in `ItemLowerer`.
Camille GILLOT [Sun, 21 Nov 2021 15:16:02 +0000 (16:16 +0100)]
Do not visit attributes in `ItemLowerer`.

By default, AST visitors visit expressions that appear in key-value attributes.
Those expressions should not be lowered to HIR, as they do not correspond to actually compiled code.

Since an attribute cannot produce meaningful HIR, just skip them altogether.

2 years agoAuto merge of #91159 - matthiaskrgr:rollup-91mgg5v, r=matthiaskrgr
bors [Tue, 23 Nov 2021 20:44:33 +0000 (20:44 +0000)]
Auto merge of #91159 - matthiaskrgr:rollup-91mgg5v, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #90856 (Suggestion to wrap inner types using 'allocator_api' in tuple)
 - #91103 (Inhibit clicks on summary's children)
 - #91137 (Give people a single link they can click in the contributing guide)
 - #91140 (Split inline const to two feature gates and mark expression position inline const complete)
 - #91148 (Use `derive_default_enum` in the compiler)
 - #91153 (kernel_copy: avoid panic on unexpected OS error)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoSort `FxHashSet`'s contents before emitting errors for consistent output
Esteban Kuber [Tue, 14 Sep 2021 11:39:49 +0000 (11:39 +0000)]
Sort `FxHashSet`'s contents before emitting errors for consistent output

2 years agoudpate comment to be more accurate
Esteban Kuber [Fri, 10 Sep 2021 07:36:01 +0000 (07:36 +0000)]
udpate comment to be more accurate

2 years ago`replace_tabs` -> `normalize_whitespace`
Esteban Kuber [Fri, 10 Sep 2021 07:32:07 +0000 (07:32 +0000)]
`replace_tabs` -> `normalize_whitespace`

2 years agoreview comment: plural of emoji is emoji
Esteban Kuber [Fri, 10 Sep 2021 07:30:58 +0000 (07:30 +0000)]
review comment: plural of emoji is emoji

2 years agoAccount for confusable codepoints when recovering emoji identifiers
Esteban Kuber [Thu, 9 Sep 2021 17:05:03 +0000 (17:05 +0000)]
Account for confusable codepoints when recovering emoji identifiers

2 years agofix fmt
Esteban Kuber [Thu, 9 Sep 2021 15:55:21 +0000 (15:55 +0000)]
fix fmt

2 years agoAdd `unic-emoji-char` and its dependencies to the allow list
Esteban Kuber [Thu, 9 Sep 2021 15:41:15 +0000 (15:41 +0000)]
Add `unic-emoji-char` and its dependencies to the allow list

2 years agoFix RustDoc
Esteban Kuber [Thu, 9 Sep 2021 15:22:29 +0000 (15:22 +0000)]
Fix RustDoc

2 years agoReplace ZWJ with nothing in terminal output
Esteban Kuber [Thu, 9 Sep 2021 15:01:43 +0000 (15:01 +0000)]
Replace ZWJ with nothing in terminal output

2 years agoTokenize emoji as if they were valid indentifiers
Esteban Kuber [Sun, 29 Aug 2021 08:34:23 +0000 (08:34 +0000)]
Tokenize emoji as if they were valid indentifiers

In the lexer, consider emojis to be valid identifiers and reject
them later to avoid knock down parse errors.

2 years agoexplain why CTFE/Miri perform truncation on shift offset
Ralf Jung [Tue, 23 Nov 2021 19:12:14 +0000 (14:12 -0500)]
explain why CTFE/Miri perform truncation on shift offset

2 years agoFix printing unit return ty, don't elaborate FnOnce unless we see it
Michael Goulet [Tue, 23 Nov 2021 18:34:01 +0000 (10:34 -0800)]
Fix printing unit return ty, don't elaborate FnOnce unless we see it

2 years agoUpdate test outputs
Michael Goulet [Sat, 20 Nov 2021 04:51:44 +0000 (20:51 -0800)]
Update test outputs

2 years agoSuppress noisy generator associated type
Michael Goulet [Mon, 22 Nov 2021 05:15:57 +0000 (21:15 -0800)]
Suppress noisy generator associated type

2 years agoAdd generator lang-item
Michael Goulet [Mon, 22 Nov 2021 05:15:27 +0000 (21:15 -0800)]
Add generator lang-item

2 years agoElaborate trait generics and associated types
Michael Goulet [Sat, 20 Nov 2021 04:51:19 +0000 (20:51 -0800)]
Elaborate trait generics and associated types

2 years agoAdd supertraits method to rustc_middle
Michael Goulet [Mon, 22 Nov 2021 04:43:48 +0000 (20:43 -0800)]
Add supertraits method to rustc_middle

2 years agoDerive Ord and PartialOrd for TraitRef
Michael Goulet [Mon, 22 Nov 2021 04:41:46 +0000 (20:41 -0800)]
Derive Ord and PartialOrd for TraitRef

2 years agoRollup merge of #91153 - birkenfeld:kernel_copy_fallback, r=the8472
Matthias Krüger [Tue, 23 Nov 2021 18:28:12 +0000 (19:28 +0100)]
Rollup merge of #91153 - birkenfeld:kernel_copy_fallback, r=the8472

kernel_copy: avoid panic on unexpected OS error

According to documentation, the listed errnos should only occur
if the `copy_file_range` call cannot be made at all, so the
assert be correct.  However, since in practice file system
drivers (incl. FUSE etc.) can return any errno they want, we
should not panic here.

Fixes #91152

2 years agoRollup merge of #91148 - jhpratt:use-default-enum, r=petrochenkov
Matthias Krüger [Tue, 23 Nov 2021 18:28:11 +0000 (19:28 +0100)]
Rollup merge of #91148 - jhpratt:use-default-enum, r=petrochenkov

Use `derive_default_enum` in the compiler

Let's get this feature some real-world love.

``@rustbot`` label: +C-cleanup +S-waiting-on-review

2 years agoRollup merge of #91140 - nbdd0121:const_typeck, r=oli-obk
Matthias Krüger [Tue, 23 Nov 2021 18:28:10 +0000 (19:28 +0100)]
Rollup merge of #91140 - nbdd0121:const_typeck, r=oli-obk

Split inline const to two feature gates and mark expression position inline const complete

This PR splits inline const in pattern position into its own `#![feature(inline_const_pat)]` feature gate, and make the usage in expression position complete.

I think I have resolved most outstanding issues related to `inline_const` with #89561 and other PRs. The only thing left that I am aware of is #90150 and the lack of lifetime checks when inline const is used in pattern position (FIXME in #89561). Implementation-wise when used in pattern position it has to be lowered during MIR building while in expression position it's evaluated only when monomorphizing (just like normal consts), so it makes some sense to separate it into two feature gates so one can progress without being blocked by another.

``@rustbot`` label: T-compiler F-inline_const

2 years agoRollup merge of #91137 - jyn514:contributing, r=spastorino
Matthias Krüger [Tue, 23 Nov 2021 18:28:09 +0000 (19:28 +0100)]
Rollup merge of #91137 - jyn514:contributing, r=spastorino

Give people a single link they can click in the contributing guide

Doc Jones mentioned that one of the things making it hard to get started
is that the amount of information is overwhelming, between the
dev-guide, contributing guide, and discussion platforms. This gives
people a single link they can click to ask for help.

cc ``@doc-jones`` - is this what you had in mind?

2 years agoRollup merge of #91103 - jsha:non-toggle-click-doesnt-toggle, r=Manishearth,Guillaume...
Matthias Krüger [Tue, 23 Nov 2021 18:28:07 +0000 (19:28 +0100)]
Rollup merge of #91103 - jsha:non-toggle-click-doesnt-toggle, r=Manishearth,GuillaumeGomez

Inhibit clicks on summary's children

A byproduct of using `<details>` and `<summary>` to show/hide detailed documentation was that clicking any part of a method heading (or impl heading) would show or hide the documentation. This was not super noticeable because clicking a link inside the method heading would navigate to that link. But clicking any unlinked black text in a method heading would trigger the behavior.

That behavior was somewhat unexpected, and means that if you try to click a type name in a method heading, but miss by a few pixels, you get a confusing surprise.

This change inhibits that behavior by putting an event listener on most summaries that cancels the event unless the event target was the summary itself. In practice, that means it cancels the event unless the target was the "[+]" / "[-]", because the rest of the heading is wrapped inside a `<div>`, which is the target for anything that doesn't have a more specific target.

r? ``@Manishearth``

2 years agoRollup merge of #90856 - ken-matsui:suggestion-to-wrap-vec-allocator-api-in-tuple...
Matthias Krüger [Tue, 23 Nov 2021 18:28:06 +0000 (19:28 +0100)]
Rollup merge of #90856 - ken-matsui:suggestion-to-wrap-vec-allocator-api-in-tuple, r=davidtwco

Suggestion to wrap inner types using 'allocator_api' in tuple

This PR provides a suggestion to wrap the inner types in tuple when being along with 'allocator_api'.

Closes https://github.com/rust-lang/rust/issues/83250

```rust
fn main() {
    let _vec: Vec<u8, _> = vec![]; //~ ERROR use of unstable library feature 'allocator_api'
}
```

```diff
 error[E0658]: use of unstable library feature 'allocator_api'
   --> $DIR/suggest-vec-allocator-api.rs:2:23
    |
 LL |     let _vec: Vec<u8, _> = vec![];
-   |                       ^
+   |                   ----^
+   |                   |
+   |                   help: consider wrapping the inner types in tuple: `(u8, _)`
    |
    = note: see issue #32838 <https://github.com/rust-lang/rust/issues/32838> for more information
    = help: add `#![feature(allocator_api)]` to the crate attributes to enable
```

2 years agoAuto merge of #90788 - ecstatic-morse:issue-90752, r=wesleywiser
bors [Tue, 23 Nov 2021 17:44:33 +0000 (17:44 +0000)]
Auto merge of #90788 - ecstatic-morse:issue-90752, r=wesleywiser

Mark places as initialized when mutably borrowed

Fixes the example in #90752, but does not handle some corner cases involving raw pointers and unsafe. See [this comment](https://github.com/rust-lang/rust/issues/90752#issuecomment-965822895) for more information, or the second test.

Although I talked about both `MaybeUninitializedPlaces` and `MaybeInitializedPlaces` in #90752, this PR only changes the latter. That's because "maybe uninitialized" is the conservative choice, and marking them as definitely initialized (`!maybe_uninitialized`) when a mutable borrow is created could lead to problems if `addr_of_mut` to an uninitialized local is allowed. Additionally, places cannot become uninitialized via a mutable reference, so if a place is definitely initialized, taking a mutable reference to it should not change that.

I think it's correct to ignore interior mutability as nbdd0121 suggests below. Their analysis doesn't work inside of `core::cell`, which *does* have access to `UnsafeCell`'s field, but that won't be an issue unless we explicitly instantiate one with an `enum` within that module.

r? `@wesleywiser`

2 years agoSuggestion to wrap inner types using `allocator_api` in tuple
Ken Matsui [Sat, 13 Nov 2021 07:39:54 +0000 (16:39 +0900)]
Suggestion to wrap inner types using `allocator_api` in tuple

2 years agoAuto merge of #89881 - Mark-Simulacrum:fieldless-fast, r=davidtwco
bors [Tue, 23 Nov 2021 13:56:00 +0000 (13:56 +0000)]
Auto merge of #89881 - Mark-Simulacrum:fieldless-fast, r=davidtwco

Avoid generating empty closures for fieldless enum variants

For many enums, this avoids generating lots of tiny stubs that need to be codegen'd and then inlined and removed by LLVM. perf shows this to be a fairly small, but significant, win on rustc bootstrap time -- with minimal impact on runtime performance (which is at times even positive).

2 years agokernel_copy: avoid panic on unexpected OS error
Georg Brandl [Tue, 23 Nov 2021 07:09:48 +0000 (08:09 +0100)]
kernel_copy: avoid panic on unexpected OS error

According to documentation, the listed errnos should only occur
if the `copy_file_range` call cannot be made at all, so the
assert be correct.  However, since in practice file system
drivers (incl. FUSE etc.) can return any errno they want, we
should not panic here.

Fixes #91152

2 years agoAuto merge of #89883 - Mark-Simulacrum:incr-verify-outline, r=nnethercote
bors [Tue, 23 Nov 2021 09:10:50 +0000 (09:10 +0000)]
Auto merge of #89883 - Mark-Simulacrum:incr-verify-outline, r=nnethercote

Manually outline error on incremental_verify_ich

This reduces codegen for rustc_query_impl by 169k lines of LLVM IR, representing
a 1.2% improvement. This code should be fairly cold, so hopefully this has minimal
performance impact.

2 years agoAuto merge of #84197 - bbjornse:stack-protector, r=nikic
bors [Tue, 23 Nov 2021 06:08:37 +0000 (06:08 +0000)]
Auto merge of #84197 - bbjornse:stack-protector, r=nikic

add codegen option for using LLVM stack smash protection

LLVM has built-in heuristics for adding stack canaries to functions. These
heuristics can be selected with LLVM function attributes. This PR adds a codegen
option `-C stack-protector={basic,strong,all}` which controls the use of these
attributes. This gives rustc the same stack smash protection support as clang
offers through options `-fstack-protector`, `-fstack-protector-strong`, and
`-fstack-protector-all`. The protection this can offer is demonstrated in
test/ui/abi/stack-protector.rs. This fills a gap in the current list of rustc
exploit mitigations (https://doc.rust-lang.org/rustc/exploit-mitigations.html),
originally discussed in #15179.

Stack smash protection adds runtime overhead and is therefore still off by
default, but now users have the option to trade performance for security as they
see fit. An example use case is adding Rust code in an existing C/C++ code base
compiled with stack smash protection. Without the ability to add stack smash
protection to the Rust code, the code base artifacts could be exploitable in
ways not possible if the code base remained pure C/C++.

Stack smash protection support is present in LLVM for almost all the current
tier 1/tier 2 targets: see
test/assembly/stack-protector/stack-protector-target-support.rs. The one
exception is nvptx64-nvidia-cuda. This PR follows clang's example, and adds a
warning message printed if stack smash protection is used with this target (see
test/ui/stack-protector/warn-stack-protector-unsupported.rs). Support for tier 3
targets has not been checked.

Since the heuristics are applied at the LLVM level, the heuristics are expected
to add stack smash protection to a fraction of functions comparable to C/C++.
Some experiments demonstrating how Rust code is affected by the different
heuristics can be found in
test/assembly/stack-protector/stack-protector-heuristics-effect.rs. There is
potential for better heuristics using Rust-specific safety information. For
example it might be reasonable to skip stack smash protection in functions which
transitively only use safe Rust code, or which uses only a subset of functions
the user declares safe (such as anything under `std.*`). Such alternative
heuristics could be added at a later point.

LLVM also offers a "safestack" sanitizer as an alternative way to guard against
stack smashing (see #26612). This could possibly also be included as a
stack-protection heuristic. An alternative is to add it as a sanitizer (#39699).
This is what clang does: safestack is exposed with option
`-fsanitize=safe-stack`.

The options are only supported by the LLVM backend, but as with other codegen
options it is visible in the main codegen option help menu. The heuristic names
"basic", "strong", and "all" are hopefully sufficiently generic to be usable in
other backends as well.

2 years agofix test in std::process on android
name1e5s [Tue, 23 Nov 2021 05:40:19 +0000 (13:40 +0800)]
fix test in std::process on android

2 years agoUpdate issue-91134.stdout
Michael Howell [Tue, 23 Nov 2021 04:00:42 +0000 (21:00 -0700)]
Update issue-91134.stdout

2 years agoAuto merge of #91094 - inquisitivecrystal:rustdoc-top-mod, r=jyn514
bors [Tue, 23 Nov 2021 03:13:26 +0000 (03:13 +0000)]
Auto merge of #91094 - inquisitivecrystal:rustdoc-top-mod, r=jyn514

Avoid documenting top-level private imports

PR #88447 aimed to make rustdoc's `--document-private-items` mode only document imports that are visible outside the importing module. Unfortunately, I inadvertently set things up so that imports at the crate top-level are always documented, regardless of their visibility. This behavior was unintended and is [not desirable](https://github.com/rust-lang/rust/issues/90865#issuecomment-971172649).

This PR treats top-level imports as never being visible outside their parent module. In practice, the only way a top-level import can be visible externally is if it's fully public, and there's a seperate check for that.

It's worth calling attention to the fact that this change means that `pub(crate)` imports will be visible in lower level modules, but not at the top-level. This is because, at the top level of the crate, `pub(crate)` means the same thing as `pub(self)`.

It turned out that there were existing tests checking for the only behavior, which I didn't notice at the time of my previous PR. I have updated them to check for the new behavior and substantially extended them to handle differences between the top-level module and lower level modules. I may have gone overboard, so please tell me if there's anything I should cut.

r? `@jyn514`

Fixes #90865.

2 years agofix(doctest): detect extern crate items in statement doctests
Michael Howell [Tue, 23 Nov 2021 02:47:58 +0000 (19:47 -0700)]
fix(doctest): detect extern crate items in statement doctests

This partially reverts #91026, because rustdoc needs to detect the extern statements,
even when they appear inside implicit `main()`. It does not entirely revert it,
so the old bug is still fixed, by duplicating some of the logic from `parse_mod`
instead of trying to use it directly.

Fixes #91134