Commit graph

161268 commits

Author SHA1 Message Date
Matthias Krüger 7f02604f3d
Rollup merge of #92877 - Amanieu:remove_llvm_nounwind, r=Mark-Simulacrum
Remove LLVMRustMarkAllFunctionsNounwind

This was originally introduced in #10916 as a way to remove all landing
pads when performing LTO. However this is no longer necessary today
since rustc properly marks all functions and call-sites as nounwind
where appropriate.

In fact this is incorrect in the presence of `extern "C-unwind"` which
must create a landing pad when compiled with `-C panic=abort` so that
foreign exceptions are caught and properly turned into aborts.
2022-01-17 20:07:07 +01:00
Matthias Krüger 6acb7043e7
Rollup merge of #92825 - pierwill:rustc-version-force-rename, r=Mark-Simulacrum
Rename environment variable for overriding rustc version
2022-01-17 20:07:06 +01:00
Matthias Krüger 51aa20de07
Rollup merge of #92801 - jsha:overflow-wrap, r=GuillaumeGomez
Enable wrapping words by default

Faced with a very long word, browsers will let it overflow its
box horizontally rather than break it in the middle. We essentially
never want that behavior. We would rather break the word and keep it
inside its horizontal limits. So we apply a default overflow-wrap:
break-word/anywhere to the document as a while.

In some contexts we would rather add a horizontal scrollbar (code
blocks), or elide the excess text with an ellipsis (sidebar). Those
still work as expected.

Fixes #92771

[Some related discussion](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/wrap.20.2F.20overflow.20.2F.20scroll) and a related issue: #92421.

Demo: https://rustdoc.crud.net/jsha/overflow-wrap/std/iter/trait.Iterator.html#method.try_find

r? ``@GuillaumeGomez``
2022-01-17 20:07:05 +01:00
Matthias Krüger 4de63e7c23
Rollup merge of #92752 - jamestiotio:error-codes-typos, r=nagisa
Correct minor typos in some long error code explanations

Just a little nitpick to improve the long explanations of the error codes. 😊
2022-01-17 20:07:04 +01:00
Matthias Krüger 97743d9d80
Rollup merge of #92729 - michaelwoerister:remove-unused-span-debuginfo, r=petrochenkov
rustc_codegen_llvm: Remove (almost) unused span parameter from many functions in metadata.rs

Many functions and intermediate data structures in `rustc_codegen_llvm/src/debuginfo/metadata.rs` take a span parameter that is only used for providing a span to a `span_bug!()` invocation, in case the debuginfo typemap gets corrupted. However, this span does not really convey useful information as it just points to the first point a type is used -- and half of the time is initialized to `DUMMY_SP`.

This PR removes this span parameter from the module.

It also removes the following unused parameters from `composite_type_metadata()` together with an outdated comment:

```rust
    // Ignore source location information as long as it
    // can't be reconstructed for non-local crates.
    _file_metadata: &'ll DIFile,
    _definition_span: Span,
```
2022-01-17 20:07:03 +01:00
Matthias Krüger 32d85c0b5a
Rollup merge of #92164 - WaffleLapkin:rustc_must_implement_one_of_attr, r=Aaron1011
Implement `#[rustc_must_implement_one_of]` attribute

This PR adds a new attribute — `#[rustc_must_implement_one_of]` that allows changing the "minimal complete definition" of a trait. It's similar to GHC's minimal `{-# MINIMAL #-}` pragma, though `#[rustc_must_implement_one_of]` is weaker atm.

Such attribute was long wanted. It can be, for example, used in `Read` trait to make transitions to recently added `read_buf` easier:
```rust
#[rustc_must_implement_one_of(read, read_buf)]
pub trait Read {
    fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
        let mut buf = ReadBuf::new(buf);
        self.read_buf(&mut buf)?;
        Ok(buf.filled_len())
    }

    fn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> Result<()> {
        default_read_buf(|b| self.read(b), buf)
    }
}

impl Read for Ty0 {}
//^ This will fail to compile even though all `Read` methods have default implementations

// Both of these will compile just fine
impl Read for Ty1 {
    fn read(&mut self, buf: &mut [u8]) -> Result<usize> { /* ... */ }
}
impl Read for Ty2 {
    fn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> Result<()> { /* ... */ }
}
```

For now, this is implemented as an internal attribute to start experimenting on the design of this feature. In the future we may want to extend it:
- Allow arbitrary requirements like `a | (b & c)`
- Allow multiple requirements like
  - ```rust
    #[rustc_must_implement_one_of(a, b)]
    #[rustc_must_implement_one_of(c, d)]
    ```
- Make it appear in rustdoc documentation
- Change the syntax?
- Etc

Eventually, we should make an RFC and make this (or rather similar) attribute public.

---

I'm fairly new to compiler development and not at all sure if the implementation makes sense, but at least it passes tests :)
2022-01-17 20:07:02 +01:00
Matthias Krüger 67bcbde3c5
Rollup merge of #90498 - joshtriplett:target-tier-policy-draft-updates, r=Mark-Simulacrum
Clarifications in the target tier policy

We've added several targets since the introduction of the target tier policy. Based on experiences of those adding such targets, and discussions around such additions, clarify the target tier policy to make it easier to follow and work with.

None of these changes substantively change the requirements on targets. (In some cases the changes do direct target submitters to follow specific process requirements for the addition of a target, such as how to respond to requirements, where to put target-specific documentation, or what should appear in that documentation. Those changes are procedural in nature and document the procedures we already direct people to follow.)

- Clarify how to quote and respond to the target tier policy requirements. Several times, people have seemed unclear on how to respond to some of the policy requirements, particularly those that just state things the target developers must *not* do (e.g. not posting to PRs that break the target). Add a note that such requirements just need acknowledgement, nothing more.
- Clarify dependency requirements in the face of cross-compilation. I previously phrased this confusingly in terms of "host tools", since that is the case where an exception applies (allowing proprietary target libraries commonly used by binaries for the target). Rephrase it to apply equally to cross-compilation. This doesn't change the net effect of the requirements, since other requirements already cover the dependencies of the Rust toolchain.
- Clarify documentation about running binaries. The requirement for target documentation talks about "running tests", but tier 3 targets often don't support running the full testsuite, and in practice the documentation for how to run an individual binary may be more useful. Change "running tests" to "running binaries, or running tests".
- Explain where to place target-specific documentation (a subdirectory of platform-support, with a link from the platform-support entry for the target).
- Add a template for target-specific documentation.
2022-01-17 20:07:01 +01:00
Michael Woerister 9a79ab6c0b rustc_codegen_llvm: Remove (almost) unused span parameter from many functions in metadata.rs. 2022-01-17 16:43:23 +01:00
bors ee5d8d37ba Auto merge of #90986 - camsteffen:nested-filter, r=cjgillot
Replace `NestedVisitorMap` with generic `NestedFilter`

This is an attempt to make the `intravisit::Visitor` API simpler and "more const" with regard to nested visiting.

With this change, `intravisit::Visitor` does not visit nested things by default, unless you specify `type NestedFilter = nested_filter::OnlyBodies` (or `All`). `nested_visit_map` returns `Self::Map` instead of `NestedVisitorMap<Self::Map>`. It panics by default (unreachable if `type NestedFilter` is omitted).

One somewhat trixty thing here is that `nested_filter::{OnlyBodies, All}` live in `rustc_middle` so that they may have `type Map = map::Map` and so that `impl Visitor`s never need to specify `type Map` - it has a default of `Self::NestedFilter::Map`.
2022-01-17 14:50:50 +00:00
bors a34c079752 Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieu
Remove deprecated LLVM-style inline assembly

The `llvm_asm!` was deprecated back in #87590 1.56.0, with intention to remove
it once `asm!` was stabilized, which already happened in #91728 1.59.0. Now it
is time to remove `llvm_asm!` to avoid continued maintenance cost.

Closes #70173.
Closes #92794.
Closes #87612.
Closes #82065.

cc `@rust-lang/wg-inline-asm`

r? `@Amanieu`
2022-01-17 09:40:29 +00:00
bors 128417f40f Auto merge of #92996 - matthiaskrgr:rollup-50wpzva, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #92795 (Link sidebar "location" heading to top of page)
 - #92799 (Remove some unnecessary uses of `FieldDef::ident`)
 - #92808 (Fix `try wrapping expression in variant` suggestion with struct field shorthand)
 - #92819 (rustdoc: remove hand-rolled isatty)
 - #92876 (Fix suggesting turbofish with lifetime arguments)
 - #92921 (Rename Printer constructor from mk_printer() to Printer::new())
 - #92937 (rustdoc: Add missing dot separator)
 - #92953 (Copy an example to PartialOrd as well)
 - #92977 (Docs: recommend VecDeque instead of Vec::remove(0))
 - #92981 (fix const_ptr_offset_from tracking issue)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-17 05:46:53 +00:00
Matthias Krüger 9612038a7e
Rollup merge of #92981 - RalfJung:const_ptr_offset_from, r=dtolnay
fix const_ptr_offset_from tracking issue

The old tracking issue #41079 was for exposing those functions at all, and got closed when they were stabilized. We had nothing tracking their `const`ness so I opened a new tracking issue: https://github.com/rust-lang/rust/issues/92980.
2022-01-17 06:08:19 +01:00
Matthias Krüger 7bdd978c24
Rollup merge of #92977 - kornelski:popdoc, r=dtolnay
Docs: recommend VecDeque instead of Vec::remove(0)

Suggestion based on a [discussion](https://internals.rust-lang.org/t/should-vec-have-a-try-remove-mut-self-usize-option-t-function/15964/9?u=kornel) where user needlessly struggled with `remove(0)` and accidentally created a quadratic cost.
2022-01-17 06:08:18 +01:00
Matthias Krüger 775fe37ca9
Rollup merge of #92953 - azdavis:azdavis-copy-example, r=dtolnay
Copy an example to PartialOrd as well

In https://github.com/rust-lang/rust/pull/88202 I added an example for deriving PartialOrd on enums, but only later did I realize that I actually put the example on Ord.

This copies the example to PartialOrd as well, which is where I intended for it to be.

We could also delete the example on Ord, but I see there's already some highly similar examples shared between Ord and PartialOrd, so I figured we could leave it.

I also changed some type annotations in an example from `x : T` to the more common style (in Rust) of `x: T`.
2022-01-17 06:08:17 +01:00
Matthias Krüger 0aae1ec9ff
Rollup merge of #92937 - GuillaumeGomez:dot-separator, r=jsha
rustdoc: Add missing dot separator

Fixes #92901.

![Screenshot from 2022-01-15 17-47-18](https://user-images.githubusercontent.com/3050060/149631249-e2c0c3a4-9ed8-48e2-92cc-79a5bb347b35.png)

r? ``@jsha``
2022-01-17 06:08:17 +01:00
Matthias Krüger 216ce7c519
Rollup merge of #92921 - dtolnay:printernew, r=wesleywiser
Rename Printer constructor from mk_printer() to Printer::new()

The original naming is left over from 2011 which was before impl blocks and associated functions existed.

21313d623a/src/comp/pretty/pp.rs
2022-01-17 06:08:16 +01:00
Matthias Krüger c6ff4be011
Rollup merge of #92876 - compiler-errors:fix-turbofish-lifetime-suggestion, r=nagisa
Fix suggesting turbofish with lifetime arguments

Now we suggest turbofish correctly given exprs like `foo<'_>`.

Also fix suggestion when we have `let x = foo<bar, baz>;` which was broken.
2022-01-17 06:08:15 +01:00
Matthias Krüger 681271e045
Rollup merge of #92819 - euclio:atty, r=CraftSpider
rustdoc: remove hand-rolled isatty

This PR replaces bindings to the platform-specific isatty APIs with the `isatty` crate, as done elsewhere in the repository.
2022-01-17 06:08:14 +01:00
Matthias Krüger ff1b653cdb
Rollup merge of #92808 - compiler-errors:wrap-struct-shorthand-field-in-variant, r=davidtwco
Fix `try wrapping expression in variant` suggestion with struct field shorthand

Fixes a broken suggestion: [playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=83fe2dbfe1485f8cfca1aef2a6582e77)

before:
```
error[E0308]: mismatched types
 --> src/main.rs:7:19
  |
7 |     let x = Foo { bar };
  |                   ^^^ expected enum `Option`, found integer
  |
  = note: expected enum `Option<i32>`
             found type `{integer}`
help: try wrapping the expression in `Some`
  |
7 |     let x = Foo { Some(bar) };
  |                   +++++   +
```

after:
```
error[E0308]: mismatched types
 --> src/main.rs:7:19
  |
7 |     let x = Foo { bar };
  |                   ^^^ expected enum `Option`, found integer
  |
  = note: expected enum `Option<i32>`
             found type `{integer}`
help: try wrapping the expression in `Some`
  |
7 |     let x = Foo { bar: Some(bar) };
  |                   ~~~~~~~~~~~~~~
```

r? ``@m-ou-se``
since you touched the code last in #91080
2022-01-17 06:08:13 +01:00
Matthias Krüger 3de7276689
Rollup merge of #92799 - rust-lang:followup-from-92533, r=Aaron1011
Remove some unnecessary uses of `FieldDef::ident`

Followup from #92533.

cc ``@Aaron1011`` ``@petrochenkov``
2022-01-17 06:08:11 +01:00
Matthias Krüger 869b7bc5e7
Rollup merge of #92795 - jsha:link-to-top, r=GuillaumeGomez
Link sidebar "location" heading to top of page

This makes it easy, when you are scrolled far down in a page, to jump back to the top.

Demo: https://rustdoc.crud.net/jsha/link-to-top/std/string/struct.String.html

r? ``@GuillaumeGomez``
2022-01-17 06:08:10 +01:00
bors fd20513f52 Auto merge of #92473 - petrochenkov:ltrattr2, r=Aaron1011
expand: Pick `cfg`s and `cfg_attrs` one by one, like other attributes

This is a rebase of https://github.com/rust-lang/rust/pull/83354, but without any language-changing parts ~(except for https://github.com/rust-lang/rust/pull/84110)~, i.e. the attribute expansion order is the same.

This is a pre-requisite for any other changes making cfg attributes closer to regular macro attributes
- Possibly changing their expansion order (https://github.com/rust-lang/rust/issues/83331)
- Keeping macro backtraces for cfg attributes, or otherwise making them visible after expansion without keeping them in place literally (https://github.com/rust-lang/rust/pull/84110).

Two exceptions to the "one by one" behavior are:
- cfgs eagerly expanded by `derive` and `cfg_eval`, they are still expanded in a batch, that's by design.
- cfgs at the crate root, they are currently expanded not during the main expansion pass, but before that, during `#![feature]` collection. I'll try to disentangle that logic later in a separate PR.

r? `@Aaron1011`
2022-01-17 02:06:54 +00:00
bors 1fbd6aedb3 Auto merge of #92935 - Xanewok:update-rls, r=pietroalbini
Update RLS and drop rustc-ap-packages

Closes #91543

r? `@pietroalbini`

cc `@calebcartwright` `@flip1995`
2022-01-16 23:03:33 +00:00
Cameron Steffen be6d6934b6 Fix Visitor::NestedFilter in Clippy 2022-01-16 16:02:36 -06:00
Cameron Steffen 1a6312ee0f Format clippy 2022-01-16 16:02:36 -06:00
Cameron Steffen 45db716902 Replace NestedVisitorMap with NestedFilter 2022-01-16 16:02:36 -06:00
Ralf Jung bb1423e019 fix const_ptr_offset_from tracking issue 2022-01-16 15:21:42 -05:00
Kornel 361ef2aadc Docs: recommend VecDeque instead of Vec::remove(0) 2022-01-16 17:53:05 +00:00
bors bd3cb52565 Auto merge of #92970 - matthiaskrgr:rollup-tcx7cfb, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #92487 (Fix unclosed boxes in pretty printing of TraitAlias)
 - #92581 (ARMv6K Horizon - Enable default libraries)
 - #92619 (Add diagnostic items for macros)
 - #92635 (rustdoc: Yet more intra-doc links cleanup)
 - #92646 (feat: rustc_pass_by_value lint attribute)
 - #92706 (Clarify explicitly that BTree{Map,Set} are ordered.)
 - #92710 (Include Projections when elaborating TypeOutlives)
 - #92746 (Parse `Ty?` as `Option<Ty>` and provide structured suggestion)
 - #92792 (rustdoc: fix intra-link for generic trait impls)
 - #92814 (remove unused FIXME)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-16 17:22:57 +00:00
Matthias Krüger 2b6b49e1d7
Rollup merge of #92814 - lcnr:unused-fixme, r=Mark-Simulacrum
remove unused FIXME

#56935 seems to be fixed.
2022-01-16 16:58:20 +01:00
Matthias Krüger 682ad02b49
Rollup merge of #92792 - mdibaiee:92662/fix-intra-doc-generics, r=camelid
rustdoc: fix intra-link for generic trait impls

fixes #92662

r? `````@camelid`````
2022-01-16 16:58:19 +01:00
Matthias Krüger 9323a0d1be
Rollup merge of #92746 - estebank:question-mark-in-type, r=davidtwco
Parse `Ty?` as `Option<Ty>` and provide structured suggestion

Swift has specific syntax that desugars to `Option<T>` similar to our
`?` operator, which means that people might try to use it in Rust. Parse
it and gracefully recover.
2022-01-16 16:58:18 +01:00
Matthias Krüger 9835b90c91
Rollup merge of #92710 - jackh726:issue-92280, r=nikomatsakis
Include Projections when elaborating TypeOutlives

Fixes #92280

In `Elaborator`, we elaborate that `Foo<<Bar as Baz>::Assoc>: 'a` -> `<Bar as Baz>::Assoc: 'a`. This is the same rule that would be applied to any other `Param`. If there are escaping vars, we continue to do nothing.

r? `@nikomatsakis`
2022-01-16 16:58:17 +01:00
Matthias Krüger 039d6dc289
Rollup merge of #92706 - umanwizard:btree, r=dtolnay
Clarify explicitly that BTree{Map,Set} are ordered.

One of the main reasons one would want to use a BTree{Map,Set} rather than a Hash{Map,Set} is because they maintain their keys in sorted order; but this was never explicitly stated in the top-level docs (it was only indirectly alluded to there, and stated explicitly in the docs for `iter`, `values`, etc.)

This PR states the ordering guarantee more prominently.
2022-01-16 16:58:16 +01:00
Matthias Krüger c5041f88ea
Rollup merge of #92646 - mdibaiee:76935/pass-by-value, r=lcnr
feat: rustc_pass_by_value lint attribute

Useful for thin wrapper attributes that are best passed as value instead
of reference.

Fixes #76935
2022-01-16 16:58:15 +01:00
Matthias Krüger e1b943991f
Rollup merge of #92635 - camelid:yet-more-cleanup, r=Manishearth
rustdoc: Yet more intra-doc links cleanup

r? `@Manishearth`
2022-01-16 16:58:14 +01:00
Matthias Krüger cf4549c920
Rollup merge of #92619 - Alexendoo:macro-diagnostic-items, r=matthewjasper
Add diagnostic items for macros

For use in Clippy, it adds diagnostic items to all the stable public macros

Clippy has lints that look for almost all of these (currently by name or path), but there are a few that aren't currently part of any lint, I could remove those if it's preferred to add them as needed rather than ahead of time
2022-01-16 16:58:14 +01:00
Matthias Krüger 391b66ccff
Rollup merge of #92581 - Meziu:armv6k-3ds-target, r=nagisa
ARMv6K Horizon - Enable default libraries

Due to the nature of the external gcc linker, default libraries are required, even for `no_std` programs.
2022-01-16 16:58:12 +01:00
Matthias Krüger 9527533408
Rollup merge of #92487 - dtolnay:traitalias, r=matthewjasper
Fix unclosed boxes in pretty printing of TraitAlias

This was causing trait aliases to not even render at all in stringified / pretty printed output.

```rust
macro_rules! repro {
    ($item:item) => {
        stringify!($item)
    };
}

fn main() {
    println!("{:?}", repro!(pub trait Trait<T> = Sized where T: 'a;));
}
```

Before:&ensp;`""`
After:&ensp;`"pub trait Trait<T> = Sized where T: 'a;"`

The fix is copied from how `head`/`end` for `ItemKind::Use`, `ItemKind::ExternCrate`, and `ItemKind::Mod` are all done in the pretty printer:

dd3ac41495/compiler/rustc_ast_pretty/src/pprust/state.rs (L1178-L1184)
2022-01-16 16:58:10 +01:00
Igor Matuszewski 69c3b723d2 Use new Racer from crates.io 2022-01-16 15:30:47 +01:00
Igor Matuszewski 7f04877b1e Drop duplicate checks for now missing rustc_ast dep in tidy 2022-01-16 15:30:47 +01:00
Igor Matuszewski d83c44a03b Update RLS and drop rustc-ap-packages 2022-01-16 15:30:46 +01:00
bors 48e89b00ca Auto merge of #92245 - petrochenkov:cmrval, r=nagisa
rustc_metadata: Switch all decoder methods from vectors to iterators

To avoid allocations in some cases.

Also remove unnecessary `is_proc_macro_crate` checks from decoder, currently the general strategy is to shift all the work to the encoder and assume that all the encoded data is correct and can be decoded unconditionally in the decoder.
2022-01-16 14:25:25 +00:00
bors 7be8693984 Auto merge of #92805 - BoxyUwU:revert-lazy-anon-const-substs, r=lcnr
partially revertish `lazily "compute" anon const default substs`

reverts #87280 except for some of the changes around `ty::Unevaluated` having a visitor and a generic for promoted
why revert: <https://github.com/rust-lang/rust/pull/92805#issuecomment-1010736049>

r? `@lcnr`
2022-01-16 11:19:21 +00:00
bors 42852d7857 Auto merge of #92740 - cuviper:update-rayons, r=Mark-Simulacrum
Update rayon and rustc-rayon

This updates rayon for various tools and rustc-rayon for the compiler's parallel mode.

- rayon v1.3.1 -> v1.5.1
- rayon-core v1.7.1 -> v1.9.1
- rustc-rayon v0.3.1 -> v0.3.2
- rustc-rayon-core v0.3.1 -> v0.3.2

... and indirectly, this updates all of crossbeam-* to their latest versions.

Fixes #92677 by removing crossbeam-queue, but there's still a lingering question about how tidy discovers "runtime" dependencies. None of this is truly in the standard library's dependency tree at all.
2022-01-16 08:12:23 +00:00
Vadim Petrochenkov 4549b13571 rustc_metadata: Switch all decoder methods from vectors to iterators
Also remove unnecessary `is_proc_macro_crate` checks from decoder
2022-01-16 14:14:39 +08:00
bors 26c06cf8e2 Auto merge of #92356 - kellerkindt:saturating_int_assign_impl, r=dtolnay
Add {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}{,Assign}<$t> to Saturat…

Tracking issue #92354
2022-01-16 05:23:44 +00:00
David Tolnay bfe0a4e06e
Touch up stray comment in PR 92953 2022-01-15 20:44:47 -08:00
Ariel Davis 828febf9e0 Clear up discriminants with more examples 2022-01-15 20:24:38 -08:00
Jack Huey ea562aeed5 Add nll revision for issue-92096 test that passes 2022-01-15 23:17:32 -05:00