about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src
AgeCommit message (Collapse)AuthorLines
2025-03-08Rework maybe_suggest_add_generic_impl_traitMichael Goulet-24/+71
2025-03-07Rollup merge of #138173 - compiler-errors:incoherent-negative-impl, r=oli-obkJacob Pratt-1/+4
Delay bug for negative auto trait rather than ICEing Fixes #138149 r? oli-obk
2025-03-08Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
(Except for `rustc_codegen_cranelift`.) It's no longer necessary now that `unreachable_pub` is in the workspace lints.
2025-03-07Rollup merge of #138042 - xizheyin:issue-135759, r=nnethercoteMatthias Krüger-2/+61
Suggest struct or union to add generic that impls trait Fixes #135759 cc ```@tdittr```
2025-03-07Delay bug for negative auto trait rather than ICEingMichael Goulet-1/+4
2025-03-07Pass `Option<Symbol>` to `def_path_data`/`create_def` methods.Nicholas Nethercote-1/+2
It's clearer than using `kw::Empty` to mean `None`.
2025-03-07Increase recursion_limit in numerous crates.Nicholas Nethercote-0/+1
This is temporarily needed for `x doc compiler` to work. They can be removed once the `Nonterminal` is removed (#124141).
2025-03-06Rollup merge of #137808 - jswrenn:droppy-unsafe-fields, r=nnethercoteMichael Goulet-55/+0
Do not require that unsafe fields lack drop glue Instead, we adopt the position that introducing an `unsafe` field itself carries a safety invariant: that if you assign an invariant to that field weaker than what the field's destructor requires, you must ensure that field is in a droppable state in your destructor. See: - https://github.com/rust-lang/rfcs/pull/3458#discussion_r1971676100 - https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/unsafe.20fields.20RFC/near/502113897 Tracking Issue: #132922
2025-03-06Rollup merge of #137764 - compiler-errors:always-applicable-negative-impl, ↵Michael Goulet-53/+130
r=lcnr Ensure that negative auto impls are always applicable r? lcnr (or reassign if you dont want to review) https://github.com/rust-lang/rust/issues/68318#issuecomment-2689265030
2025-03-06Rollup merge of #137565 - compiler-errors:macro-ex, r=estebankMichael Goulet-0/+5
Try to point of macro expansion from resolver and method errors if it involves macro var In the case that a macro caller passes an identifier into a macro generating a path or method expression, point out that identifier in the context of the *macro* so it's a bit more clear how the macro is involved in causing the error. r? ``````````@estebank`````````` or reassign
2025-03-06Remove the `Option` part of range ends in the HIROli Scherer-95/+13
2025-03-06Avoid having to handle an `Option` in the type systemOli Scherer-17/+80
2025-03-06Prefer a two value enum over boolOli Scherer-5/+0
2025-03-05Rollup merge of #137633 - ↵许杰友 Jieyou Xu (Joe)-48/+18
compiler-errors:no-implied-bounds-hack-unless-bevy, r=lcnr Only use implied bounds hack if bevy, and use deeply normalize in implied bounds hack Consolidates the implied bounds computation mode into a single function, which deeply normalizes, and if it's in **compat** mode (for bevy), it extracts outlives bounds from the infcx. Previously, we were using the implied bounds compat mode in two cases: 1. During WF, if it detects `ParamSet` 2. EVERYWHERE ELSE (lol) -- e.g. borrowck, predicate entailment, etc. While I think this is fine, and the net effect was just that we emitted fewer diagnostics, it makes me uncomfortable that all crates were using the supposed "compat" code. Fixes #137767
2025-03-05Rollup merge of #137298 - compiler-errors:mir-wf, r=lcnr许杰友 Jieyou Xu (Joe)-16/+19
Check signature WF when lowering MIR body Alternative to #137233. https://github.com/rust-lang/rust/pull/137233#issuecomment-2667879143 Fixes https://github.com/rust-lang/rust/issues/137186 We do this check in `mir_drops_elaborated_and_const_checked` and not during `mir_promoted` because that may result in borrowck cycles if WF requires looking into an opaque hidden type. This causes some TAIT tests to fail unnecessarily. r? lcnr try-job: test-various
2025-03-05Suggest struct or union to add generic that impls traitxizheyin-2/+61
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-03-04Rollup merge of #137913 - compiler-errors:struct-field-default-generic, ↵Jubilee-0/+2
r=BoxyUwU Allow struct field default values to reference struct's generics Right now, the default field value feature (https://github.com/rust-lang/rust/issues/132162) lowers anon consts whose types may reference ADT params that the const doesn't inherit. This PR fixes this, so that these defaults can reference ADTs' generics, and sets the `generics_of` parenting up correctly. There doesn't seem to be a good reason not to support this, since the anon const has a well-defined type from the field, and the anon const doesn't interact with the type system like generic parameter defaults do. r? `````@boxyuwu````` or reassign I could also make this into an error if this seems problematic (https://github.com/rust-lang/rust/compare/master...compiler-errors:rust:default-field-value-implicit-param?expand=1)...... but I'd rather make this work and register an open question on the tracking issue about validating that this is well-vetted. Fixes #137896
2025-03-04Only use implied bounds hack if bevy, and use deeply normalize in implied ↵Michael Goulet-48/+18
bounds hack
2025-03-04Make rustdoc tests use always applicable negative auto implsMichael Goulet-2/+2
2025-03-04Ensure that negative auto impls are always applicableMichael Goulet-52/+129
2025-03-04mgca: Lower all const paths as `ConstArgKind::Path`Noah Lev-95/+302
When `#![feature(min_generic_const_args)]` is enabled, we now lower all const paths in generic arg position to `hir::ConstArgKind::Path`. We then lower assoc const paths to `ty::ConstKind::Unevaluated` since we can no longer use the anon const expression lowering machinery. In the process of implementing this, I factored out `hir_ty_lowering` code that is now shared between lowering assoc types and assoc consts. This PR also introduces a `#[type_const]` attribute for trait assoc consts that are allowed as const args. However, we still need to implement code to check that assoc const definitions satisfy `#[type_const]` if present (basically is it a const path or a monomorphic anon const).
2025-03-04Allow struct field default values to reference struct's genericsMichael Goulet-0/+2
2025-03-04Also note struct access, and fix macro expansion from foreign cratesMichael Goulet-1/+1
2025-03-03Fix associated type errors tooMichael Goulet-0/+5
2025-03-03Don't typeck during WF, instead check outside of WF in check_crateMichael Goulet-12/+7
2025-03-03Check signature WF when lowering MIR bodyMichael Goulet-1/+1
2025-03-03Tweak error code for sized checks of const/staticMichael Goulet-3/+11
2025-03-02update outdated doc with new exampleMu001999-2/+2
2025-03-01Rollup merge of #137837 - fee1-dead-contrib:push-pvqvwuvrnwsy, r=compiler-errorsMatthias Krüger-7/+3
Update `const_conditions` and `explicit_implied_const_bounds` docs Move documentation to query definitions, and add docs to `explicit_implied_const_bounds`. r? project-const-traits
2025-03-01Rollup merge of #137617 - BoxyUwU:generic_const_parameter_types, r=lcnrMatthias Krüger-21/+64
Introduce `feature(generic_const_parameter_types)` Allows to define const generic parameters whose type depends on other generic parameters, e.g. `Foo<const N: usize, const ARR: [u8; N]>;` Wasn't going to implement for this for a while until we could implement it with `bad_inference.rs` resolved but apparently the project simd folks would like to be able to use this for some intrinsics and the inference issue isn't really a huge problem there aiui. (cc ``@workingjubilee`` )
2025-03-01Update `const_conditions` and `explicit_implied_const_bounds` docsDeadbeef-7/+3
Move documentation to query definitions, and add docs to `explicit_implied_const_bounds`.
2025-03-01Rollup merge of #137686 - nbdd0121:asm_const, r=compiler-errorsMatthias Krüger-53/+26
Handle asm const similar to inline const Previously, asm consts are handled similar to anon consts rather than inline consts. Anon consts are not good at dealing with lifetimes, because `type_of` has lifetimes erased already. Inline consts can deal with lifetimes because they live in an outer typeck context. And since `global_asm!` lacks an outer typeck context, we have implemented asm consts with anon consts while they're in fact more similar to inline consts. This was changed in #137180, and this means that handling asm consts as inline consts are possible. While as `@compiler-errors` pointed out, `const` currently can't be used with any types with lifetime, this is about to change if #128464 is implemented. This PR is a preparatory PR for that feature. As an unintentional side effect, fix #117877. cc `@Amanieu` r? `@compiler-errors`
2025-02-28Introduce `feature(generic_const_parameter_types)`Boxy-21/+64
2025-02-28Do not require that unsafe fields lack drop glueJack Wrenn-55/+0
Instead, we adopt the position that introducing an `unsafe` field itself carries a safety invariant: that if you assign an invariant to that field weaker than what the field's destructor requires, you must ensure that field is in a droppable state in your destructor. See: - https://github.com/rust-lang/rfcs/pull/3458#discussion_r1971676100 - https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/unsafe.20fields.20RFC/near/502113897
2025-02-26Handle asm const similar to inline constGary Guo-53/+26
2025-02-26Rollup merge of #137631 - TaKO8Ki:issue-137508, r=compiler-errorsLeón Orell Valerian Liehr-1/+5
Avoid collecting associated types for undefined trait Fixes #137508 Fixes #137554
2025-02-26Rollup merge of #137613 - davidtwco:const-traits-variances, r=compiler-errorsLeón Orell Valerian Liehr-0/+4
hir_analysis: skip self type of host effect preds in variances_of Discovered as part of an implementation of rust-lang/rfcs#3729 - w/out this then when introducing const trait bounds: many more interesting tests change with different output, missing errors, new errors, etc related to this but they all depend on feature flags and are much more complex than this test. r? ``@oli-obk``
2025-02-26Rollup merge of #137529 - klensy:unused3, r=lcnrLeón Orell Valerian Liehr-1/+0
remove few unused args
2025-02-26fix #137508Takayuki Maeda-1/+5
rename ui tests check if res is trait def fix typo regression test for #137554
2025-02-25Auto merge of #137608 - fmease:rollup-h4siso6, r=fmeasebors-2/+0
Rollup of 8 pull requests Successful merges: - #137370 (adjust_abi: make fallback logic for ABIs a bit easier to read) - #137444 (Improve behavior of `IF_LET_RESCOPE` around temporaries and place expressions) - #137464 (Fix invalid suggestion from type error for derive macro) - #137539 ( Add rustdoc-gui regression test for #137082 ) - #137576 (Don't doc-comment BTreeMap<K, SetValZST, A>) - #137595 (remove `simd_fpow` and `simd_fpowi`) - #137600 (type_ir: remove redundant part of comment) - #137602 (feature: fix typo in attribute description) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-25Rollup merge of #137595 - folkertdev:remove-simd-pow-powi, r=RalfJungLeón Orell Valerian Liehr-2/+0
remove `simd_fpow` and `simd_fpowi` Discussed in https://github.com/rust-lang/rust/issues/137555 These functions are not exposed from `std::intrinsics::simd`, and not used anywhere outside of the compiler. They also don't lower to particularly good code at least on the major ISAs (I checked x86_64, aarch64, s390x, powerpc), where the vector is just spilled to the stack and scalar functions are used for the actual logic. r? `@RalfJung`
2025-02-25remove unused field from VariantDef::new and convert debug to instrumentklensy-1/+0
2025-02-25remove `simd_fpow` and `simd_fpowi`Folkert de Vries-2/+0
2025-02-25Don't require method impls for methods with `Self:Sized` bounds for impls ↵Oli Scherer-1/+44
for unsized types
2025-02-25Auto merge of #137573 - compiler-errors:rollup-noq9yhp, r=compiler-errorsbors-139/+134
Rollup of 11 pull requests Successful merges: - #136522 (Remove `feature(dyn_compatible_for_dispatch)` from the compiler) - #137289 (Consolidate and improve error messaging for `CoerceUnsized` and `DispatchFromDyn`) - #137321 (Correct doc about `temp_dir()` behavior on Android) - #137417 (rustc_target: Add more RISC-V atomic-related features) - #137489 (remove `#[rustc_intrinsic_must_be_overridde]`) - #137530 (DWARF mixed versions with LTO on MIPS) - #137543 (std: Fix another new symlink test on Windows) - #137548 (Pass correct `TypingEnv` to `InlineAsmCtxt`) - #137550 (Don't immediately panic if dropck fails without returning errors) - #137552 (Update books) - #137556 (rename simd_shuffle_generic → simd_shuffle_const_generic) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-24Rollup merge of #137556 - RalfJung:simd_shuffle_const_generic, r=oli-obkMichael Goulet-1/+1
rename simd_shuffle_generic → simd_shuffle_const_generic I've been confused by this name one time too often. ;) r? `@oli-obk`
2025-02-24Rollup merge of #137548 - compiler-errors:asm-ty, r=oli-obkMichael Goulet-5/+20
Pass correct `TypingEnv` to `InlineAsmCtxt` Fixes #137512 r? oli-obk
2025-02-24Rollup merge of #137289 - compiler-errors:coerce-unsized-errors, r=oli-obkMichael Goulet-128/+112
Consolidate and improve error messaging for `CoerceUnsized` and `DispatchFromDyn` Firstly, this PR consolidates and reworks the error diagnostics for `CoercePointee` and `DispatchFromDyn`. There was a ton of duplication for no reason -- this reworks both the errors and also the error codes, since they can be shared between both traits since they report the same thing. Secondly, when encountering a struct with multiple fields that must be coerced, point out the field spans, rather than mentioning the fields by name. This makes the error message clearer, but also means that we don't mention the `__S` dummy parameter for `derive(CoercePointee)`. Thirdly, emit a custom error message when we encounter a trait error that comes from the recursive field `CoerceUnsized`/`DispatchFromDyn` trait check. **Note:** This is the only one I'm not too satisfied with -- I think it could use some more refinement, but ideally it explains that the field must be an unsize-able pointer... Feedback welcome. Finally, don't emit `DispatchFromDyn` validity errors if we detect `CoerceUnsized` validity errors from an impl of the same ADT. This is best reviewed per commit. r? `@oli-obk` perhaps? cc `@dingxiangfei2009` -- sorry for making my own attempt at this PR, but I wanted to see if I could implement a fix for #136796 in a less complicated way, since communicating over github review comments can be a bit slow. I'll leave comments inline to explain my thinking about the diagnostics changes.
2025-02-24Deduplicate CoerceUnsized and DispatchFromDyn impl errorsMichael Goulet-3/+13
2025-02-24Simplify trait error message for CoercePointee validationMichael Goulet-47/+81