Commit Graph

220990 Commits

Author SHA1 Message Date
bors
22a7a19f93 Auto merge of #98112 - saethlin:mir-alignment-checks, r=oli-obk
Insert alignment checks for pointer dereferences when debug assertions are enabled

Closes https://github.com/rust-lang/rust/issues/54915

- [x] Jake tells me this sounds like a place to use `MirPatch`, but I can't figure out how to insert a new basic block with a new terminator in the middle of an existing basic block, using `MirPatch`. (if nobody else backs up this point I'm checking this as "not actually a good idea" because the code looks pretty clean to me after rearranging it a bit)
- [x] Using `CastKind::PointerExposeAddress` is definitely wrong, we don't want to expose. Calling a function to get the pointer address seems quite excessive. ~I'll see if I can add a new `CastKind`.~ `CastKind::Transmute` to the rescue!
- [x] Implement a more helpful panic message like slice bounds checking.

r? `@oli-obk`
2023-03-31 08:50:35 +00:00
bors
ec7bb8da11 Auto merge of #109803 - matthiaskrgr:rollup-mojot7k, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #109598 (Improve documentation for str::replace() and str::replacen())
 - #109779 (Update gccjit and remove libc 0.1 dependency)
 - #109784 (Refactor glibc time64 support, riscv32 always has 64-bit `time_t`)
 - #109793 (add comment to `impl !Error for &str`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-31 06:10:06 +00:00
Matthias Krüger
ec276c7e67
Rollup merge of #109793 - lukas-code:negative-impl-comment, r=scottmcm
add comment to `impl !Error for &str`

I saw this impl in the [standard library docs](https://doc.rust-lang.org/nightly/core/error/trait.Error.html#impl-Error-for-%26str) and wondered why it's needed. This commit adds a comment to explain its existence.
2023-03-31 08:03:15 +02:00
Matthias Krüger
0708fbf5cb
Rollup merge of #109784 - beetrees:riscv32-time64, r=cuviper
Refactor glibc time64 support, riscv32 always has 64-bit `time_t`

Refactor existing support for 64-bit `time_t` on 32-bit glibc platforms, as riscv32 `time_t` is 64-bit by default. Split out of #109773.
2023-03-31 08:03:15 +02:00
Matthias Krüger
3f30b514ab
Rollup merge of #109779 - uweigand:s390x-gccjit-libc, r=WaffleLapkin
Update gccjit and remove libc 0.1 dependency

Fixes https://github.com/rust-lang/rust/issues/109774.
2023-03-31 08:03:14 +02:00
Matthias Krüger
41369b734d
Rollup merge of #109598 - veera-sivarajan:improve-wording, r=thomcc
Improve documentation for str::replace() and str::replacen()

Currently, to know what the function will return when the pattern doesn't match, the docs require the reader to understand the implementation detail and mentally evaluate or run the example code. It is not immediately clear.

This PR makes it more explicit so the reader can quickly find the information.
2023-03-31 08:03:14 +02:00
Ben Kimock
750707801b Disable the ui panic test on wasm32-bare 2023-03-30 23:46:44 -04:00
bors
eb3e9c1f45 Auto merge of #109762 - scottmcm:variantdef-indexvec, r=WaffleLapkin
Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>`

And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`.

There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places.

Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
2023-03-31 03:36:18 +00:00
bors
276029deae Auto merge of #109750 - compiler-errors:deep-reject-less-permissive-num-var, r=lcnr
numeric vars can only be unified with numerical types in deep reject

Don't consider numeric vars (int and float vars) to unify with non-numeric types during deep reject. This helps us reject incompatible impls sooner.
2023-03-31 00:59:04 +00:00
bors
c1d3610ac1 Auto merge of #109791 - compiler-errors:rollup-c3o710k, r=compiler-errors
Rollup of 6 pull requests

Successful merges:

 - #109347 (Skip no_mangle if the item has no name.)
 - #109522 (Implement current_dll_path for AIX)
 - #109679 (Freshen normalizes-to hack goal RHS in the evaluate loop)
 - #109704 (resolve: Minor improvements to effective visibilities)
 - #109739 (Closures always implement `FnOnce` in new solver)
 - #109758 (Parallel compiler cleanups)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-30 22:02:10 +00:00
Lukas Markeffsky
bdb0c7f427 add comment to impl !Error for &str 2023-03-30 22:19:28 +02:00
Michael Goulet
249198c1f8
Rollup merge of #109758 - nnethercote:parallel-cleanups, r=cjgillot
Parallel compiler cleanups

A few small improvements I found while looking closely at this code.

r? `@cjgillot`

cc `@Zoxc,` `@SparrowLii`
2023-03-30 12:42:21 -07:00
Michael Goulet
7cd96ae2d7
Rollup merge of #109739 - compiler-errors:new-solver-closure-fnonce, r=lcnr
Closures always implement `FnOnce` in new solver

We should process `[closure]: FnOnce(Tys...) -> Ty` obligations *before* fallback and closure analysis. We can do this by taking advantage of the fact that `FnOnce` is always implemented by closures, even before we definitely know the closure kind.

Fixes compiler-errors/next-solver-hir-issues#15

r? ``@oli-obk`` (trying to spread the reviewer load for new trait solver prs, and this one is pretty self-contained, though feel free to reassign 😸)
2023-03-30 12:42:20 -07:00
Michael Goulet
fbe738345c
Rollup merge of #109704 - petrochenkov:effvisclean, r=jackh726
resolve: Minor improvements to effective visibilities

See individual commits.
2023-03-30 12:42:19 -07:00
Michael Goulet
1ffb1afea7
Rollup merge of #109679 - compiler-errors:normalizes-to-hack-2, r=lcnr,BoxyUwU
Freshen normalizes-to hack goal RHS in the evaluate loop

Ensure that we repeatedly equate the unconstrained RHS of the normalizes-to hack goal with the *actual* RHS of the goal, even if the normalizes-to goal loops several times and thus we replace the unconstrained RHS var repeatedly.

Alternative to #109583.
2023-03-30 12:42:18 -07:00
Michael Goulet
bc7976eee5
Rollup merge of #109522 - bzEq:aix-current-dll-path, r=Nilstrieb
Implement current_dll_path for AIX

AIX doesn't feature `dladdr`, use `loadquery` instead.

`loadquery` is documented in https://www.ibm.com/docs/en/aix/7.2?topic=l-loadquery-subroutine.
2023-03-30 12:42:18 -07:00
Michael Goulet
987628e82b
Rollup merge of #109347 - cjgillot:issue-109305, r=WaffleLapkin
Skip no_mangle if the item has no name.

Fixes https://github.com/rust-lang/rust/issues/109305
2023-03-30 12:42:18 -07:00
bors
ec2f40c6b0 Auto merge of #109740 - compiler-errors:new-solver-deep-reject-placeholder-consts, r=lcnr
Don't ICE on placeholder consts in deep reject

Since we canonicalize const params into placeholder consts, we need to be able to handle them during deep reject.

r? `@lcnr` (though maybe `@oli-obk` can look at this one too, if he wants 😸)

Fixes compiler-errors/next-solver-hir-issues#10
2023-03-30 19:28:56 +00:00
beetrees
8d1bf505ff
Refactor glibc time64 support, riscv32 always has 64-bit time_t 2023-03-30 19:43:47 +01:00
Ulrich Weigand
9cd1a316aa Update gccjit and remove libc 0.1 dependency 2023-03-30 18:30:56 +02:00
Scott McMurray
4abb455529 Update ty::VariantDef to use IndexVec<FieldIdx, FieldDef>
And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`.

There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places.

Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
2023-03-30 09:23:40 -07:00
bors
789ee5e433 Auto merge of #108576 - megakorre:rustdock_additional_typecheck_before_clean, r=GuillaumeGomez
rustdoc: run more HIR validation to mirror rustc

# Explanation

While investigating these issues: https://github.com/rust-lang/rust/issues/107093, https://github.com/rust-lang/rust/issues/106079
I thought it maybe would be useful to test running `rustdoc` on all rust files under `tests/ui` grepping for files that causes any ICEs.
And these are the files I found would cause ICEs.
```
// These are handled by this fix.
tests/ui/late-bound-lifetimes/mismatched_arg_count.rs
tests/ui/associated-consts/issue-102335-const.rs
tests/ui/const-generics/generic_const_exprs/issue-102768.rs
tests/ui/const-generics/const-arg-type-arg-misordered.rs
tests/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.rs
tests/ui/typeck/issue-88643.rs
tests/ui/typeck/issue-75889.rs
tests/ui/typeck/issue-83621-placeholder-static-in-extern.rs
// These are not they will still produce a ICE after this change
tests/ui/limits/issue-56762.rs
tests/ui/union/projection-as-union-type-error-2.rs
tests/ui/union/projection-as-union-type-error.rs
```

I reduces the issues handled by this PR down to the tests added in the PR. That includes the linked issues.
But the 3 files that are not handled I will leave for a future PR.

This PR adds the `type_collecting` step from `hir_analysis::check_crate` to the rustdoc typechecks.
It had the following comment on it.
```
// this ensures that later parts of type checking can assume that items
// have valid types and not error
```
Adding the check report the same errors as rustc does for these input.
And not ICE when the lint checker walks the HIR or when in the `rustdoc::clean` pass.

This PR updates the expected errors of some existing rustdoc-ui tests (some now report less errors).
These new reported errors does mirror the errors reported by rustc.

# Performance
It does more checking so it will probably regress. We should run ``@bors` try `@rust-timer` queue` and see.

# Discussion

Maybe instead of calling a subset of the checks in `hir_analysis::check_crate` and having comments that say they should be kept in sync. We could instead call `check_crate` directly and pass in some flag. Maybe `check_toplevel_signatures_only` or something like that. That flag would have to skip most of the checks in that function tough.
2023-03-30 15:21:22 +00:00
Michael Goulet
177997e383 Closures always implement FnOnce in new solver 2023-03-30 15:11:42 +00:00
Patrik Kårlin
1f9e2d0538
rustdoc: tidy excess whitespace 2023-03-30 15:46:34 +02:00
Patrik Kårlin
df556a3177
rustdoc: add error messages to the test 2023-03-30 14:55:03 +02:00
Patrik Kårlin
4d571a9ccf
rustdoc: remove other redundant item 2023-03-30 14:55:03 +02:00
Patrik Kårlin
d1b6aa6834
rustdoc: remove excess from rustdoc test 2023-03-30 14:55:03 +02:00
Patrik Kårlin
2ee19c9c4c
rustdoc: remove redundant test 2023-03-30 14:55:03 +02:00
Patrik Kårlin
466fc4af84
rustdoc: update with --bless and change expected errors 2023-03-30 14:55:03 +02:00
Patrik Kårlin
9b5115f92b
rustdoc: run more HIR validation to mirror rustc 2023-03-30 14:55:03 +02:00
bors
516a6d3202 Auto merge of #109769 - JohnTitor:rollup-7n2bnpg, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #106985 (Enhanced doucmentation of binary search methods for `slice` and `VecDeque` for unsorted instances)
 - #109509 (compiletest: Don't allow tests with overlapping prefix names)
 - #109719 (RELEASES: Add "Only support Android NDK 25 or newer" to 1.68.0)
 - #109748 (Don't ICE on `DiscriminantKind` projection in new solver)
 - #109749 (Canonicalize float var as float in new solver)
 - #109761 (Drop binutils on powerpc-unknown-freebsd)
 - #109766 (Fix title for openharmony.md)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-30 12:44:25 +00:00
Yuki Okushi
6519ca462f
Rollup merge of #109766 - Amanieu:ohos-title, r=JohnTitor
Fix title for openharmony.md
2023-03-30 21:07:04 +09:00
Yuki Okushi
33ff1c9331
Rollup merge of #109761 - pkubaj:patch-1, r=ozkanonur
Drop binutils on powerpc-unknown-freebsd

FreeBSD 13.1 and 13.2 can build Rust with LLD just fine on powerpc.
2023-03-30 21:07:03 +09:00
Yuki Okushi
e1f4ddfdd9
Rollup merge of #109749 - compiler-errors:new-solver-float-var, r=lcnr
Canonicalize float var as float in new solver

Typo in new canonicalizer -- we should be canonicalizing float vars as `CanonicalTyVarKind::Float`, not `CanonicalTyVarKind::Int`.

Fixes compiler-errors/next-solver-hir-issues#9
2023-03-30 21:07:02 +09:00
Yuki Okushi
c1b28c3435
Rollup merge of #109748 - compiler-errors:new-solver-discr-kind-ice, r=lcnr
Don't ICE on `DiscriminantKind` projection in new solver

As title says, since we now actually call `Ty::discriminant_kind` on placeholder types 😃

Also drive-by simplify `Pointee::Metadata` projection logic, and fix the UI test because the `<T as Pointee>::Metadata` tests weren't actually exercising the new projection logic, since we still eagerly normalize (which hits `project.rs` in the old solver) in HIR typeck.

r? `@lcnr` tho feel free to re-roll, this pr is very low-priority and not super specific to the new trait solver.

Fixes compiler-errors/next-solver-hir-issues#14
2023-03-30 21:07:02 +09:00
Yuki Okushi
ae9c1bf090
Rollup merge of #109719 - tyilo:patch-1, r=Mark-Simulacrum
RELEASES: Add "Only support Android NDK 25 or newer" to 1.68.0

See https://blog.rust-lang.org/2023/01/09/android-ndk-update-r25.html and https://internals.rust-lang.org/t/rust-1-68-0-pre-release-testing/18481/2
2023-03-30 21:07:01 +09:00
Yuki Okushi
2981d7781c
Rollup merge of #109509 - ehuss:overlapping-tests, r=Mark-Simulacrum
compiletest: Don't allow tests with overlapping prefix names

Some tests will delete their output directory before starting. The output directory is based on the test names. If one test is the prefix of another test, then when that test starts, it could try to delete the output directory of the other test with the longer path, or otherwise clash with it while the two tests are trying to create/delete/modify the same directory.

In practice, this manifested as a random error on macOS where two tests were trying to create/delete/create `rustdoc/primitive` and `rustdoc/primitive/no_std`, which resulted in an EINVAL (InvalidInput) error.

This renames some of the offending tests, adds `compiletest-ignore-dir` to prevent compiletest from processing some files, and adds a check to prevent this from happening in the future.

Fixes #109397
2023-03-30 21:07:00 +09:00
Yuki Okushi
d6f27401f1
Rollup merge of #106985 - jofas:106746-fix, r=ChrisDenton
Enhanced doucmentation of binary search methods for `slice` and `VecDeque` for unsorted instances

Fixes #106746. Issue #106746 raises the concern that the binary search methods for slices and deques aren't explicit enough about the fact that they are only applicable to sorted slices/deques. I changed the explanation for these methods. I took the relatively harsh description of the behaviour of binary search on unsorted collections ("unspecified and meaningless") from the description of the [`partition_point`](https://doc.rust-lang.org/std/primitive.slice.html#method.partition_point) method:

> If this slice is not partitioned, the returned result is unspecified and meaningless, as this method performs a kind of binary search.
2023-03-30 21:06:59 +09:00
Amanieu d'Antras
4b7f14149b Fix title for openharmony.md 2023-03-30 12:06:07 +01:00
Nicholas Nethercote
08dec8969f Remove an out-of-date comment on QueryCache::lookup. 2023-03-30 21:14:43 +11:00
Nicholas Nethercote
44bfb6538e CacheAligned and Sharded don't need to derive Clone. 2023-03-30 21:14:43 +11:00
Nicholas Nethercote
0ccb60096a Remove RwLock::clone_guard.
It's unused.
2023-03-30 21:14:43 +11:00
Nicholas Nethercote
eeb5b782a6 Improve the rustc_data_structures::sync module doc comment.
Also, `MTRef<'a, T>` is a typedef for a reference to a `T`, but in
practice it's only used (and useful) in combination with `MTLock`, i.e.
`MTRef<'a, MTLock<T>>`. So this commit changes it to be a typedef for a
reference to an `MTLock<T>`, and renames it as `MTLockRef`. I think this
clarifies things, because I found `MTRef` quite puzzling at first.
2023-03-30 21:14:37 +11:00
bors
8a7ca936e6 Auto merge of #105587 - tgross35:once-cell-min, r=m-ou-se
Partial stabilization of `once_cell`

This PR aims to stabilize a portion of the `once_cell` feature:

- `core::cell::OnceCell`
- `std::cell::OnceCell` (re-export of the above)
- `std::sync::OnceLock`

This will leave `LazyCell` and `LazyLock` unstabilized, which have been moved to the `lazy_cell` feature flag.

Tracking issue: https://github.com/rust-lang/rust/issues/74465 (does not fully close, but it may make sense to move to a new issue)

Future steps for separate PRs:
- ~~Add `#[inline]` to many methods~~ #105651
- Update cranelift usage of the `once_cell` crate
- Update rust-analyzer usage of the `once_cell` crate
- Update error messages discussing once_cell

## To be stabilized API summary

```rust
// core::cell (in core/cell/once.rs)

pub struct OnceCell<T> { .. }

impl<T> OnceCell<T> {
    pub const fn new() -> OnceCell<T>;
    pub fn get(&self) -> Option<&T>;
    pub fn get_mut(&mut self) -> Option<&mut T>;
    pub fn set(&self, value: T) -> Result<(), T>;
    pub fn get_or_init<F>(&self, f: F) -> &T where F: FnOnce() -> T;
    pub fn into_inner(self) -> Option<T>;
    pub fn take(&mut self) -> Option<T>;
}

impl<T: Clone> Clone for OnceCell<T>;
impl<T: Debug> Debug for OnceCell<T>
impl<T> Default for OnceCell<T>;
impl<T> From<T> for OnceCell<T>;
impl<T: PartialEq> PartialEq for OnceCell<T>;
impl<T: Eq> Eq for OnceCell<T>;
```

```rust
// std::sync (in std/sync/once_lock.rs)

impl<T> OnceLock<T> {
    pub const fn new() -> OnceLock<T>;
    pub fn get(&self) -> Option<&T>;
    pub fn get_mut(&mut self) -> Option<&mut T>;
    pub fn set(&self, value: T) -> Result<(), T>;
    pub fn get_or_init<F>(&self, f: F) -> &T where F: FnOnce() -> T;
    pub fn into_inner(self) -> Option<T>;
    pub fn take(&mut self) -> Option<T>;
}

impl<T: Clone> Clone for OnceLock<T>;
impl<T: Debug> Debug for OnceLock<T>;
impl<T> Default for OnceLock<T>;
impl<#[may_dangle] T> Drop for OnceLock<T>;
impl<T> From<T> for OnceLock<T>;
impl<T: PartialEq> PartialEq for OnceLock<T>
impl<T: Eq> Eq for OnceLock<T>;
impl<T: RefUnwindSafe + UnwindSafe> RefUnwindSafe for OnceLock<T>;
unsafe impl<T: Send> Send for OnceLock<T>;
unsafe impl<T: Sync + Send> Sync for OnceLock<T>;
impl<T: UnwindSafe> UnwindSafe for OnceLock<T>;
```

No longer planned as part of this PR, and moved to the `rust_cell_try` feature gate:

```rust
impl<T> OnceCell<T> {
    pub fn get_or_try_init<F, E>(&self, f: F) -> Result<&T, E> where F: FnOnce() -> Result<T, E>;
}

impl<T> OnceLock<T> {
    pub fn get_or_try_init<F, E>(&self, f: F) -> Result<&T, E> where F: FnOnce() -> Result<T, E>;
}
```

I am new to this process so would appreciate mentorship wherever needed.
2023-03-30 10:12:23 +00:00
jofas
b085007313 removed deprecated markdown links from documentation 2023-03-30 10:20:57 +02:00
pkubaj
ad60b99835
Drop binutils on powerpc-unknown-freebsd
FreeBSD 13.1 and 13.2 can build Rust with LLD just fine on powerpc.
2023-03-30 07:05:24 +00:00
bors
f2d9a3d077 Auto merge of #109499 - spastorino:new-rpitit-19, r=compiler-errors
Give return-position impl traits in trait a (synthetic) name to avoid name collisions with new lowering strategy

The only needed commit from this PR is the last one.

r? `@compiler-errors`

Needs #109455.
2023-03-30 05:48:59 +00:00
bors
82bfda848e Auto merge of #109224 - oli-obk:smir, r=pnkfelix
Stable MIR: Add basic MIR body datastructures

At this point it will panic on most useful MIR, but you can do basic assignments

r? `@pnkfelix`
2023-03-30 02:59:25 +00:00
Michael Goulet
1d7192d6ea deep reject only unify numeric var with concrete numeric 2023-03-30 02:13:24 +00:00
Michael Goulet
977694aaec canonicalize float var as float in new solver 2023-03-30 01:15:37 +00:00