about summary refs log tree commit diff
path: root/compiler/rustc_middle
AgeCommit message (Collapse)AuthorLines
2024-03-01Use FxIndexMap instead FxHashMap to stabilize iteration order in ↵Michael Woerister-5/+4
EffectiveVisibilities. Part of https://github.com/rust-lang/compiler-team/issues/533
2024-03-01Auto merge of #121462 - compiler-errors:eq-and-sub, r=lcnrbors-70/+33
Combine `Sub` and `Equate` Combine `Sub` and `Equate` into a new relation called `TypeRelating` (that name sounds familiar...) Tracks the difference between `Sub` and `Equate` via `ambient_variance: ty::Variance` much like the `NllTypeRelating` relation, but implemented slightly jankier because it's a more general purpose relation. r? lcnr
2024-03-01Auto merge of #121728 - tgross35:f16-f128-step1-ty-updates, r=compiler-errorsbors-1/+11
Add stubs in IR and ABI for `f16` and `f128` This is the very first step toward the changes in https://github.com/rust-lang/rust/pull/114607 and the [`f16` and `f128` RFC](https://rust-lang.github.io/rfcs/3453-f16-and-f128.html). It adds the types to `rustc_type_ir::FloatTy` and `rustc_abi::Primitive`, and just propagates those out as `unimplemented!` stubs where necessary. These types do not parse yet so there is no feature gate, and it should be okay to use `unimplemented!`. The next steps will probably be AST support with parsing and the feature gate. r? `@compiler-errors` cc `@Nilstrieb` suggested breaking the PR up in https://github.com/rust-lang/rust/pull/120645#issuecomment-1925900572
2024-03-01Fallout from removing a_is_expectedMichael Goulet-59/+27
2024-03-01Remove causeMichael Goulet-11/+6
2024-02-29Rollup merge of #121782 - RalfJung:mutable-ref-in-static, r=oli-obkMatthias Krüger-1/+0
allow statics pointing to mutable statics Fixes https://github.com/rust-lang/rust/issues/120450 for good. We can even simplify our checks: no need to specifically go looking for mutable references in const, we can just reject any reference that points to something mutable. r? `@oli-obk`
2024-02-29Rollup merge of #121669 - nnethercote:count-stashed-errs-again, r=estebankGuillaume Gomez-11/+13
Count stashed errors again Stashed diagnostics are such a pain. Their "might be emitted, might not" semantics messes with lots of things. #120828 and #121206 made some big changes to how they work, improving some things, but still leaving some problems, as seen by the issues caused by #121206. This PR aims to fix all of them by restricting them in a way that eliminates the "might be emitted, might not" semantics while still allowing 98% of their benefit. Details in the individual commit logs. r? `@oli-obk`
2024-02-29Rollup merge of #121376 - Nadrieril:mir-half-ranges, r=pnkfelixGuillaume Gomez-16/+2
Skip unnecessary comparison with half-open range patterns This is the last remaining detail in the implementation of half-open range patterns. Until now, a half-open range pattern like `10..` was converted to `10..T::MAX` before lowering to MIR, which generated an extra pointless comparison. With this PR we don't generate it.
2024-02-29distinguish recursion limit based overflow for diagnosticslcnr-10/+20
also change the number of allowed fixpoint steps to be fixed instead of using the `log` of the total recursion depth.
2024-02-29allow statics pointing to mutable staticsRalf Jung-1/+0
2024-02-28Avoid code duplicationVeera-10/+7
2024-02-28Improve error messages for generics with default parametersVeera-0/+27
Fixes #120785
2024-02-29Overhaul how stashed diagnostics work, again.Nicholas Nethercote-15/+13
Stashed errors used to be counted as errors, but could then be cancelled, leading to `ErrorGuaranteed` soundness holes. #120828 changed that, closing the soundness hole. But it introduced other difficulties because you sometimes have to account for pending stashed errors when making decisions about whether errors have occured/will occur and it's easy to overlook these. This commit aims for a middle ground. - Stashed errors (not warnings) are counted immediately as emitted errors, avoiding the possibility of forgetting to consider them. - The ability to cancel (or downgrade) stashed errors is eliminated, by disallowing the use of `steal_diagnostic` with errors, and introducing the more restrictive methods `try_steal_{modify,replace}_and_emit_err` that can be used instead. Other things: - `DiagnosticBuilder::stash` and `DiagCtxt::stash_diagnostic` now both return `Option<ErrorGuaranteed>`, which enables the removal of two `delayed_bug` calls and one `Ty::new_error_with_message` call. This is possible because we store error guarantees in `DiagCtxt::stashed_diagnostics`. - Storing the guarantees also saves us having to maintain a counter. - Calls to the `stashed_err_count` method are no longer necessary alongside calls to `has_errors`, which is a nice simplification, and eliminates two more `span_delayed_bug` calls and one FIXME comment. - Tests are added for three of the four fixed PRs mentioned below. - `issue-121108.rs`'s output improved slightly, omitting a non-useful error message. Fixes #121451. Fixes #121477. Fixes #121504. Fixes #121508.
2024-02-29Don't cancel stashed `OpaqueHiddenTypeMismatch` errors.Nicholas Nethercote-1/+5
This gives one extra error message on one test, but is necessary to fix bigger problems caused by the cancellation of stashed errors. (Note: why not just avoid stashing altogether? Because that resulted in additional output changes.)
2024-02-28Auto merge of #121489 - nnethercote:diag-renaming, r=davidtwcobors-63/+59
Diagnostic renaming Renaming various diagnostic types from `Diagnostic*` to `Diag*`. Part of https://github.com/rust-lang/compiler-team/issues/722. There are more to do but this is enough for one PR. r? `@davidtwco`
2024-02-28Add `f16` and `f128` to `rustc_type_ir::FloatTy` and `rustc_abi::Primitive`Trevor Gross-1/+11
Make changes necessary to support these types in the compiler.
2024-02-28Rollup merge of #121695 - oli-obk:split_ty_utils, r=compiler-errorsGuillaume Gomez-1/+3
Split rustc_type_ir to avoid rustc_ast from depending on it unblocks #121576 and resolves a FIXME in `rustc_ast`'s `Cargo.toml` The new crate is tiny, but it will get bigger in #121576
2024-02-28Rename `DiagnosticArg{,Map,Name,Value}` as `DiagArg{,Map,Name,Value}`.Nicholas Nethercote-37/+37
2024-02-28Rename `DiagnosticBuilder` as `Diag`.Nicholas Nethercote-26/+22
Much better! Note that this involves renaming (and updating the value of) `DIAGNOSTIC_BUILDER` in clippy.
2024-02-28Rename `Diagnostic` as `DiagInner`.Nicholas Nethercote-2/+2
I started by changing it to `DiagData`, but that didn't feel right. `DiagInner` felt much better.
2024-02-27Split rustc_type_ir to avoid rustc_ast from depending on itOli Scherer-1/+3
2024-02-27Print RPITIT like an opaqueMichael Goulet-8/+12
2024-02-27Document invariant in `thir::PatRange`Nadrieril-0/+2
2024-02-27Skip unnecessary comparison with half-open rangesNadrieril-16/+0
2024-02-27Auto merge of #121285 - nnethercote:delayed_bug-audit, r=lcnrbors-13/+24
Delayed bug audit I went through all the calls to `delayed_bug` and `span_delayed_bug` and found a few places where they could be avoided. r? `@compiler-errors`
2024-02-27Avoid `span_delayed_bug` on one path in `AdtDef::eval_explicit_discr`.Nicholas Nethercote-13/+24
Also change its return type to `Result`.
2024-02-26Auto merge of #121516 - RalfJung:platform-intrinsics-begone, r=oli-obkbors-2/+1
remove platform-intrinsics ABI; make SIMD intrinsics be regular intrinsics `@Amanieu` `@workingjubilee` I don't think there is any reason these need to be "special"? The [original RFC](https://rust-lang.github.io/rfcs/1199-simd-infrastructure.html) indicated eventually making them stable, but I think that is no longer the plan, so seems to me like we can clean this up a bit. Blocked on https://github.com/rust-lang/stdarch/pull/1538, https://github.com/rust-lang/rust/pull/121542.
2024-02-26always emit `AliasRelate` goals when relating aliaseslcnr-16/+1
Add `StructurallyRelateAliases` to allow instantiating infer vars with rigid aliases. Change `instantiate_query_response` to be infallible in the new solver. This requires canonicalization to not hide any information used by the query, so weaken universe compression. It also modifies `term_is_fully_unconstrained` to allow region inference variables in a higher universe.
2024-02-25remove platform-intrinsics ABI; make SIMD intrinsics be regular intrinsicsRalf Jung-2/+1
2024-02-24Rollup merge of #121556 - GrigorenkoPV:addr_of, r=NilstriebMatthias Krüger-3/+3
Use `addr_of!` As per https://github.com/rust-lang/rust/pull/121303#discussion_r1500954662
2024-02-24Auto merge of #121523 - matthiaskrgr:comp_comp, r=Nilstriebbors-1/+1
compiler: clippy::complexity fixes
2024-02-24Implement asm goto in MIR and MIR loweringGary Guo-1/+9
2024-02-24Change InlineAsm to allow multiple targets insteadGary Guo-48/+54
2024-02-24Use slice.chain(option) for SuccessorsGary Guo-31/+28
This makes more sense because most cases then second one is unwind target.
2024-02-24Add asm label support to THIRGary Guo-0/+4
2024-02-24compiler: use `addr_of!`Pavel Grigorenko-3/+3
2024-02-23compiler: clippy::complexity fixesMatthias Krüger-1/+1
2024-02-23Rollup merge of #121495 - cuishuang:master, r=clubby789Matthias Krüger-1/+1
remove repetitive words
2024-02-23Rollup merge of #120742 - Nadrieril:use-min_exh_pats, r=compiler-errorsMatthias Krüger-1/+2
mark `min_exhaustive_patterns` as complete This is step 1 and 2 of my [proposal](https://github.com/rust-lang/rust/issues/119612#issuecomment-1918097361) to move `min_exhaustive_patterns` forward. The vast majority of in-tree use cases of `exhaustive_patterns` are covered by `min_exhaustive_patterns`. There are a few cases that still require `exhaustive_patterns` in tests and they're all behind references. r? ``@ghost``
2024-02-23remove repetitive wordscui fliter-1/+1
Signed-off-by: cui fliter <imcusg@gmail.com>
2024-02-23Auto merge of #121442 - lcnr:region-var-universe-uwu, r=compiler-errorsbors-44/+45
region unification: update universe of region vars necessary for #119106. see inline comment for why this is necessary r? `@compiler-errors` `@BoxyUwU`
2024-02-23Auto merge of #120730 - estebank:confusable-api, r=oli-obkbors-1/+1
Provide suggestions through `rustc_confusables` annotations Help with common API confusion, like asking for `push` when the data structure really has `append`. ``` error[E0599]: no method named `size` found for struct `Vec<{integer}>` in the current scope --> $DIR/rustc_confusables_std_cases.rs:17:7 | LL | x.size(); | ^^^^ | help: you might have meant to use `len` | LL | x.len(); | ~~~ help: there is a method with a similar name | LL | x.resize(); | ~~~~~~ ``` Fix #59450 (we can open subsequent tickets for specific cases). Fix #108437: ``` error[E0599]: `Option<{integer}>` is not an iterator --> f101.rs:3:9 | 3 | opt.flat_map(|val| Some(val)); | ^^^^^^^^ `Option<{integer}>` is not an iterator | ::: /home/gh-estebank/rust/library/core/src/option.rs:571:1 | 571 | pub enum Option<T> { | ------------------ doesn't satisfy `Option<{integer}>: Iterator` | = note: the following trait bounds were not satisfied: `Option<{integer}>: Iterator` which is required by `&mut Option<{integer}>: Iterator` help: you might have meant to use `and_then` | 3 | opt.and_then(|val| Some(val)); | ~~~~~~~~ ``` On type error of method call arguments, look at confusables for suggestion. Fix #87212: ``` error[E0308]: mismatched types --> f101.rs:8:18 | 8 | stuff.append(Thing); | ------ ^^^^^ expected `&mut Vec<Thing>`, found `Thing` | | | arguments to this method are incorrect | = note: expected mutable reference `&mut Vec<Thing>` found struct `Thing` note: method defined here --> /home/gh-estebank/rust/library/alloc/src/vec/mod.rs:2025:12 | 2025 | pub fn append(&mut self, other: &mut Self) { | ^^^^^^ help: you might have meant to use `push` | 8 | stuff.push(Thing); | ~~~~ ```
2024-02-22drive-by fmt cleanupEsteban Küber-1/+1
2024-02-22add commentlcnr-1/+8
2024-02-22region unification update universe of region varslcnr-44/+38
2024-02-22Rollup merge of #121441 - lcnr:typesystem-cleanup, r=compiler-errorsMatthias Krüger-2/+3
`DefId` to `LocalDefId`
2024-02-22Rollup merge of #121386 - oli-obk:no_higher_ranked_opaques, r=lcnrMatthias Krüger-4/+5
test that we do not support higher-ranked regions in opaque type inference We already do all the right checks in `check_opaque_type_parameter_valid`, and we have done so since at least 2 years. I collected the tests from https://github.com/rust-lang/rust/pull/116935 and https://github.com/rust-lang/rust/pull/100503 and added some more cc https://github.com/rust-lang/rust/issues/96146 r? `@lcnr`
2024-02-22`report_mismatch` did not actually report anymoreOli Scherer-1/+1
2024-02-22Avoid emitting type mismatches against `{type error}`Oli Scherer-3/+4
2024-02-22`DefId` to `LocalDefId`lcnr-2/+3