Commit Graph

216057 Commits

Author SHA1 Message Date
Matthias Krüger
53ccee0d38
Rollup merge of #107096 - clubby789:fluent-bad-messageref, r=compiler-errors
Detect references to non-existant messages in Fluent resources

Should help with cases like #107091, where `{variable}` (a message reference) is accidentally typed, rather than `{$variable}` (a variable reference)

Fixes #107370

```@rustbot``` label +A-translation
2023-01-28 11:11:07 +01:00
Matthias Krüger
45430a5351
Rollup merge of #105524 - Ayush1325:libc-free, r=ChrisDenton
Replace libc::{type} with crate::ffi::{type}

Replace libc::{type} imports with crate::ffi::{type} outside of `std::sys` and `std::os`.

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-01-28 11:11:06 +01:00
Matthias Krüger
36ef4f15d3
Rollup merge of #104252 - faern:stabilize-const_socketaddr, r=JohnTitor
Stabilize the const_socketaddr feature

Stabilizes `#![feature(const_socketaddr)]`. Tracking issue: #82485
Closes #82485

This has been unstably const for over a year now. And the code change simplifying the constness of the `new` constructors has been in stable Rust since 1.64 (a bit over a full release cycle). I'm not aware of any blockers to this stabilization.
2023-01-28 11:11:06 +01:00
Matthias Krüger
e3048c7838
Rollup merge of #104012 - chenyukang:yukang/fix-103882-deli-indentation, r=petrochenkov
Improve unexpected close and mismatch delimiter hint in TokenTreesReader

Fixes #103882
Fixes #68987
Fixes #69259

The inner indentation mismatching will be covered by outer block, the new added function `report_error_prone_delim_block` will find out the error prone candidates for reporting.
2023-01-28 11:11:05 +01:00
bors
226b2496fc Auto merge of #107400 - matthiaskrgr:rollup-l6bycds, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #107022 (Implement `SpecOptionPartialEq` for `cmp::Ordering`)
 - #107100 (Use proper `InferCtxt` when probing for associated types in astconv)
 - #107103 (Use new solver in `evaluate_obligation` query (when new solver is enabled))
 - #107190 (Recover from more const arguments that are not wrapped in curly braces)
 - #107306 (Correct suggestions for closure arguments that need a borrow)
 - #107339 (internally change regions to be covariant)
 - #107344 (Minor tweaks in the new solver)
 - #107373 (Don't merge vtables when full debuginfo is enabled.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-28 06:46:42 +00:00
Ayush Singh
c50d3e28ab
Replace libc::{type} with crate::ffi::{type}
Replace libc::{type} imports with crate::ffi::{type} outside of
`std::sys` and `std::os`.

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-01-28 11:24:13 +05:30
Matthias Krüger
c89bb159f6
Rollup merge of #107373 - michaelwoerister:dont-merge-vtables-when-debuginfo, r=WaffleLapkin
Don't merge vtables when full debuginfo is enabled.

This PR makes the compiler not emit the `unnamed_addr` attribute for vtables when full debuginfo is enabled, so that they don't get merged even if they have the same contents. This allows debuggers to more reliably map from a dyn pointer to the self-type of a trait object by looking at the vtable's debuginfo.

The PR only changes the behavior of the LLVM backend as other backends don't emit vtable debuginfo (as far as I can tell).

The performance impact of this change should be small as [measured](https://github.com/rust-lang/rust/pull/103514#issuecomment-1290833854) in a previous PR.
2023-01-28 05:20:19 +01:00
Matthias Krüger
ab769a0bac
Rollup merge of #107344 - compiler-errors:new-solver-tweaks, r=lcnr
Minor tweaks in the new solver

1. `InferCtxt::probe` is not needed in `compute_subtype_goal` and `compute_well_formed_goal`.
2. Add a handful of comments.
3. Add a micro-optimization in `consider_assumption` where we check the def-ids of the assumption and goal match before instantiating any binders.

r? ``@lcnr``
2023-01-28 05:20:19 +01:00
Matthias Krüger
a5caa989c9
Rollup merge of #107339 - aliemjay:covariant, r=lcnr
internally change regions to be covariant

Surprisingly, we consider the reference type `&'a T` to be contravaraint in its lifetime parameter. This is confusing and conflicts with the documentation we have in the reference, rustnomicon, and rustc-dev-guide. This also arguably not the correct use of terminology since we can use `&'static u8` in a place where `&' a u8` is expected, this implies that `&'static u8 <: &' a u8` and consequently `'static <: ' a`, hence covariance.

Because of this, when relating two types, we used to switch the argument positions in a confusing way:
`Subtype(&'a u8 <: &'b u8) => Subtype('b <: 'a) => Outlives('a: 'b) => RegionSubRegion('b <= 'a)`

The reason for the current behavior is probably that we wanted `Subtype('b <: 'a)` and `RegionSubRegion('b <= 'a)` to be equivalent, but I don' t think this is a good reason since these relations are sufficiently different in that the first is a relation in the subtyping lattice and is intrinsic to the type-systems, while the the second relation is an implementation detail of regionck.

This PR changes this behavior to use covariance, so..
`Subtype(&'a u8 <: &'b u8) => Subtype('a <: 'b) => Outlives('a: 'b) => RegionSubRegion('b <= 'a) `

Resolves #103676

r? `@lcnr`
2023-01-28 05:20:18 +01:00
Matthias Krüger
fa2cd945af
Rollup merge of #107306 - compiler-errors:correct-sugg-for-closure-arg-needs-borrow, r=oli-obk
Correct suggestions for closure arguments that need a borrow

Fixes #107301 by dealing with binders correctly
Fixes another issue where we were suggesting adding just `&` when we expected `&mut _` in a closure arg
2023-01-28 05:20:18 +01:00
Matthias Krüger
260e04879e
Rollup merge of #107190 - fmease:fix-81698, r=compiler-errors
Recover from more const arguments that are not wrapped in curly braces

Recover from some array, borrow, tuple & arithmetic expressions in const argument positions that lack curly braces and provide a suggestion to fix the issue continuing where #92884 left off. Examples of such expressions: `[]`, `[0]`, `[1, 2]`, `[0; 0xff]`, `&9`, `("", 0)` and `(1 + 2) * 3` (we previously did not recover from them).

I am not entirely happy with my current solution because the code that recovers from `[0]` (coinciding with a malformed slice type) and `[0; 0]` (coinciding with a malformed array type) is quite fragile as the aforementioned snippets are actually successfully parsed as types by `parse_ty` since it itself already recovers from them (returning `[⟨error⟩]` and `[⟨error⟩; 0]` respectively) meaning I have to manually look for `TyKind::Err`s and construct a separate diagnostic for the suggestion to attach to (thereby emitting two diagnostics in total).

Fixes #81698.
`@rustbot` label A-diagnostics
r? diagnostics
2023-01-28 05:20:17 +01:00
Matthias Krüger
3b6593a0b4
Rollup merge of #107103 - compiler-errors:new-solver-evaluate_obligation, r=lcnr
Use new solver in `evaluate_obligation` query (when new solver is enabled)

(only when `-Ztrait-solver=next`, of course)

... Does this make sense? It seems to me like it should be reasonable, but maybe there's some reason why this is a bad idea.

r? ``@lcnr``

Needs a perf run because I guess this `solver == TraitSolver::Next` check is on a hot path.
2023-01-28 05:20:16 +01:00
Matthias Krüger
28188d17ba
Rollup merge of #107100 - compiler-errors:issue-107087, r=lcnr
Use proper `InferCtxt` when probing for associated types in astconv

Fixes #107087
2023-01-28 05:20:16 +01:00
Matthias Krüger
7b78b6a78d
Rollup merge of #107022 - scottmcm:ordering-option-eq, r=m-ou-se
Implement `SpecOptionPartialEq` for `cmp::Ordering`

Noticed as I continue to explore options for having code using `partial_cmp` optimize better.

Before:
```llvm
; Function Attrs: mustprogress nofree nosync nounwind willreturn uwtable
define noundef zeroext i1 `@ordering_eq(i8` noundef %0, i8 noundef %1) unnamed_addr #0 {
start:
  %2 = icmp eq i8 %0, 2
  br i1 %2, label %bb1.i, label %bb3.i

bb1.i:                                            ; preds = %start
  %3 = icmp eq i8 %1, 2
  br label %"_ZN55_$LT$T$u20$as$u20$core..option..SpecOptionPartialEq$GT$2eq17hb7e7beacecde585fE.exit"

bb3.i:                                            ; preds = %start
  %.not.i = icmp ne i8 %1, 2
  %4 = icmp eq i8 %0, %1
  %spec.select.i = and i1 %.not.i, %4
  br label %"_ZN55_$LT$T$u20$as$u20$core..option..SpecOptionPartialEq$GT$2eq17hb7e7beacecde585fE.exit"

"_ZN55_$LT$T$u20$as$u20$core..option..SpecOptionPartialEq$GT$2eq17hb7e7beacecde585fE.exit": ; preds = %bb1.i, %bb3.i
  %.0.i = phi i1 [ %3, %bb1.i ], [ %spec.select.i, %bb3.i ]
  ret i1 %.0.i
}
```

After:
```llvm
; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn uwtable
define noundef zeroext i1 `@ordering_eq(i8` noundef %0, i8 noundef %1) unnamed_addr #1 {
start:
  %2 = icmp eq i8 %0, %1
  ret i1 %2
}
```

(Which <https://alive2.llvm.org/ce/z/-rop5r> says LLVM *could* just do itself, but there's probably an issue already open for that problem from when this was originally looked at for `Option<NonZeroU8>` and friends.)
2023-01-28 05:20:15 +01:00
bors
252741673b Auto merge of #107360 - bjorn3:fix_thin_archive_reading, r=wesleywiser
Fix thin archive reading

This includes a revert of https://github.com/rust-lang/rust/pull/105221 to restore fat archive reading with LlvmArchiveBuilder.

Should fix #107162, #107334 and https://github.com/google/shaderc-rs/issues/133
2023-01-28 04:02:25 +00:00
Scott McMurray
3e9d1e40cb Link to the LLVM issue from a comment on SpecOptionPartialEq 2023-01-27 19:09:52 -08:00
bors
6cd6bad51f Auto merge of #101692 - cjgillot:generator-lazy-witness, r=oli-obk
Compute generator saved locals on MIR

Generators are currently type-checked by introducing a `witness` type variable, which is unified with a `GeneratorWitness(captured types)` whose purpose is to ensure that the auto traits correctly migrate from the captured types to the `witness` type.  This requires computing the captured types on HIR during type-checking, only to re-do it on MIR later.

This PR proposes to drop the HIR-based computation, and only keep the MIR one.  This is done in 3 steps.
1. During type-checking, the `witness` type variable is never unified.  This allows to stall all the obligations that depend on it until the end of type-checking.  Then, the stalled obligations are marked as successful, and saved into the typeck results for later verification.
2. At type-checking writeback, `witness` is replaced by `GeneratorWitnessMIR(def_id, substs)`.  From this point on, all trait selection involving `GeneratorWitnessMIR` will fetch the MIR-computed locals, similar to what opaque types do.  There is no lifetime to be preserved here: we consider all the lifetimes appearing in this witness type to be higher-ranked.
3. After borrowck, the stashed obligations are verified against the actually computed types, in the `check_generator_obligations` query.  If any obligation was wrongly marked as fulfilled in step 1, it should be reported here.

There are still many issues:
- ~I am not too happy having to filter out some locals from the checked bounds, I think this is MIR building that introduces raw pointers polluting the analysis;~ solved by a check specific to static variables.
- the diagnostics for captured types don't show where they are used/dropped;
- I do not attempt to support chalk.

cc `@eholk` `@jyn514` for the drop-tracking work
r? `@oli-obk` as you warned me of potential unsoundness
2023-01-28 01:05:29 +00:00
Camille GILLOT
d3d626920a Bless mir-opt tests. 2023-01-27 22:01:47 +00:00
Camille GILLOT
de110f9208 Pacify tidy. 2023-01-27 22:01:25 +00:00
Camille GILLOT
65c3c90f3e Restrict amount of ignored locals. 2023-01-27 22:01:12 +00:00
bors
7d4df2d30e Auto merge of #107386 - flip1995:clippyup, r=Manishearth
Update Clippy

r? `@Manishearth`
2023-01-27 21:20:39 +00:00
Camille GILLOT
c51fc382bd Bless ui-fulldeps. 2023-01-27 20:10:25 +00:00
Camille GILLOT
0e52a671d4 Bless tests. 2023-01-27 20:10:17 +00:00
Camille GILLOT
60e04d1e8c Compute generator saved locals on MIR. 2023-01-27 20:10:06 +00:00
Philipp Krones
c71062a324
Update Cargo.lock 2023-01-27 21:09:23 +01:00
Philipp Krones
1dd773175a
Merge commit '1480cea393d0cee195e59949eabdfbcf1230f7f9' into clippyup 2023-01-27 21:09:08 +01:00
Michael Goulet
8a0b2156d5 Micro-optimization in consider_assumption 2023-01-27 20:06:12 +00:00
Michael Goulet
0654374750 Add some comments 2023-01-27 20:06:12 +00:00
Michael Goulet
ff2413db1b No need to probe when computing goals 2023-01-27 20:04:59 +00:00
bors
1480cea393 Auto merge of #10242 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2023-01-27 19:31:37 +00:00
Philipp Krones
6f9c70a201
Bump Clippy version -> 0.1.69 2023-01-27 20:27:00 +01:00
Philipp Krones
1f403e9ab9
Bump nightly version -> 2023-01-27 2023-01-27 20:26:48 +01:00
Philipp Krones
2bc2431fd1
Merge remote-tracking branch 'upstream/master' into rustup 2023-01-27 20:26:35 +01:00
Camille GILLOT
400cb9aa41 Separate witness type computation from the generator transform. 2023-01-27 19:00:26 +00:00
Camille GILLOT
e2387ad484 Remember where a type was kept in MIR. 2023-01-27 18:59:32 +00:00
Camille GILLOT
1974b6b68d Introduce GeneratorWitnessMIR. 2023-01-27 18:58:44 +00:00
Camille GILLOT
03618d6afd Always require Drop for generators. 2023-01-27 18:58:23 +00:00
Camille GILLOT
9259da51ed Test the 3 generator handling versions for generator/async tests. 2023-01-27 18:58:13 +00:00
Camille GILLOT
a20078f044 Add drop_tracking_mir option. 2023-01-27 18:57:34 +00:00
Camille GILLOT
cb873b2d93 Separate trait selection from ambiguity reporting. 2023-01-27 18:57:10 +00:00
Camille GILLOT
2870ce01b8 Impl HashStable/Encodable/Decodable for ObligationCause. 2023-01-27 18:56:32 +00:00
Camille GILLOT
caefec955f Do not abort compilation when failing to normalize opaque types. 2023-01-27 18:55:58 +00:00
León Orell Valerian Liehr
80a1536c7a
recover more unbraced const args 2023-01-27 19:26:04 +01:00
Michael Goulet
5bfd90efd1 Use now solver in evaluate_obligation 2023-01-27 17:53:07 +00:00
bors
ef982929c0 Auto merge of #107372 - JohnTitor:rollup-zkl2ges, r=JohnTitor
Rollup of 9 pull requests

Successful merges:

 - #106806 (Replace format flags u32 by enums and bools.)
 - #107194 (Remove dependency on slice_internals feature in rustc_ast)
 - #107234 (Revisit fix_is_ci_llvm_available logic)
 - #107316 (Update snap from `1.0.1` to `1.1.0`)
 - #107321 (solver comments + remove `TyCtxt::evaluate_goal`)
 - #107332 (Fix wording from `rustbuild` to `bootstrap`)
 - #107347 (reduce rightward-drift)
 - #107352 (compiler: Fix E0587 explanation)
 - #107357 (Fix infinite loop in rustdoc get_all_import_attributes function)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-27 17:49:56 +00:00
Michael Woerister
e5995e6168 Don't merge vtables when full debuginfo is enabled. 2023-01-27 15:29:04 +00:00
Yuki Okushi
c64f4c41f7
Rollup merge of #107357 - GuillaumeGomez:fix-infinite-loop-in-rustdoc-get_all_import_attributes, r=notriddle
Fix infinite loop in rustdoc get_all_import_attributes function

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

We'll also need to backport this fix to beta.

r? `@notriddle`
2023-01-28 00:23:16 +09:00
Yuki Okushi
85dc93b4d3
Rollup merge of #107352 - sameo:topic/E0587, r=JohnTitor
compiler: Fix E0587 explanation

We meant to use 8 as the packed argument.

Signed-off-by: Samuel Ortiz <sameo@rivosinc.com>
2023-01-28 00:23:15 +09:00
Yuki Okushi
b247253edd
Rollup merge of #107347 - tshepang:rightward-drift, r=Nilstrieb
reduce rightward-drift
2023-01-28 00:23:15 +09:00
Yuki Okushi
1e0cf727c3
Rollup merge of #107332 - chansuke:issue-107230, r=albertlarsan68
Fix wording from `rustbuild` to `bootstrap`

Fixes #107230
2023-01-28 00:23:14 +09:00