Commit graph

8969 commits

Author SHA1 Message Date
bors
e249ce6b23 Auto merge of #90422 - GuillaumeGomez:rollup-s1mdag0, r=GuillaumeGomez
Rollup of 5 pull requests

Successful merges:

 - #90156 (Remove underlines from non-top docblocks.)
 - #90183 (Show all Deref implementations recursively)
 - #90202 (Improve and test cross-crate hygiene)
 - #90375 (Use `is_global` in `candidate_should_be_dropped_in_favor_of`)
 - #90399 (Skipping verbose diagnostic suggestions when calling .as_ref() on type not implementing AsRef)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-30 19:31:47 +00:00
Guillaume Gomez
197da45e18
Rollup merge of #90399 - yuvaldolev:as-ref-overly-verbose-diagnostic, r=estebank
Skipping verbose diagnostic suggestions when calling .as_ref() on type not implementing AsRef

Addresses #89806

Skipping suggestions when calling `.as_ref()` for types that do not implement the `AsRef` trait.

r? `@estebank`
2021-10-30 20:30:28 +02:00
Guillaume Gomez
06bb1ff1b5
Rollup merge of #90375 - yanok:master, r=lcnr
Use `is_global` in `candidate_should_be_dropped_in_favor_of`

This manifistated in #90195 with compiler being unable to keep
one candidate for a trait impl, if where is a global impl and more
than one trait bound in the where clause.

Before #87280 `candidate_should_be_dropped_in_favor_of` was using
`TypeFoldable::is_global()` that was enough to discard the two
`ParamCandidate`s. But #87280 changed it to use
`TypeFoldable::is_known_global()` instead, which is pessimistic, so
now the compiler drops the global impl instead (because
`is_known_global` is not sure) and then can't decide between the
two `ParamCandidate`s.

Switching it to use `is_global` again solves the issue.

Fixes #90195.
2021-10-30 20:30:27 +02:00
Guillaume Gomez
1a1f525bb0
Rollup merge of #90202 - matthewjasper:xcrate-hygiene, r=petrochenkov
Improve and test cross-crate hygiene

- Decode the parent expansion for traits and enums in `rustc_resolve`, this was already being used for resolution in typeck
- Avoid suggesting importing names with def-site hygiene, since it's often not useful
- Add more tests

r? `@petrochenkov`
2021-10-30 20:30:27 +02:00
bors
2609fab8e4 Auto merge of #90205 - mati865:link-modifiers-in-rustc, r=petrochenkov
Repace use of `static_nobundle` with `native_link_modifiers` within Rust codebase

This fixes warnings when building Rust and running tests:
```
warning: library kind `static-nobundle` has been superseded by specifying `-bundle` on library kind `static`. Try `static:-bundle`
warning: `rustc_llvm` (lib) generated 2 warnings (1 duplicate)
```
2021-10-30 16:22:49 +00:00
Matthias Krüger
f9111e0336
Rollup merge of #90402 - wesleywiser:query_descriptions, r=oli-obk
Add a few query descriptions
2021-10-30 14:37:04 +02:00
Matthias Krüger
d99dc7abfa
Rollup merge of #90396 - b-naber:type_flags_ices_default_anon_consts, r=lcnr
Prevent type flags assertions being thrown in default_anon_const_substs if errors occurred

Fixes https://github.com/rust-lang/rust/issues/90364
Fixes https://github.com/rust-lang/rust/issues/88997

r? ``@lcnr``
2021-10-30 14:37:03 +02:00
Matthias Krüger
88e0bea7ca
Rollup merge of #90395 - b-naber:const-expr-type-relation, r=oli-obk
Restrict liveness of mutable borrow of inner infcx in ConstInferUnifier::consts

Fixes https://github.com/rust-lang/rust/issues/89304

r? ``@oli-obk``
2021-10-30 14:37:02 +02:00
Matthias Krüger
a213740abe
Rollup merge of #90374 - GuillaumeGomez:unify-rustdoc-book-titles, r=camelid
Unify titles in rustdoc book doc attributes chapter

As discussed in https://github.com/rust-lang/rust/pull/90339.

I wasn't able to find out where the link to the titles was used so let's see if the CI fails. :)

r? ``@camelid``
2021-10-30 14:37:00 +02:00
Guillaume Gomez
0c70831171 Unify titles in rustdoc book doc attributes chapter 2021-10-29 21:27:44 +02:00
Michael Woerister
6771ac3f19 Update odht crate to 0.3.1 (big-endian bugfix) 2021-10-29 18:05:15 +02:00
Wesley Wiser
60bf2f1926 Add a few query descriptions 2021-10-29 11:15:45 -04:00
Yuval Dolev
cad2d21cb6 Explicitly skipping suggestions for 'Pin' as it does not implement the 'AsRef' trait 2021-10-29 15:49:55 +03:00
Yuval Dolev
e2151497bf Skip suggestions for the AsRef trait 2021-10-29 15:49:55 +03:00
bors
9ed5b94b28 Auto merge of #90373 - tmiasko:union-qualification, r=oli-obk
Use type based qualification for unions

Union field access is currently qualified based on the qualification of
a value previously assigned to the union. At the same time, every union
access transmutes the content of the union, which might result in a
different qualification.

For example, consider constants A and B as defined below, under the
current rules neither contains interior mutability, since a value used
in the initial assignment did not contain `UnsafeCell` constructor.

```rust
#![feature(untagged_unions)]

union U { i: u32, c: std::cell::Cell<u32> }
const A: U = U { i: 0 };
const B: std::cell::Cell<u32> = unsafe { U { i: 0 }.c };
```

To avoid the issue, the changes here propose to consider the content of
a union as opaque and use type based qualification for union types.

Fixes #90268.

`@rust-lang/wg-const-eval`
2021-10-29 12:21:09 +00:00
b-naber
87fbf3c5aa ignore type flags insertion in default_anon_const_substs if error occurred 2021-10-29 13:47:53 +02:00
b-naber
04cb19692c don't mutably borrow inner infcx in all of ConstInferUnifier::consts 2021-10-29 12:32:06 +02:00
bors
37f70a0e1e Auto merge of #90214 - tmiasko:indirect-mutation-qualif, r=ecstatic-morse,oli-obk
Consider indirect mutation during const qualification dataflow

Previously a local would be qualified if either one of two separate data
flow computations indicated so. First determined if a local could
contain the qualif, but ignored any forms of indirect mutation. Second
determined if a local could be mutably borrowed (and so indirectly
mutated), but which in turn ignored the qualif.

The end result was incorrect because the effect of indirect mutation was
effectivelly ignored in the all but the final stage of computation.

In the new implementation the indirect mutation is directly incorporated
into the qualif data flow. The local variable becomes immediately
qualified once it is mutably borrowed and borrowed place type can
contain the qualif.

In general we will now reject additional programs, program that were
prevously unintentionally accepted.

There are also some cases which are now accepted but were previously
rejected, because previous implementation didn't consider whether
borrowed place could have the qualif under the consideration.

Fixes #90124.

r? `@ecstatic-morse`
2021-10-29 08:38:39 +00:00
bors
88a5a984fe Auto merge of #90380 - Mark-Simulacrum:revert-89558-query-stable-lint, r=lcnr
Revert "Add rustc lint, warning when iterating over hashmaps"

Fixes perf regressions introduced in https://github.com/rust-lang/rust/pull/90235 by temporarily reverting the relevant PR.
2021-10-29 04:55:51 +00:00
bors
df76418f1e Auto merge of #90387 - matthiaskrgr:rollup-b2x8v0x, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #90082 (Fix minor typos)
 - #90336 (Remove extra lines in examples for `Duration::try_from_secs_*`)
 - #90376 (Various cleanups around opaque types)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-28 22:44:45 +00:00
Matthias Krüger
bcee0a6ecc
Rollup merge of #90376 - oli-obk:🧹, r=spastorino
Various cleanups around opaque types

Best reviewed commit by commit.

This PR has no functional changes.

Mostly it's moving logic from an extension trait in rustc_trait_selection to inherent impls on rustc_infer.
2021-10-29 00:30:31 +02:00
Matthew Jasper
d8426ea636 Remove ModData from rustc_metadata
This avoids having to decode 2 `Lazy`s when decoding a modules exports.
2021-10-28 21:48:21 +01:00
bors
c390d69a61 Auto merge of #90281 - xldenis:public-borrow-set, r=nikomatsakis
Add BorrowSet to public api

This PR adds `BorrowSet` to the public api so that verification tools can obtain the activation and reservation points of two phase borrows without having to redo calculations themselves (and thus potentially differently from rustc).

Turns out we already can obtain `MoveData` thanks to the public `HasMoveData` trait, so constructing a `BorrowSet` should not provide much of an issue. However, I can't speak to the soundness of this approach, is it safe to take an under-approximation of `MoveData`?

r? `@nikomatsakis`
2021-10-28 19:34:01 +00:00
bors
85c0558d03 Auto merge of #90218 - JakobDegen:adt_significant_drop_fix, r=nikomatsakis
Fixes incorrect handling of ADT's drop requirements

Fixes #90024 and a bunch of duplicates.

The main issue was just that the contract of `NeedsDropTypes::adt_components` was inconsistent; the list of types it might return were the generic parameters themselves or the fields of the ADT, depending on the nature of the drop impl. This meant that the caller could not determine whether a `.subst()` call was still needed on those types; it called `.subst()` in all cases, and this led to ICEs when the returned types were the generic params.

First contribution of more than a few lines, so feedback definitely appreciated.
2021-10-28 16:03:13 +00:00
Mark Rousskov
3215eeb99f
Revert "Add rustc lint, warning when iterating over hashmaps" 2021-10-28 11:01:42 -04:00
Oli Scherer
bc552fc417 Move instantiate_opaque_types to rustc_infer.
It does not depend on anything from rustc_trait_selection anymore.
2021-10-28 14:12:24 +00:00
Oli Scherer
a8f06b249b Move some functions into rustc_infer.
They don't depend on trait selection anymore, so there is no need for an extension trait.
2021-10-28 13:54:11 +00:00
Oli Scherer
849b73b8d9 Manually inline a function that is only ever called at the end of another function 2021-10-28 13:42:16 +00:00
Oli Scherer
f1a2f2098f Remove dead code.
We don't do member constraint checks in regionck anymore.
All member constraint checks are done in mir borrowck.
2021-10-28 13:38:41 +00:00
Ilya Yanok
6f942a2f4a Reformat the changed line to make tidy happy 2021-10-28 13:23:49 +00:00
bors
c4ff03f689 Auto merge of #90145 - cjgillot:sorted-map, r=michaelwoerister
Use SortedMap in HIR.

Closes https://github.com/rust-lang/rust/issues/89788
r? `@ghost`
2021-10-28 13:04:40 +00:00
Ilya Yanok
6c61db4407 Use is_global in candidate_should_be_dropped_in_favor_of
This manifistated in #90195 with compiler being unable to keep
one candidate for a trait impl, if where is a global impl and more
than one trait bound in the where clause.

Before #87280 `candidate_should_be_dropped_in_favor_of` was using
`TypeFoldable::is_global()` that was enough to discard the two
`ParamCandidate`s. But #87280 changed it to use
`TypeFoldable::is_known_global()` instead, which is pessimistic, so
now the compiler drops the global impl instead (because
`is_known_global` is not sure) and then can't decide between the
two `ParamCandidate`s.

Switching it to use `is_global` again solves the issue.

Fixes #90195.
2021-10-28 12:49:46 +00:00
Tomasz Miąsko
3f778f31b6 Use type based qualification for unions
Union field access is currently qualified based on the qualification of
a value previously assigned to the union. At the same time, every union
access transmutes the content of the union, which might result in a
different qualification.

For example, consider constants A and B as defined below, under the
current rules neither contains interior mutability, since a value used
in the initial assignment did not contain `UnsafeCell` constructor.

```rust
#![feature(untagged_unions)]

union U { i: u32, c: std::cell::Cell<u32> }
const A: U = U { i: 0 };
const B: std::cell::Cell<u32> = unsafe { U { i: 0 }.c };
```

To avoid the issue, the changes here propose to consider the content of
a union as opaque and use type based qualification for union types.
2021-10-28 00:00:00 +00:00
bors
4e0d3973fa Auto merge of #90347 - matthiaskrgr:rollup-rp2ms7j, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #90239 (Consistent big O notation in map.rs)
 - #90267 (fix: inner attribute followed by outer attribute causing ICE)
 - #90288 (Add hint for people missing `TryFrom`, `TryInto`, `FromIterator` import pre-2021)
 - #90304 (Add regression test for #75961)
 - #90344 (Add tracking issue number to const_cstr_unchecked)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-27 18:42:13 +00:00
Matthias Krüger
83d5c24071
Rollup merge of #90288 - JakobDegen:import_diagnostics, r=davidtwco
Add hint for people missing `TryFrom`, `TryInto`, `FromIterator` import pre-2021

Adds a hint anytime a `TryFrom`, `TryInto`, `FromIterator` import is suggested noting that these traits are automatically imported in Edition 2021.
2021-10-27 18:25:46 +02:00
Matthias Krüger
17d1742028
Rollup merge of #90267 - EliseZeroTwo:elisezerotwo/fix_invalid_attrs_ice, r=Aaron1011
fix: inner attribute followed by outer attribute causing ICE

Fixes #87936, #88938, and #89971.

This removes the assertion that validates that there are no outer attributes following inner attributes. Where the inner attribute is invalid you get an actual error.
2021-10-27 18:25:44 +02:00
bors
dd757b9e06 Auto merge of #90273 - nbdd0121:const, r=fee1-dead
Clean up special function const checks

Mark them as const and `#[rustc_do_not_const_check]` instead of hard-coding them in const-eval checks.

r? `@oli-obk`
`@rustbot` label A-const-eval T-compiler
2021-10-27 15:32:42 +00:00
bors
a8f6e614f8 Auto merge of #89652 - rcvalle:rust-cfi, r=nagisa
Add LLVM CFI support to the Rust compiler

This PR adds LLVM Control Flow Integrity (CFI) support to the Rust compiler. It initially provides forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their number of arguments.

Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by defining and using compatible type identifiers (see Type metadata in the design document in the tracking issue #89653).

LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto).

Thank you, `@eddyb` and `@pcc,` for all the help!
2021-10-27 09:19:42 +00:00
Gary Guo
223f58085a Remove is_const_fn in find_mir_or_eval_fn 2021-10-27 07:21:28 +01:00
bors
a9b2bfb5ed Auto merge of #89937 - JohnTitor:fix-89875, r=Amanieu
Properly check `target_features` not to trigger an assertion

Fixes #89875
I think it should be a condition instead of an assertion to check if it's a register as it's possible that `reg` is a register class.
Also, this isn't related to the issue directly, but `is_target_supported` doesn't check `target_features` attributes. Is there any way to check it on rustc_codegen_llvm?

r? `@Amanieu`
2021-10-27 03:08:47 +00:00
Jakob Degen
cb336f1f67 Reverting switching test to no_std and adjust output after rebase. 2021-10-26 22:30:15 -04:00
Jakob Degen
958e645946 Adds hint if a trait fails to resolve and a newly added one in Edition 2021 is suggested 2021-10-26 22:17:01 -04:00
Jakob Degen
3876753668 Add diagnostic in case of failed .try_into() method call pre-Edition 2021 2021-10-26 22:17:01 -04:00
bors
c7a30c8b68 Auto merge of #90075 - pierwill:fix-79717, r=petrochenkov
Edit error messages for `rustc_resolve::AmbiguityKind` variants

Edit the language of the ambiguity descriptions for E0659. These strings now appear as notes.

Closes #79717.
2021-10-26 07:57:51 +00:00
Tomasz Miąsko
93f85f5a9d Consider indirect mutation during const qualification dataflow
Previously a local would be qualified if either one of two separate data
flow computations indicated so. First determined if a local could
contain the qualif, but ignored any forms of indirect mutation. Second
determined if a local could be mutably borrowed (and so indirectly
mutated), but which in turn ignored the qualif.

The end result was incorrect because the effect of indirect mutation was
effectivelly ignored in the all but the final stage of computation.

In the new implementation the indirect mutation is directly incorporated
into the qualif data flow. The local variable becomes immediately
qualified once it is mutably borrowed and borrowed place type can
contain the qualif.

In general we will now reject additional programs, program that were
prevously unintentionally accepted.

There are also some cases which are now accepted but were previously
rejected, because previous implementation didn't consider whether
borrowed place could have the qualif under the consideration.
2021-10-26 08:20:01 +02:00
Matthias Krüger
fc8df9b0b8
Rollup merge of #90241 - DrMeepster:thiscall_lint_upgrade, r=petrochenkov
Make thiscall abi on unsupported platforms a hard error

As suggested in https://github.com/rust-lang/rust/issues/42202#issuecomment-950205016, this PR makes use of the `thiscall` abi on unsupported a hard error instead of a lint.
2021-10-26 06:14:07 +02:00
Matthias Krüger
b0df3af5c3
Rollup merge of #90181 - notriddle:notriddle/error-pointer, r=estebank
fix(rustc_typeck): report function argument errors on matching type

Fixes #90101
2021-10-26 06:14:06 +02:00
Yuki Okushi
12647eab79
Properly check target_features not to trigger an assertion 2021-10-26 11:02:51 +09:00
Yuki Okushi
630df7c54a
Remove unnecessary check for registers
`is_clobber()` already checks if `reg` is a register and the both
values should be the same.
2021-10-26 11:02:51 +09:00
Yuki Okushi
f5cbb9b9e6
Fix some typos 2021-10-26 11:02:47 +09:00