Commit graph

158493 commits

Author SHA1 Message Date
Matthias Krüger 13c60669cc
Rollup merge of #91212 - compiler-errors:issue91206, r=oli-obk
Fix ICE due to out-of-bounds statement index when reporting borrowck error

Replace an `[index]` with a `.get` when `statement_index` points to a basic-block terminator (and is therefore out-of-bounds in the statements list).

Fixes #91206
Cc ``@camsteffen``
r? ``@oli-obk``
2021-11-26 16:02:26 +01:00
Matthias Krüger fdc305d58d
Rollup merge of #91176 - hermitcore:spin, r=kennytm
If the thread does not get the lock in the short term, yield the CPU

Reduces on [RustyHermit](https://github.com/hermitcore/rusty-hermit) the amount of wasted processor cycles
2021-11-26 16:02:24 +01:00
Matthias Krüger 324b4bcb3c
Rollup merge of #91169 - RDambrosio016:master, r=bjorn3
Change cg_ssa's get_param to borrow the builder mutably

This is a small change to make `get_param` more flexible for codegens that may need to modify things when retrieving function parameters.

This will currently only be used by [rustc_codegen_nvvm](https://github.com/Rust-GPU/Rust-CUDA) (my own project), but may be useful to more codegens in the future.

This is needed because cg_nvvm needs to remap certain types to libnvvm-friendly types, such as `i128` -> `<2 x i64>`. Because cg_ssa does not give mutable access to the builder, i resorted to using a mutex:
```rs
    fn get_param(&self, index: usize) -> Self::Value {
        let val = llvm::get_param(self.llfn(), index as c_uint);
        trace!("Get param `{:?}`", val);
        unsafe {
            let llfnty = LLVMRustGetFunctionType(self.llfn());
            let map = self.remapped_integer_args.borrow();
            if let Some((_, key)) = map.get(llfnty) {
                if let Some((_, new_ty)) = key.iter().find(|t| t.0 == index) {
                    trace!("Casting irregular param {:?} to {:?}", val, new_ty);
                    return transmute_llval(
                        *self.llbuilder.lock().unwrap(),
                        &self.cx,
                        val,
                        *new_ty,
                    );
                }
            }
            val
        }
    }
```
However, i predict this is pretty bad for performance, considering how much builders are called during codegen, so i would greatly appreciate having a more flexible API for this.
2021-11-26 16:02:23 +01:00
bors 1e79d79dac 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.
2021-11-26 09:55:06 +00:00
bors a7836bf885 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`
2021-11-26 06:44:00 +00:00
bors 9adfd9db78 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
2021-11-26 03:57:55 +00:00
bors e2f6fb9996 Auto merge of #91037 - c410-f3r:testsssssss, r=petrochenkov
Move some tests to more reasonable directories - 10

cc #73494
r? `@petrochenkov`
2021-11-25 23:53:02 +00:00
Aaron Hill a7cc6bc4d0
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.
2021-11-25 15:33:37 -06:00
bors dd549dcab4 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`
2021-11-25 19:43:56 +00:00
Esteban Kuber 2e1792a764 Fix clippy test 2021-11-25 18:39:32 +00:00
Esteban Kuber 9cce7bb921 Account for type obligation coming from const and static 2021-11-25 18:04:33 +00:00
Esteban Küber 37a11a96a1 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
2021-11-25 18:04:33 +00:00
Michael Goulet 69d1917672 Add test demonstrating no more ICE 2021-11-25 16:34:30 +00:00
Michael Goulet 718a3b1f2d Fix issue 91206 2021-11-25 16:34:30 +00:00
bors 37a49713cb 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
2021-11-25 16:12:04 +00:00
Matthias Krüger 984e644432
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```
2021-11-25 15:05:40 +01:00
Matthias Krüger 5fff1d77e7
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
2021-11-25 15:05:39 +01:00
Matthias Krüger 5f6cb2c552
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`
2021-11-25 15:05:38 +01:00
Matthias Krüger 6970cf5a23
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````
2021-11-25 15:05:37 +01:00
Matthias Krüger 0780889833
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>`.
2021-11-25 15:05:36 +01:00
Matthias Krüger 90dd7c03af
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.
2021-11-25 15:05:35 +01:00
Guillaume Gomez e340478f5d Improve tests 2021-11-25 14:49:03 +01:00
Guillaume Gomez f6c728f5e7 Update browser-ui-test version to enforce that text is displayed before checking colors 2021-11-25 14:48:14 +01:00
bors 862962b90e 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`
2021-11-25 13:11:35 +00:00
Caio 062abf3d21 Move some tests to more reasonable directories 2021-11-25 08:11:01 -03:00
bors 23a436606b 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.
2021-11-25 08:16:08 +00:00
Hans Kratz b376f5621b Set MACOSX_DEPLOYMENT_TARGET env var to default for linking if not set. 2021-11-25 07:08:44 +01:00
Hans Kratz 8f4d88c4bf 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.
2021-11-25 07:08:37 +01:00
Hans Kratz fa18030567 The correct LLVM target for aarch64-apple-darwin is arm64-... (as with ios) 2021-11-25 06:56:42 +01:00
bors c6eda7d8a7 Auto merge of #85346 - estebank:issue-84946, r=nagisa,varkor
Account for incorrect `impl Foo<const N: ty> {}` syntax

Fix #84946
2021-11-25 05:09:51 +00:00
Esteban Kuber d92916439c Update cargo to fix tokenizer test affected by tokenizing emoji 2021-11-25 00:19:50 +00:00
Noah Lev 617bbb21f8
Update comment
Co-authored-by: Joshua Nelson <github@jyn.dev>
2021-11-24 18:32:03 -05:00
Camille GILLOT 7f5d3fff4f Do not visit attributes in LateResolutionVisitor. 2021-11-25 00:24:04 +01:00
bors d2c24aabcd 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
2021-11-24 23:09:42 +00:00
Esteban Kuber 505b09e326 Tweak span and add more tests 2021-11-24 22:04:52 +00:00
Guillaume Gomez ae9681ecfa
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.
2021-11-24 22:56:40 +01:00
Guillaume Gomez 3bc8fc8049
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``
2021-11-24 22:56:39 +01:00
Guillaume Gomez a81f3610ea
Rollup merge of #91151 - name1e5s:chore/process_test, r=m-ou-se
Fix test in std::process on android

closes #10380
2021-11-24 22:56:38 +01:00
Guillaume Gomez 9390b50ef4
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>
2021-11-24 22:56:37 +01:00
Guillaume Gomez a6a1d7ca29
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`` ?
2021-11-24 22:56:37 +01:00
Guillaume Gomez cbe563a4d5
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.
2021-11-24 22:56:36 +01:00
Guillaume Gomez 658c148b87
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.
2021-11-24 22:56:35 +01:00
Noah Lev 2e0bc33594 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.
2021-11-24 13:16:10 -08:00
Guillaume Gomez 9447d1f903 Add test for merged features 2021-11-24 21:57:18 +01:00
Guillaume Gomez 3c77b56d94 Update error message for doc(keyword) 2021-11-24 21:57:18 +01:00
Guillaume Gomez 2ba483883e Add feature gate test for "rustdoc_internal" feature 2021-11-24 21:57:18 +01:00
Guillaume Gomez 1e6ced3532 Create rustdoc_internals feature gate 2021-11-24 21:57:18 +01:00
Stefan Lankes 6911af9d06
Improving the readability
Co-authored-by: kennytm <kennytm@gmail.com>
2021-11-24 21:12:56 +01:00
Noah Lev 43651125ee Remove ResolvedPath.did 2021-11-24 12:06:47 -08:00
bors b426445c60 Auto merge of #91188 - jsha:fix-click-items, r=Manishearth
Fix clicking on anchors inside summary tags

Fixes #91184

r? `@camelid`
2021-11-24 20:03:33 +00:00