| Age | Commit message (Collapse) | Author | Lines |
|
Do leak check after function pointer coercion
cc #73154
I still need to clean diagnostics just a tad, but figured I would put this up anyways.
This change is made in order to make match arm coercion order-independent.
Basically, any time we do function pointer coercion, we follow it by doing a leak check. This is necessary because the LUB code doesn't handler higher-ranked things correctly, leading us to "coerce", but use the wrong type. A proper fix is to actually fix that code (so the type returned by `unify_and` is a supertype of both `a` and `b` if `Ok`). However, that requires a more in-depth fix, likely heavily overlapping with the new subtyping changes.
Here, I've been conservative and error early if we generate unsatisfiable constraints. Note, this should *mostly* only affect NLL, since migrate mode falls back to the LUB implementation (followed by leak check), whereas NLL only does sub.
There could be other coercion code that has an order-dependence where a leak check in the coercion code might be useful. However, this is more of a spot-fix for #73154 than a "permanent" fix, since we likely want to go the other way long-term, and allow this pattern without error.
r? `@nikomatsakis`
|
|
Move some tests to more reasonable directories
r? `@petrochenkov`
|
|
|
|
Implement proper stability check for const impl Trait, fall back to unstable const when undeclared
Continuation of #93960
`@jhpratt` it looks to me like the test was simply not testing for the failure you were looking for? Your checks actually do the right thing for const traits?
|
|
Recover when resolution did not resolve lifetimes.
This can happen for items inside a foreign fn's body, which are not visited at all.
Fixes https://github.com/rust-lang/rust/issues/97193
Fixes https://github.com/rust-lang/rust/issues/97194
|
|
correctly deal with user type ascriptions in pat
supersedes #93856
`thir::PatKind::AscribeUserType` previously resulted in `CanonicalUserTypeAnnotations` where the inferred type already had a subtyping relation according to `variance` to the `user_ty`.
The bug can pretty much be summarized as follows:
- during mir building
- `user_ty -> inferred_ty`: considers variance
- `StatementKind::AscribeUserType`: `inferred_ty` is the type of the place, so no variance needed
- during mir borrowck
- `user_ty -> inferred_ty`: does not consider variance
- `StatementKind::AscribeUserType`: applies variance
This mostly worked fine. The lifetimes in `inferred_ty` were only bound by its relation to `user_ty` and to the `place` of `StatementKind::AscribeUserType`, so it doesn't matter where exactly the subtyping happens.
It does however matter when having higher ranked subtying. At this point the place where the subtyping happens is forced, causing this mismatch between building and borrowck to result in unintended errors.
cc #96514 which is pretty much the same issue
r? `@nikomatsakis`
|
|
|
|
Add some more weird-exprs
Continuing from https://github.com/rust-lang/rust/pull/86713 (which stalled due to a thinking emoji), I'd like to "improve" the `weird-exprs.rs`-file (as I can't reopen that PR).
|
|
|
|
Remove `crate` visibility modifier
FCP to remove this syntax is just about complete in #53120. Once it completes, this should be merged ASAP to avoid merge conflicts.
The first two commits remove usage of the feature in this repository, while the last removes the feature itself.
|
|
|
|
|
|
|
|
|
|
Drop Tracking: Implement `fake_read` callback
This PR updates drop tracking's use of `ExprUseVisitor` so that we treat `fake_read` events as borrows. Without doing this, we were not handling match expressions correctly, which showed up as a breakage in the `addassign-yield.rs` test. We did not previously notice this because we still had rather large temporary scopes that we held borrows for, which changed in #94309.
This PR also includes a variant of the `addassign-yield.rs` test case to make sure we continue to have correct behavior here with drop tracking.
r? `@nikomatsakis`
|
|
|
|
|
|
Use unicode identifiers and a unicode emoji in weird-exprs.rs
|
|
Add or-pattern syntax in argument position
|
|
Rollup of 7 pull requests
Successful merges:
- #97109 (Fix misleading `cannot infer type for type parameter` error)
- #97187 (Reverse condition in Vec::retain_mut doctest)
- #97201 (Fix typo)
- #97203 (Minor tweaks to rustc book summary formatting.)
- #97208 (Do not emit the lint `unused_attributes` for *inherent* `#[doc(hidden)]` associated items)
- #97215 (Add complexity estimation of iterating over HashSet and HashMap)
- #97220 (Add regression test for#81827)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
Add regression test for#81827
Closes #81827
r? `@compiler-errors`
|
|
Do not emit the lint `unused_attributes` for *inherent* `#[doc(hidden)]` associated items
Fixes #97205 (embarrassing oversight from #96008).
`@rustbot` label A-lint
|
|
TaKO8Ki:fix-misleading-cannot-infer-type-for-type-parameter-error, r=oli-obk
Fix misleading `cannot infer type for type parameter` error
closes #93198
|
|
|
|
Lint single-use lifetimes during AST resolution
This PR rewrites `single_use_lifetime` and `unused_lifetime` lints to be based on the AST.
We have more information at our disposal, so we can reduce the amount of false positives.
Remaining false positive: single-use lifetimes in argument-position impl-trait.
I'm waiting for https://github.com/rust-lang/rust/issues/96529 to be fixed to have a clean and proper solution here.
Closes https://github.com/rust-lang/rust/issues/54079
Closes https://github.com/rust-lang/rust/issues/55057
Closes https://github.com/rust-lang/rust/issues/55058
Closes https://github.com/rust-lang/rust/issues/60554
Closes https://github.com/rust-lang/rust/issues/69952
r? `@petrochenkov`
|
|
fix ci error
emit err for `impl_item`
|
|
|
|
Rollup of 6 pull requests
Successful merges:
- #96565 (rustdoc: show implementations on `#[fundamental]` wrappers)
- #97179 (Add new lint to enforce whitespace after keywords)
- #97185 (interpret/validity: separately control checking numbers for being init and non-ptr)
- #97188 (Remove unneeded null pointer asserts in ptr2int casts)
- #97189 (Update .mailmap)
- #97192 (Say "last" instead of "rightmost" in the documentation for `std::str:rfind`)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
interpret/validity: separately control checking numbers for being init and non-ptr
This lets Miri control this in a more fine-grained way.
r? `@oli-obk`
|
|
rustdoc: show implementations on `#[fundamental]` wrappers
Fixes #92940
|
|
|
|
|
|
|
|
|
|
r=nikomatsakis
generator_interior: Count match pattern bindings as borrowed for the whole guard expression
The test case `yielding-in-match-guard.rs` was failing with `-Zdrop-tracking` enabled. The reason is that the copy of a local (`y`) was not counted as a borrow in typeck, while MIR did consider this as borrowed.
The correct thing to do here is to count pattern bindings are borrowed for the whole guard. Instead, what we were doing is to record the type at the use site of the variable and check if the variable comes from a borrowed pattern. Due to the fix for #57017, we were considering too small of a scope for this variable, which meant it was not counted as borrowed.
Because we now unconditionally record the borrow, rather than only for bindings that are used, this PR is also able to remove a lot of the logic around match bindings that was there before.
r? `@nikomatsakis`
|
|
Use pointers in `cell::{Ref,RefMut}` to avoid `noalias`
When `Ref` and `RefMut` were based on references, they would get LLVM `noalias` attributes that were incorrect, because that alias guarantee is only true until the guard drops. A `&RefCell` on the same value can get a new borrow that aliases the previous guard, possibly leading to miscompilation. Using `NonNull` pointers in `Ref` and `RefCell` avoids `noalias`.
Fixes the library side of #63787, but we still might want to explore language solutions there.
|
|
|
|
This reverts commit 0d270b5e9f48268735f9a05462df65c9d1039855.
|
|
|
|
Thanks to @tmiasko for this one!
|
|
|
|
|
|
non-ptr
|
|
Add regression test for #88119
Closes #88119
|
|
Improve `u32 as char` cast diagnostic
Fixes #97160
|
|
|
|
|
|
|
|
This alters the diagnostics a bit, as the trait method is still stable.
The only thing this check does is ensure that compilation fails if a
trait implementation is declared const-stable.
|
|
Rather than deferring to const eval for checking if a trait is const, we
now check up-front. This allows the error to be emitted earlier, notably
at the same time as other stability checks.
Also included in this commit is a change of the default const stability
level to UNstable. Previously, an item that was `const` but did not
explicitly state it was unstable was implicitly stable.
|