Commit Graph

161391 Commits

Author SHA1 Message Date
David Tolnay
6e8b06015e
Simplify the buffer push done by scan_break 2022-01-18 19:35:43 -08:00
David Tolnay
fe5c4eab2d
Eliminate a check_stack call on an empty scan stack 2022-01-18 19:23:22 -08:00
David Tolnay
377c9dbabf
Index a single time in check_stack 2022-01-18 19:21:18 -08:00
David Tolnay
a37d272892
Implement check_stack nonrecursively 2022-01-18 19:20:33 -08:00
David Tolnay
0490e43422
Implement check_stream nonrecursively 2022-01-18 19:19:18 -08:00
David Tolnay
947a09a4a8
Replace if + unwrap with if let in check_stack 2022-01-18 19:18:47 -08:00
David Tolnay
80139a0f02
Ensure Printer buf is always indexed using self.left or self.right 2022-01-18 19:18:04 -08:00
David Tolnay
ae28ec5a9c
Inline Printer's scan_pop_bottom method 2022-01-18 19:16:33 -08:00
David Tolnay
2a14275500
Inline Printer's scan_top method 2022-01-18 19:16:32 -08:00
David Tolnay
e20d5abdfb
Inline Printer's scan_pop method 2022-01-18 19:16:32 -08:00
David Tolnay
50d722a691
Simplify ring buffer pushes 2022-01-18 19:07:12 -08:00
David Tolnay
e219b2b5f9
Inline Printer's scan_push method 2022-01-18 19:04:12 -08:00
David Tolnay
fdb95f54e8
Inline Printer's advance_right method 2022-01-18 19:02:49 -08:00
bors
e5e2b0be26 Auto merge of #93048 - matthiaskrgr:rollup-cz5ma34, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #90782 (Implement raw-dylib support for windows-gnu)
 - #91150 (Let qpath contain NtTy: `<$:ty as $:ty>::…`)
 - #92425 (Improve SIMD casts)
 - #92692 (Simplify and unify rustdoc sidebar styles)
 - #92780 (Directly use ConstValue for single literals in blocks)
 - #92924 (Delete pretty printer tracing)
 - #93018 (Remove some unused `Ord` derives based on `Span`)
 - #93026 (fix typo in `max` description for f32/f64)
 - #93035 (Fix stdarch submodule pointing to commit outside tree)

Failed merges:

 - #92861 (Rustdoc mobile: put out-of-band info on its own line)

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-18 22:46:47 +00:00
Matthias Krüger
f851a849cb
Rollup merge of #93035 - Amanieu:stdarch_fix, r=Mark-Simulacrum
Fix stdarch submodule pointing to commit outside tree

PR #93016 was merged with the stdarch submodule pointing to a commit in
a PR branch and not in master. This was due to a circular dependency
between the rust and stdarch changes which would cause the other to fail
to build.

cc #75109
2022-01-18 22:00:52 +01:00
Matthias Krüger
63376bb0fa
Rollup merge of #93026 - klensy:f-typo, r=scottmcm
fix typo in `max` description for f32/f64
2022-01-18 22:00:51 +01:00
Matthias Krüger
73988b6d82
Rollup merge of #93018 - pierwill:rm-unused-ord, r=davidtwco
Remove some unused `Ord` derives based on `Span`

Remove some `Ord`, `PartialOrd` derivations that rely on underlying ordering of `Span`. These ordering traits appear to be unused right now.

If we're going to attempt to remove ordering traits from `Span` as suggested in https://github.com/rust-lang/rust/issues/90317#issuecomment-1013980591, we might want to slowly remove code that depends on this ordering (as opposed to the all-at-once approach in https://github.com/rust-lang/rust/pull/90749 and https://github.com/rust-lang/rust/pull/90408).

cc `@tmiasko` `@cjgillot`
2022-01-18 22:00:50 +01:00
Matthias Krüger
262f48eab0
Rollup merge of #92924 - dtolnay:pptracing, r=Mark-Simulacrum
Delete pretty printer tracing

These are left over from 2011. I did not find these helpful at all in my work on https://github.com/dtolnay/prettyplease despite doing significant refactors to this code. Learning what these messages all refer to is harder than putting in your own messages to log exactly what is relevant to specifically the thing that you are working on debugging.
2022-01-18 22:00:49 +01:00
Matthias Krüger
5a4f47460b
Rollup merge of #92780 - b-naber:postpone-const-eval-coherence, r=lcnr
Directly use ConstValue for single literals in blocks

Addresses the minimal repro in https://github.com/rust-lang/rust/issues/92186, but doesn't fix the underlying problem (which would be solved by solving the anon subst problem afaict).

I do, however, think that it makes sense in general to treat single literals in anon blocks as const values directly, especially in light of the problem that the issue refers to (anon const evaluation being postponed until infer variables in substs can be resolved, which was introduced by https://github.com/rust-lang/rust/pull/90023), i.e. while we do get warnings for those unnecessary braces, we should try to avoid errors caused by those braces if possible.
2022-01-18 22:00:47 +01:00
Matthias Krüger
ff476b3009
Rollup merge of #92692 - jsha:cool-sidebar, r=GuillaumeGomez
Simplify and unify rustdoc sidebar styles

Fixes #59860

This switches to just use size, weight, and spacing to distinguish headings in the sidebar. We no longer use boxes, horizontal bars, or centering to distinguish headings. This makes it much easier to understand the hierarchy of headings, and reduces visual noise.

I also refactored how the mobile topbar works. Previously, we tried to shift around elements from the sidebar to make the topbar. Now, the topbar gets its own elements, which can be styled on their own. This makes styling and reasoning about those elements simpler.

Because the heading font sizes are bigger, increase the sidebar width slightly.

As a very minor change, removed version from the "All types" page. It's now only on the crate page.

struct - https://rustdoc.crud.net/jsha/cool-sidebar/std/vec/struct.Vec.html
trait - https://rustdoc.crud.net/jsha/cool-sidebar/std/io/trait.Read.html
crate - https://rustdoc.crud.net/jsha/cool-sidebar/std/index.html
mod - https://rustdoc.crud.net/jsha/cool-sidebar/std/any/index.html
macro - https://rustdoc.crud.net/jsha/cool-sidebar/std/macro.panic.html
fn - https://rustdoc.crud.net/jsha/cool-sidebar/std/io/fn.stdin.html
type alias - https://rustdoc.crud.net/jsha/cool-sidebar/std/io/type.Result.html
keyword - https://rustdoc.crud.net/jsha/cool-sidebar/std/keyword.as.html
primitive - https://rustdoc.crud.net/jsha/cool-sidebar/std/primitive.pointer.html

r? `@GuillaumeGomez`
cc `@camelid`
[Discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/sidebar.20headings).

Note: This has a lot of smaller commits, but I plan to squash them before merging.
2022-01-18 22:00:46 +01:00
Matthias Krüger
7889f96103
Rollup merge of #92425 - calebzulawski:simd-cast, r=workingjubilee
Improve SIMD casts

* Allows `simd_cast` intrinsic to take `usize` and `isize`
* Adds `simd_as` intrinsic, which is the same as `simd_cast` except for saturating float-to-int conversions (matching the behavior of `as`).

cc `@workingjubilee`
2022-01-18 22:00:45 +01:00
Matthias Krüger
f372476d2c
Rollup merge of #91150 - dtolnay:qpath, r=davidtwco
Let qpath contain NtTy: `<$:ty as $:ty>::…`

Example:

```rust
macro_rules! m {
    (<$type:ty as $trait:ty>::$name:ident) => {
        <$type as $trait>::$name
    };
}

fn main() {
    let _: m!(<str as ToOwned>::Owned);
}
```

Previous behavior:

```console
error: expected identifier, found `ToOwned`
 --> src/main.rs:3:19
  |
3 |         <$type as $trait>::$name
  |                   ^^^^^^ expected identifier
...
8 |     let _: m!(<str as ToOwned>::Owned);
  |            ---------------------------
  |            |
  |            this macro call doesn't expand to a type
  |            in this macro invocation
```

The <code>expected identifier, found \`ToOwned\`</code> error is particularly silly. I think it should be fine to accept this code as long as $trait is of the form `TyKind::Path(None, path)`; if it is any other kind of `NtTy`, we'll keep the same behavior as before.
2022-01-18 22:00:43 +01:00
Matthias Krüger
dd621a4c5c
Rollup merge of #90782 - ricobbe:binutils-dlltool, r=michaelwoerister
Implement raw-dylib support for windows-gnu

Add support for `#[link(kind = "raw-dylib")]` on windows-gnu targets.  Work around binutils's linker's inability to read import libraries produced by LLVM by calling out to the binutils `dlltool` utility to create an import library from a temporary .DEF file; this approach is effectively a slightly refined version of `@mati865's` earlier attempt at this strategy in PR #88801.  (In particular, this attempt at this strategy adds support for `#[link_ordinal(...)]` as well.)

In support of #58713.
2022-01-18 22:00:42 +01:00
David Tolnay
fe86dcf0cc
Delete pretty printer tracing 2022-01-18 12:33:42 -08:00
Jacob Hoffman-Andrews
6a5f8b1aef Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.

I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.

Because the heading font sizes are bigger, increase the sidebar width
slightly.

As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-18 10:43:14 -08:00
Amanieu d'Antras
3db479ed07 Fix stdarch submodule pointing to commit outside tree
PR #93016 was merged with the stdarch submodule pointing to a commit in
a PR branch and not in master. This was due to a circular dependency
between the rust and stdarch changes which would cause the other to fail
to build.

cc #75109
2022-01-18 15:25:38 +00:00
bors
9ad5d82f82 Auto merge of #92731 - bjorn3:asm_support_changes, r=nagisa
Avoid unnecessary monomorphization of inline asm related functions

This should reduce build time for codegen backends by avoiding duplicated monomorphization of certain inline asm related functions for each passed in closure type.
2022-01-18 14:32:52 +00:00
bors
7bc7be860f Auto merge of #87648 - JulianKnodt:const_eq_constrain, r=oli-obk
allow eq constraints on associated constants

Updates #70256

(cc `@varkor,` `@Centril)`
2022-01-18 09:58:39 +00:00
klensy
51cd00c32f fix typo in max description for f32/f64 2022-01-18 10:30:32 +03:00
bors
7531d2fdd4 Auto merge of #93021 - matthiaskrgr:rollup-o7z8zoe, r=matthiaskrgr
Rollup of 14 pull requests

Successful merges:

 - #92629 (Pick themes on settings page, not every page)
 - #92640 (Fix ICEs related to `Deref<Target=[T; N]>` on newtypes)
 - #92701 (Add some more attribute validation)
 - #92803 (Hide mobile sidebar on some clicks)
 - #92830 (Rustdoc style cleanups)
 - #92866 ("Does exists" typos fix)
 - #92870 (add `rustc_diagnostic_item` attribute to `AtomicBool` type)
 - #92914 (htmldocck: Add support for `/text()` in ``@snapshot`)`
 - #92923 (Abstract the pretty printer's ringbuffer to be infinitely sized)
 - #92946 (Exclude llvm-libunwind from the self-contained set on s390x-musl targets)
 - #92947 (rustdoc: Use `intersperse` in a `visit_path` function)
 - #92997 (Add `~const` bound test for negative impls)
 - #93004 (update codegen test for LLVM 14)
 - #93016 (Stabilize vec_spare_capacity)

Failed merges:

 - #92924 (Delete pretty printer tracing)

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-18 06:07:58 +00:00
Caleb Zulawski
49d36d733d Improve documentation of splatted constants 2022-01-18 03:51:04 +00:00
Matthias Krüger
83b1a9452a
Rollup merge of #93016 - Amanieu:vec_spare_capacity, r=Mark-Simulacrum
Stabilize vec_spare_capacity

Closes #75017
2022-01-18 04:42:11 +01:00
Matthias Krüger
b8c544de71
Rollup merge of #93004 - krasimirgg:threadlocal-llvm-up, r=nikic
update codegen test for LLVM 14

Fixes https://github.com/rust-lang/rust/issues/93003.
2022-01-18 04:42:10 +01:00
Matthias Krüger
baeff67b5f
Rollup merge of #92997 - woppopo:test92114, r=Mark-Simulacrum
Add `~const` bound test for negative impls

Resolves #92114 which has been fixed in #92892.
2022-01-18 04:42:09 +01:00
Matthias Krüger
71e5bfed70
Rollup merge of #92947 - vacuus:rustdoc-core-visit-path, r=camelid
rustdoc: Use `intersperse` in a `visit_path` function

(~~Is there a better way to word the title?~~ Eh, this works, I guess.)
I'm surprised that the compiler didn't complain when I left out the `.to_string()`, but hey, if it works then it works.
2022-01-18 04:42:08 +01:00
Matthias Krüger
b05be976ef
Rollup merge of #92946 - kaniini:chore/llvm-libunwind-s390x, r=Mark-Simulacrum
Exclude llvm-libunwind from the self-contained set on s390x-musl targets

llvm-libunwind does not support s390x targets at present, so we cannot build it
for s390x targets.  Accordingly, remove it from the self-contained set.
2022-01-18 04:42:07 +01:00
Matthias Krüger
04b2073c84
Rollup merge of #92923 - dtolnay:ringbuffer, r=petrochenkov
Abstract the pretty printer's ringbuffer to be infinitely sized

This PR backports 8e5e83c3ff from the `prettyplease` crate into `rustc_ast_pretty`.

Using a dedicated RingBuffer type with non-wrapping indices, instead of manually `%`-ing indices into a capped sized buffer, unlocks a number of simplifications to the pretty printing algorithm implementation in followup commits such as fcb5968b1e and 4427cedcb8.

This change also greatly reduces memory overhead of the pretty printer. The old implementation always grows its buffer to 205920 bytes even for files without deeply nested code, because it only wraps its indices when they hit the maximum tolerable size of the ring buffer (the size after which the pretty printer will crash if there are that many tokens buffered). In contrast, the new implementation uses memory proportional to the peak number of simultaneously buffered tokens only, not the number of tokens that have ever been in the buffer.

Speaking of crashing the pretty printer and "maximum tolerable size", the constant used for that in the old implementation is a lie:

de9b573eed/compiler/rustc_ast_pretty/src/pp.rs (L227-L228)

It was raised from 3 to 55 in https://github.com/rust-lang/rust/pull/33934 because that was empirically the size that avoided crashing on one particular test crate, but according to https://github.com/rust-lang/rust/pull/33934#issuecomment-226700470 other syntax trees still crash at that size. There is no reason to believe that any particular size is good enough for arbitrary code, and using a large number like 55 adds overhead to inputs that never need close to that much of a buffer. The new implementation eliminates this tradeoff.
2022-01-18 04:42:06 +01:00
Matthias Krüger
be3d25bd78
Rollup merge of #92914 - camelid:snapshot-text, r=GuillaumeGomez
htmldocck: Add support for `/text()` in `@snapshot`

This allows just testing the text, in cases where the HTML tags don't
matter.

See https://github.com/rust-lang/rust/pull/92908#discussion_r785191758 for an example of when this would be useful.

r? `@GuillaumeGomez`
2022-01-18 04:42:05 +01:00
Matthias Krüger
6a5663ed82
Rollup merge of #92870 - llogiq:atomic_bool_sym, r=Manishearth
add `rustc_diagnostic_item` attribute to `AtomicBool` type

I wanted to use this in clippy and found that it didn't work. So hopefully this addition will fix it.
2022-01-18 04:42:04 +01:00
Matthias Krüger
ae8f39e4d4
Rollup merge of #92866 - maxwase:does_exist_typo, r=Mark-Simulacrum
"Does exists" typos fix

Fixed some typos
2022-01-18 04:42:03 +01:00
Matthias Krüger
deee6f770f
Rollup merge of #92830 - jsha:style-cleanups, r=GuillaumeGomez
Rustdoc style cleanups

 - Make "since" version numbers grey again (regressed in #92602).
 - Remove unneeded selectors for when crate filter dropdown is a
   sibling of search-input.
 - Crate filter dropdown doesn't need to be 100% width on mobile.
 - Only build crate filter dropdown when there is more than one crate.
 - Remove unused addCrateDropdown

 Demo: https://rustdoc.crud.net/jsha/style-cleanups/std/string/struct.String.html

 r? `@GuillaumeGomez`
2022-01-18 04:42:02 +01:00
Matthias Krüger
cc2339ce83
Rollup merge of #92803 - jsha:hide-sidebar, r=GuillaumeGomez
Hide mobile sidebar on some clicks

When the user clicks outside the sidebar, the sidebar should close. Also, when the user clicks an internal link in the sidebar, it should close.

Fixes #92682

Demo: https://rustdoc.crud.net/jsha/hide-sidebar/std/string/struct.String.html
2022-01-18 04:42:00 +01:00
Matthias Krüger
804072fdfc
Rollup merge of #92701 - ehuss:even-more-attr-validation, r=matthewjasper
Add some more attribute validation

This adds some more validation for the position of attributes:

* `link` is only valid on an `extern` block
* `windows_subsystem` and `no_builtins` are only valid at the crate level
2022-01-18 04:41:59 +01:00
Matthias Krüger
cb5ecff8b2
Rollup merge of #92640 - compiler-errors:array-deref-on-newtype, r=lcnr
Fix ICEs related to `Deref<Target=[T; N]>` on newtypes

1. Stash a const infer's type into the canonical var during canonicalization, so we can recreate the fresh const infer with that same type.
    For example, given `[T; _]` we know `_` is a `usize`. If we go from infer => canonical => infer, we shouldn't forget that variable is a usize.
Fixes #92626
Fixes #83704

2. Don't stash the autoderef'd slice type that we get from method lookup, but instead recreate it during method confirmation. We need to do this because the type we receive back after picking the method references a type variable that does not exist after probing is done.
Fixes #92637

... A better solution for the second issue would be to actually _properly_ implement `Deref` for `[T; N]` instead of fixing this autoderef hack to stop leaking inference variables. But I actually looked into this, and there are many complications with const impls.
2022-01-18 04:41:58 +01:00
Matthias Krüger
d501ead009
Rollup merge of #92629 - jsha:theme-picker-local-only-2, r=GuillaumeGomez
Pick themes on settings page, not every page

This hides the paintbrush icon on most pages by default, in preference for the settings on the settings page.  When loading from a local file, and not in mobile view, continue to show the theme picker. That's because some browsers limit access to localStorage from file:/// URLs, so choosing a theme from settings.html doesn't take effect.

Fixes #84539
Part of #59840

r? `@GuillaumeGomez`

Demo: https://rustdoc.crud.net/jsha/theme-picker-local-only-2/std/io/trait.Read.html
2022-01-18 04:41:58 +01:00
Caleb Zulawski
1d5bf6bc28
Update compiler/rustc_codegen_llvm/src/builder.rs
Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2022-01-17 22:29:12 -05:00
bors
e4ff9031ac Auto merge of #93001 - flip1995:clippyup, r=Manishearth
Out of cycle Clippy update

I want to do an out-of-cycle sync for rust-lang/rust-clippy#8295, and possibly backport this to stable together with https://github.com/rust-lang/rust/issues/92938. If this doesn't get backported to stable, then I at least want to backport it to beta.

r? `@Manishearth`
2022-01-18 02:32:36 +00:00
bors
86b1581ea0 Auto merge of #93009 - matthiaskrgr:rollup-3fkxg6i, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #90498 (Clarifications in the target tier policy)
 - #92164 (Implement `#[rustc_must_implement_one_of]` attribute)
 - #92729 (rustc_codegen_llvm: Remove (almost) unused span parameter from many functions in metadata.rs)
 - #92752 (Correct minor typos in some long error code explanations)
 - #92801 (Enable wrapping words by default)
 - #92825 (Rename environment variable for overriding rustc version)
 - #92877 (Remove LLVMRustMarkAllFunctionsNounwind)
 - #92936 (rustdoc: Remove `collect` in `html::markdown::parse`)
 - #92956 (Add `log2` and `log10` to `NonZeroU*`)
 - #92960 (Use `carrying_{mul|add}` in `num::bignum`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-17 23:01:35 +00:00
Jacob Hoffman-Andrews
ae99e23c11 Add staged_api for tests 2022-01-17 13:23:46 -08:00
pierwill
ae9b624bf6 Rm some unused ord impls 2022-01-17 15:15:32 -06:00