about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2025-07-13Auto merge of #140717 - mejrs:diagnostic_lints, r=oli-obkbors-11/+13
Split up the `unknown_or_malformed_diagnostic_attributes` lint This splits up the lint into the following lint group: - `unknown_diagnostic_attributes` - triggers if the attribute is unknown to the current compiler - `misplaced_diagnostic_attributes` - triggers if the attribute exists but it is not placed on the item kind it's meant for - `malformed_diagnostic_attributes` - triggers if the attribute's syntax or options are invalid - `malformed_diagnostic_format_literals` - triggers if the format string literal is invalid, for example if it has unpaired curly braces or invalid parameters - this pr doesn't create it, but future lints for things like deprecations can also go here. This PR does not start emitting lints in places that previously did not. ## Motivation I want to have finer control over what `unknown_or_malformed_diagnostic_attributes` does I have a project with fairly low msrv that is/will have a lower msrv than future diagnostic attributes. So lints will be emitted when I or others compile it on a lower msrv. At this time, there are two options to silence these lints: - `#[allow(unknown_or_malformed_diagnostic_attributes)]` - this risks diagnostic regressions if I (or others) mess up using the attribute, or if the attribute's syntax ever changes. - write a build script to detect the compiler version and emit cfgs, and then conditionally enable the attribute: ```rust #[cfg_attr(rust_version_99, diagnostic::new_attr_in_rust_99(thing = ..))]` struct Foo; ``` or conditionally `allow` the lint: ```rust // lib.rs #![cfg_attr(not(current_rust), allow(unknown_or_malformed_diagnostic_attributes))] ``` I like to avoid using build scripts if I can, so the following works much better for me. That is what this PR will let me do in the future: ```rust #[allow(unknown_diagnostic_attribute, reason = "attribute came out in rust 1.99 but msrv is 1.70")] #[diagnostic::new_attr_in_rust_99(thing = ..)]` struct Foo;
2025-07-11Auto merge of #142911 - mejrs:unsized, r=compiler-errorsbors-0/+6
Remove support for dynamic allocas Followup to rust-lang/rust#141811
2025-07-10Rollup merge of #143742 - estebank:borrow-suggestion, r=compiler-errorsTrevor Gross-103/+125
Rework borrowing suggestions to use `Expr` instead of just `Span` In the suggestion machinery for borrowing expressions and types, always use the available obligation `Span` to find the appropriate `Expr` to perform appropriateness checks no the `ExprKind` instead of on the textual snippet corresponding to the `Span`. (We were already doing this, but only for a subset of cases.) This now better handles situations where parentheses and `<>` are needed for correct syntax (`&(foo + bar)`, `(&foo).bar()`, `<&Foo>::bar()`, etc.). Unify the logic for the case where `&` *and* `&mut` are appropriate with the logic for only one of those cases. (Instead of having two branches for emitting the suggestion, we now have a single one, using `Diag::multipart_suggestions` always.) Handle the case when `S::foo()` should have been `<&S>::foo()` (instead of suggesting the prior `&S::foo()`. Fix rust-lang/rust#143393. Make `Diag::multipart_suggestions` always verbose. CC rust-lang/rust#141973.
2025-07-11Split up the `unknown_or_malformed_diagnostic_attributes` lintmejrs-11/+13
2025-07-10Rollup merge of #143640 - oli-obk:const-fn-traits, r=compiler-errorsMatthias Krüger-1/+50
Constify `Fn*` traits r? `@compiler-errors` `@fee1-dead` this should unlock a few things. A few `const_closures` tests have broken even more than before, but that feature is marked as incomplete anyway cc rust-lang/rust#67792
2025-07-10Rework borrowing suggestions to use `Expr` instead of just `Span`Esteban Küber-103/+125
In the suggestion machinery for borrowing expressions and types, always use the available obligation `Span` to find the appropriate `Expr` to perform appropriateness checks no the `ExprKind` instead of on the textual snippet corresponding to the `Span`. Unify the logic for the case where `&` *and* `&mut` are appropriate with the logic for only one of those cases. Handle the case when `S::foo()` should have been `<&S>::foo()` (instead of suggesting the prior `&S::foo()`.
2025-07-09Auto merge of #143538 - compiler-errors:instantiate-auto-trait, r=lcnrbors-212/+245
Instantiate auto trait/`Copy`/`Clone`/`Sized` before computing constituent types binder This makes the binder logic w.r.t. coroutines a bit simpler. r? lcnr
2025-07-08Rollup merge of #143532 - compiler-errors:mut-ref-sugg, r=davidtwcoTrevor Gross-5/+8
More carefully consider span context when suggesting remove `&mut` Use `find_ancestor_inside` to compute a relative span that is macro-aware, rather than falling back to using BytePos arithmetic which is wrong for `&mut`. Fixes https://github.com/rust-lang/rust/issues/143523
2025-07-08Rollup merge of #143499 - compiler-errors:predicates-of-crate, r=davidtwcoTrevor Gross-13/+20
Don't call `predicates_of` on a dummy obligation cause's body id See the test for a brief explanation Fixes rust-lang/rust#143481.
2025-07-08Error on moving unsized values rather than ICE'ingmejrs-0/+6
2025-07-08Rollup merge of #143620 - Muscraft:remove-newline, r=compiler-errorsMatthias Krüger-1/+1
fix: Remove newline from multiple crate versions note While working on getting `annotate-snippets` to match `rustc`, `annotate-snippets` was adding an extra new line after [this line](https://github.com/rust-lang/rust/blob/a2d45f73c70d9dec57140c9412f83586eda895f8/tests/run-make/crate-loading/multiple-dep-versions.stderr#L9) for [`run-make/crate-loading/multiple-dep-versions.rs`](https://github.com/rust-lang/rust/blob/a2d45f73c70d9dec57140c9412f83586eda895f8/tests/run-make/crate-loading/multiple-dep-versions.rs). I found out this was because there was an explicit `\n` in the message that `annotate-snippets` was respecting, while `rustc` was [skipping it](https://github.com/rust-lang/rust/blob/2f8eeb2bba86b8f457ec602c578473c711f85628/compiler/rustc_errors/src/emitter.rs#L1542). After talking with ```@estebank,``` I was told to remove the newline from the error message. r? ```@estebank```
2025-07-08Instantiate binder for Copy/Clone/Sized eagerlyMichael Goulet-196/+222
2025-07-08Instantiate auto trait before computing higher-ranked constituent typesMichael Goulet-16/+23
2025-07-08Remove `const_eval_select` hackOli Scherer-5/+2
2025-07-08Constify `Fn*` traitsOli Scherer-1/+53
2025-07-08Rollup merge of #143571 - lcnr:has_nested-bb, r=compiler-errorsMatthias Krüger-59/+52
remove `has_nested` from builtin candidates it's no longer necessary r? types
2025-07-07fix: Remove newline from multiple crate versions noteScott Schafer-1/+1
2025-07-07Rollup merge of #132469 - estebank:issue-132041, r=NadrierilMatthias Krüger-7/+77
Do not suggest borrow that is already there in fully-qualified call When encountering `&str::from("value")` do not suggest `&&str::from("value")`. Fix #132041.
2025-07-07remove `has_nested`lcnr-59/+52
2025-07-06compiler: rename {ast,hir}::BareFn* to FnPtr*Jubilee Young-1/+1
Fix some comments and related types and locals where it is obvious, e.g. - bare_fn -> fn_ptr - LifetimeBinderKind::BareFnType -> LifetimeBinderKind::FnPtrType Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
2025-07-06More carefully consider span context when suggesting remove &mutMichael Goulet-5/+8
2025-07-05Don't call predicates_of on a dummy obligation cause's body idMichael Goulet-13/+20
2025-07-05Use relative visibility when noting sealed trait to reduce false positivexizheyin-5/+15
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-04NitsMichael Goulet-12/+10
2025-07-04Fix elided lifetimes in rustdocMichael Goulet-2/+2
2025-07-04Fix pretty printing of placeholder typesMichael Goulet-6/+6
2025-07-04Remove Symbol for Named LateParam/Bound variantsMichael Goulet-49/+55
2025-07-04Rollup merge of #143308 - compiler-errors:no-pointer-like, r=oli-obkMatthias Krüger-78/+1
Remove `PointerLike` trait r? oli-obk
2025-07-04Rollup merge of #143307 - compiler-errors:fast-path-nitpicks, r=lcnrJacob Pratt-15/+6
Fast path nitpicks Miscellaneous commits that I didn't really want to fold into anything else. Fixes one theoretical bug with the fast path not considering polarity for `T: !Sized` bounds.
2025-07-03Remove PointerLike traitMichael Goulet-78/+1
2025-07-03Rework logic and provide structured suggestionEsteban Küber-10/+71
2025-07-03Rollup merge of #143038 - Qelxiros:142676-private-dependency-traits, r=tgross35Jana Dönszelmann-1/+1
avoid suggesting traits from private dependencies fixes rust-lang/rust#142676 fixes rust-lang/rust#138191 r? ``@tgross35``
2025-07-03Rollup merge of #142876 - JonathanBrouwer:target_feature_parser, r=oli-obkJana Dönszelmann-3/+3
Port `#[target_feature]` to new attribute parsing infrastructure Ports `target_feature` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971353197 r? ``@jdonszelmann``
2025-07-03Rollup merge of #134006 - klensy:typos, r=nnethercoteJana Dönszelmann-7/+7
setup typos check in CI This allows to check typos in CI, currently for compiler only (to reduce commit size with fixes). With current setup, exclude list is quite short, so it worth trying? Also includes commits with actual typo fixes. MCP: https://github.com/rust-lang/compiler-team/issues/817 typos check currently turned for: * ./compiler * ./library * ./src/bootstrap * ./src/librustdoc After merging, PRs which enables checks for other crates (tools) can be implemented too. Found typos will **not break** other jobs immediately: (tests, building compiler for perf run). Job will be marked as red on completion in ~ 20 secs, so you will not forget to fix it whenever you want, before merging pr. Check typos: `python x.py test tidy --extra-checks=spellcheck` Apply typo fixes: `python x.py test tidy --extra-checks=spellcheck:fix` (in case if there only 1 suggestion of each typo) Current fail in this pr is expected and shows how typo errors emitted. Commit with error will be removed after r+.
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-7/+7
2025-07-03Port `#[target_feature]` to the new attribute parsing infrastructureJonathan Brouwer-3/+3
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-02avoid suggesting traits from private dependenciesJeremy Smart-1/+1
2025-07-02Rollup merge of #143235 - compiler-errors:const-item-bound, r=oli-obkMatthias Krüger-1/+66
Assemble const bounds via normal item bounds in old solver too Fixes the first example in https://rust-lang.zulipchat.com/#narrow/channel/144729-t-types/topic/elaboration.20of.20const.20bounds.3F/with/526378135 The code duplication here is not that nice, but it's at least very localized. cc `@davidtwco` r? oli-obk
2025-07-02Consider polarity in sizedness fast pathMichael Goulet-3/+4
2025-07-02Use is_trivially_wf for ProvePredicate fast pathMichael Goulet-12/+2
2025-07-01Do not suggest borrow that is already there in fully-qualified callEsteban Küber-0/+9
When encountering `&str::from("value")` do not suggest `&&str::from("value")`. Fix #132041.
2025-07-01Remove support for dyn*Michael Goulet-21/+0
2025-06-30Assemble const bounds via normal item bounds in old solver tooMichael Goulet-1/+66
2025-06-30Make check_param_wf only go through the HIR in the error pathOli Scherer-1/+6
2025-06-27Rollup merge of #139858 - oli-obk:new-const-traits-syntax, r=fee1-deadMatthias Krüger-12/+12
New const traits syntax This PR only affects the AST and doesn't actually change anything semantically. All occurrences of `~const` outside of libcore have been replaced by `[const]`. Within libcore we have to wait for rustfmt to be bumped in the bootstrap compiler. This will happen "automatically" (when rustfmt is run) during the bootstrap bump, as rustfmt converts `~const` into `[const]`. After this we can remove the `~const` support from the parser Caveat discovered during impl: there is no legacy bare trait object recovery for `[const] Trait` as that snippet in type position goes down the slice /array parsing code and will error r? ``@fee1-dead`` cc ``@nikomatsakis`` ``@traviscross`` ``@compiler-errors``
2025-06-27Auto merge of #142223 - compiler-errors:perf-wf, r=lcnrbors-2/+20
Fast path for WF goals in new solver Hopefully self-explanatory.
2025-06-27Auto merge of #143074 - compiler-errors:rollup-cv64hdh, r=compiler-errorsbors-118/+155
Rollup of 18 pull requests Successful merges: - rust-lang/rust#137843 (make RefCell unstably const) - rust-lang/rust#140942 (const-eval: allow constants to refer to mutable/external memory, but reject such constants as patterns) - rust-lang/rust#142549 (small iter.intersperse.fold() optimization) - rust-lang/rust#142637 (Remove some glob imports from the type system) - rust-lang/rust#142647 ([perf] Compute hard errors without diagnostics in impl_intersection_has_impossible_obligation) - rust-lang/rust#142700 (Remove incorrect comments in `Weak`) - rust-lang/rust#142927 (Add note to `find_const_ty_from_env`) - rust-lang/rust#142967 (Fix RwLock::try_write documentation for WouldBlock condition) - rust-lang/rust#142986 (Port `#[export_name]` to the new attribute parsing infrastructure) - rust-lang/rust#143001 (Rename run always ) - rust-lang/rust#143010 (Update `browser-ui-test` version to `0.20.7`) - rust-lang/rust#143015 (Add `sym::macro_pin` diagnostic item for `core::pin::pin!()`) - rust-lang/rust#143033 (Expand const-stabilized API links in relnotes) - rust-lang/rust#143041 (Remove cache for citool) - rust-lang/rust#143056 (Move an ACE test out of the GCI directory) - rust-lang/rust#143059 (Fix 1.88 relnotes) - rust-lang/rust#143067 (Tracking issue number for `iter_macro`) - rust-lang/rust#143073 (Fix some fixmes that were waiting for let chains) Failed merges: - rust-lang/rust#143020 (codegen_fn_attrs: make comment more precise) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-26Rollup merge of #142927 - compiler-errors:note-find-const, r=BoxyUwUMichael Goulet-3/+5
Add note to `find_const_ty_from_env` Add a note to `find_const_ty_from_env` to explain why it has an `unwrap` which "often" causes ICEs. Also, uplift it into the new trait solver. This avoids needing to go through the interner to call this method which is otherwise an inherent method in the compiler. I can remove this part if desired. r? `@boxyuwu`
2025-06-26Rollup merge of #142647 - compiler-errors:less-work-in-coherence, r=lcnrMichael Goulet-17/+26
[perf] Compute hard errors without diagnostics in impl_intersection_has_impossible_obligation First compute hard errors without diagnostics, then ambiguities with diagnostics since we need to know if any of them overflowed.
2025-06-26Rollup merge of #142637 - compiler-errors:less-globs, r=lcnrMichael Goulet-96/+120
Remove some glob imports from the type system Namely, remove the glob imports for `BoundRegionConversionTime`, `RegionVariableOrigin`, `SubregionOrigin`, `TyOrConstInferVar`, `RegionResolutionError`, `SelectionError`, `ProjectionCandidate`, `ProjectionCandidateSet`, and some more specific scoped globs (like `Inserted` in the impl overlap graph construction. These glob imports are IMO very low value, since they're not used nearly as often as other globs (like `TyKind`).