And likewise for the `Const::val` method.
Because its type is called `ConstKind`. Also `val` is a confusing name
because `ConstKind` is an enum with seven variants, one of which is
called `Value`. Also, this gives consistency with `TyS` and `PredicateS`
which have `kind` fields.
The commit also renames a few `Const` variables from `val` to `c`, to
avoid confusion with the `ConstKind::Value` variant.
Remove unnecessary `to_string` and `String::new`
73fa217bc1 changed the type of the `suggestion` argument to `impl ToString`. This patch removes unnecessary `to_string` and `String::new`.
cc: `````@davidtwco`````
Make `type_changing_struct_update` no longer an incomplete feature
After #97705, I don't see what would make it incomplete anymore. `check_expr_struct_fields` seems to now implement the RFC to the letter.
r? ``````@nikomatsakis``````
cc ``````@rust-lang/types``````
interpret: unify offset_from check with offset check
`offset` does the check with a single `check_ptr_access` call while `offset_from` used two calls. Make them both just one one call.
I originally intended to actually factor this into a common function, but I am no longer sure if that makes a lot of sense... the two functions start with pretty different precondition (e.g. `offset` *knows* that the 2nd pointer has the same provenance).
I also reworded the UB messages a little. Saying it "cannot" do something is not how we usually phrase UB (as far as I know). Instead it's not *allowed* to do that.
r? ``````@oli-obk``````
Use safer `strip=symbols`-flag for dylibs on macOS
Closes#93988
To safely strip dylibs on macOS, the `-x` flag is needed per the manpage (see the discussion here: https://github.com/rust-lang/rust/issues/93988#issuecomment-1042574854).
Thus, when the current `crate_type` is producing a dylib (I assume this is the case for proc macros) use the `-x` flag instead of bare `strip` for `strip=symbols`.
Tidy up miscellaneous bounds suggestions
Just some small fixes to suggestions
- Generalizes `Ty::is_suggestable` into a `TypeVisitor`, so that it can be called on things other than `Ty`
- Makes `impl Trait` in arg position no longer suggestible (generalizing the fix in #97640)
- Fixes `impl Trait` not being replaced with fresh type param when it's deeply nested in function signature (fixes#97760)
- Fixes some poor handling of `where` clauses with no predicates (also #97760)
- Uses `InferCtxt::resolve_numeric_literals_with_default` so we suggest `i32` instead of `{integer}` (fixes#97677)
Sorry there aren't many tests the fixes. Most of them would just be duplicates of other tests with empty `where` clauses or `impl Trait` in arg position instead of generic params. Let me know if you'd want more test coverage.
Fix inference issues with unconstrained base expr in `type_changing_struct_update`
Use fresh infer vars to guide inference along in `type_changing_struct_update`.
Fixes#96878
Handle `def_ident_span` like `def_span`.
`def_ident_span` had an ad-hoc status in the compiler.
This PR refactors it to be a first-class citizen like `def_span`:
- it gets encoded in the main metadata loop, instead of the visitor;
- its implementation is updated to mirror the one of `def_span`.
We do not remove the `Option` in the return type, since some items do not have an ident, AnonConsts for instance.
Make -Cpasses= only apply to pre-link optimization
This change causes passes specified in -Cpasses= to be applied
only during pre-link optimization, not during LTO. This avoids
such passes running multiple times, which they may not be
designed for.
Fixes https://github.com/rust-lang/rust/issues/97713
Rollup of 5 pull requests
Successful merges:
- #97761 (validating the vtable can lead to Stacked Borrows errors)
- #97789 (Fix#71363's test by adding `-Z translate-remapped-path-to-local-path=no`)
- #97913 (Wrap `HirId`s of locals into `LocalVarId`s for THIR nodes)
- #97979 (Fix typos in Provider API docs)
- #97987 (remove an unnecessary `String`)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Wrap `HirId`s of locals into `LocalVarId`s for THIR nodes
This is the first effort to decouple `HirId`s from THIR. `HirId` is not very relevant in building THIR and MIR.
Based on the changeset, I think there are a few other pending refactoring that we could perform after this, in case we want to eliminate use of `HirId` in THIR.
- `TypeckResults::closure_min_captures` could be remapped from the variable `HirId`s to `LocalVarId` while the THIR is getting built.
- Use of `ScopeTree::var_scope` could be eliminated as well, since we will consider deprecating `ScopeTree` in the future.
Fix#71363's test by adding `-Z translate-remapped-path-to-local-path=no`
The test relies on `library/std/src/error.rs` not corresponding to a local path, but remapping might still find the related local file of a remapped path. To fix the test, this PR adds a new `-Z` flag to disable finding the corresponding local path of a remapped path.
Never regard macro rules with compile_error! invocations as unused
The very point of compile_error! is to never be reached, and one of
the use cases of the macro, currently also listed as examples in the
documentation of compile_error, is to create nicer errors for wrong
macro invocations. Thus, we should never warn about unused macro arms
that contain invocations of compile_error.
See also https://github.com/rust-lang/rust/pull/96150#issuecomment-1126599107 and the discussion after that.
Furthermore, the PR also contains two commits to silence `unused_macro_rules` when a macro has an invalid rule, and to add a test that `unused_macros` does not behave badly in the same situation.
r? `@petrochenkov` as I've talked to them about this
Mention `infer::Trace` methods on `infer::At` methods' docs
I missed that you could do `infcx.at(...).trace(...).eq(a, b)` when `a` and `b` dont implement `ToTrace` but does implement `Relate` these docs would have helped see that 😅