Commit graph

9417 commits

Author SHA1 Message Date
bors
90912e68ab Auto merge of #91330 - cjgillot:no-ee-features, r=Aaron1011
Remove eval_always for lib_features.

r? `@Aaron1011`
2021-11-30 07:40:08 +00:00
bors
6db0a0e9a4 Auto merge of #91299 - cjgillot:expect-ldid, r=petrochenkov
Take a LocalDefId in expect_*item.

Items and item-likes are always HIR owners.
When trying to find such nodes, there is no ambiguity, the `LocalDefId` and the `HirId::owner` always match.
In such cases, `local_def_id_to_hir_id` does not carry any meaningful information, so we can just skip calling it altogether.
2021-11-29 15:02:01 +00:00
bors
8b954910c5 Auto merge of #91350 - matthiaskrgr:rollup-nleabdj, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #91049 (Add a caveat to std::os::windows::fs::symlink_file)
 - #91281 (Add demonstration test for #91161)
 - #91327 (Delete an unreachable codepath from format_args implementation)
 - #91336 (Remove unused root_parent.)
 - #91349 (Accumulate all values of `-C remark` option)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-29 10:34:52 +00:00
Matthias Krüger
e15e0ba45c
Rollup merge of #91349 - tmiasko:accumulate-remark-args, r=nikic
Accumulate all values of `-C remark` option

When `-C remark=...` option is specified multiple times,
accumulate all values instead of using only the last one.

r? `@nikic`
2021-11-29 10:41:38 +01:00
Matthias Krüger
b8a4a4c232
Rollup merge of #91336 - cjgillot:root_parent, r=matthewjasper
Remove unused root_parent.
2021-11-29 10:41:37 +01:00
Matthias Krüger
7df49eff10
Rollup merge of #91327 - dtolnay:exact, r=michaelwoerister
Delete an unreachable codepath from format_args implementation
2021-11-29 10:41:36 +01:00
Tomasz Miąsko
e74e39a699 Accumulate all values of -C remark option
When `-C remark=...` option is specified multiple times,
accumulate all values instead of using only the last one.
2021-11-29 09:12:01 +01:00
bors
44723c5d59 Auto merge of #91043 - camsteffen:descendant-eq, r=petrochenkov
Add fast path to `is_descendant_of`
2021-11-29 07:46:36 +00:00
Matthias Krüger
67762ffe35
Rollup merge of #90833 - tmiasko:optimization-remarks, r=nikic
Emit LLVM optimization remarks when enabled with `-Cremark`

The default diagnostic handler considers all remarks to be disabled by
default unless configured otherwise through LLVM internal flags:
`-pass-remarks`, `-pass-remarks-missed`, and `-pass-remarks-analysis`.
This behaviour makes `-Cremark` ineffective on its own.

Fix this by configuring a custom diagnostic handler that enables
optimization remarks based on the value of `-Cremark` option. With
`-Cremark=all` enabling all remarks.

Fixes #90924.

r? `@nikic`
2021-11-28 23:45:17 +01:00
Matthias Krüger
9715724006
Rollup merge of #90131 - camsteffen:fmt-args-span-fix, r=cjgillot
Fix a format_args span to be expansion

I found this while exploring solutions for rust-lang/rust-clippy#7843.

r? `@m-ou-se`
2021-11-28 23:45:15 +01:00
Cameron Steffen
ac8d514376 Add parent crate assert to register_expn_id 2021-11-28 16:35:54 -06:00
Cameron Steffen
768cfac705 Add fast path to is_descendant_of 2021-11-28 16:35:54 -06:00
Camille GILLOT
06b2e659d3 Remove unused root_parent. 2021-11-28 21:48:28 +01:00
Camille GILLOT
877b2d79d9 Remove eval_always for lib_features. 2021-11-28 21:13:36 +01:00
Camille GILLOT
5fb4648757 Take a LocalDefId in expect_*item. 2021-11-28 21:09:45 +01:00
David Tolnay
cc53f1356d
Delete an unreachable codepath from format_args implementation 2021-11-28 11:52:38 -08:00
Matthias Krüger
67d175515f
Rollup merge of #91308 - BGR360:issue-88586, r=jackh726
Fix ICE when lowering `trait A where for<'a> Self: 'a`

Fixes #88586.

r? `@jackh726`

Jack, this fix is much smaller in scope than what I think you were proposing in the issue. Let me know if you had a vision for a larger refactor here.

cc `@JohnTitor`
2021-11-28 17:11:11 +01:00
Matthias Krüger
233c50e79e
Rollup merge of #91251 - oli-obk:wf_sync_statics, r=matthewjasper
Perform Sync check on static items in wf-check instead of during const checks

r? `@RalfJung`

This check is solely happening on the signature of the static item and not on its body, therefor it belongs into wf-checking instead of const checking.
2021-11-28 17:11:10 +01:00
Ben Reeves
6df2c78e1c Address PR feedback 2021-11-28 07:05:23 -06:00
bors
e6d2de9483 Auto merge of #91230 - eggyal:fallible-type-fold, r=jackh726
Make `TypeFolder::fold_*` return `Result`

Implements rust-lang/compiler-team#432.

Initially this is just a rebase of `@LeSeulArtichaut's` work in #85469 (abandoned; see https://github.com/rust-lang/rust/pull/85485#issuecomment-908781112).  At that time, it caused a regression in performance that required some further exploration... with this rebased PR bors can hopefully report some perf analysis from which we can investigate further (if the regression is indeed still present).

r? `@jackh726` cc `@nikomatsakis`
2021-11-28 13:04:27 +00:00
Matthias Krüger
7134ae0a8d
Rollup merge of #91303 - RalfJung:array-init-align, r=oli-obk
Miri: fix alignment check in array initialization

https://github.com/rust-lang/rust/pull/85376 introduced a regression in Miri, reported at https://github.com/rust-lang/miri/issues/1919 and https://github.com/rust-lang/miri/issues/1925. This PR fixes that. I will add tests to Miri once this lands.

r? `@oli-obk`
Fixes https://github.com/rust-lang/miri/issues/1919
Fixes https://github.com/rust-lang/miri/issues/1925
2021-11-28 10:42:40 +01:00
Matthias Krüger
9e8dfcffb7
Rollup merge of #91254 - Aaron1011:impl-candidate-err-ty, r=lcnr
Only check for errors in predicate when skipping impl assembly

Prior to PR #91205, checking for errors in the overall obligation
would check checking the `ParamEnv`, due to an incorrect
`super_visit_with` impl. With this bug fixed, we will now
bail out of impl candidate assembly if the `ParamEnv` contains
any error types.

In practice, this appears to be overly conservative - when an error
occurs early in compilation, we end up giving up early for some
predicates that we could have successfully evaluated without overflow.
By only checking for errors in the predicate itself, we avoid causing
additional spurious 'type annotations needed' errors after a 'real'
error has already occurred.

With this PR, the diagnostic changes caused by PR #91205 are reverted.
2021-11-28 10:42:39 +01:00
Ben Reeves
9155f672bf typeck: Ensure proper bound vars passed to add_bounds.
Fixes the ICE in #88586.
2021-11-27 23:59:08 -06:00
Ralf Jung
f8e3b31858 Miri: fix alignment check in array initialization 2021-11-27 18:18:48 -05:00
Aaron Hill
d18065d997
Only check for errors in predicate when skipping impl assembly
Prior to PR #91205, checking for errors in the overall obligation
would check checking the `ParamEnv`, due to an incorrect
`super_visit_with` impl. With this bug fixed, we will now
bail out of impl candidate assembly if the `ParamEnv` contains
any error types.

In practice, this appears to be overly conservative - when an error
occurs early in compilation, we end up giving up early for some
predicates that we could have successfully evaluated without overflow.
By only checking for errors in the predicate itself, we avoid causing
additional spurious 'type annotations needed' errors after a 'real'
error has already occurred.

With this PR, the diagnostic changes caused by PR #91205 are reverted.
2021-11-27 11:33:55 -06:00
Alan Egerton
afa6f92c46
Use intrinsic pointer methods 2021-11-27 16:59:18 +00:00
Alan Egerton
9f714ef035
Delegate from map_id to try_map_id 2021-11-27 16:55:21 +00:00
Alan Egerton
04f1c09f90
Avoid UB when short-circuiting try_map_id for Vec 2021-11-27 15:06:06 +00:00
Alan Egerton
51e15ac709
Remove erroneous merge conflict 2021-11-27 11:53:00 +00:00
Matthias Krüger
7c5bcd548b
Rollup merge of #91208 - estebank:eq-constraint, r=cjgillot
Account for incorrect `where T::Assoc = Ty` bound

Provide suggestoin to constrain trait bound for associated type.
Revert incorrect changes to `missing-bounds` test.

Address part of #20041.
2021-11-27 11:46:44 +01:00
bors
6d246f0c8d Auto merge of #91253 - matthiaskrgr:rollup-dnlcjmr, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #91169 (Change cg_ssa's get_param to borrow the builder mutably)
 - #91176 (If the thread does not get the lock in the short term, yield the CPU)
 - #91212 (Fix ICE due to out-of-bounds statement index when reporting borrowck error)
 - #91225 (Fix invalid scrollbar display on source code page)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-26 16:30:42 +00:00
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
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
Oli Scherer
18694126b1 Perform Sync check on static items in wf-check instead of during const checks 2021-11-26 14:22:45 +00:00
bors
454cc5fb86 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.
2021-11-26 13:42:35 +00: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
LeSeulArtichaut
6db9605d85
Use TypeFolder::Error for FullTypeResolver and QueryNormalizer
Co-authored-by: Alan Egerton <eggyal@gmail.com>
2021-11-26 07:40:43 +00:00
LeSeulArtichaut
30bf20a692
Unwrap the results of type folders
Co-authored-by: Alan Egerton <eggyal@gmail.com>
2021-11-26 07:38:25 +00:00
LeSeulArtichaut
6dc3dae46f
Adapt TypeFolder implementors to return a Result
Co-authored-by: Alan Egerton <eggyal@gmail.com>
2021-11-26 07:25:16 +00:00
LeSeulArtichaut
6e3fa20b00
Make TypeFoldable implementors short-circuit on error
Co-authored-by: Alan Egerton <eggyal@gmail.com>
2021-11-26 07:17:59 +00:00
LeSeulArtichaut
c5f0d0ebb4
Make TypeFolder::fold_* return Result 2021-11-26 06:53:35 +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
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
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
718a3b1f2d Fix issue 91206 2021-11-25 16:34:30 +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