-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Ty::primitive_symbol
recognize str
#132799
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rustbot
added
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Nov 9, 2024
compiler-errors
approved these changes
Nov 9, 2024
@bors r+ rollup |
bors
added
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
Nov 9, 2024
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Nov 9, 2024
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#132341 (Reject raw lifetime followed by `'`, like regular lifetimes do) - rust-lang#132363 (Enforce that raw lifetimes must be valid raw identifiers) - rust-lang#132744 (add regression test for rust-lang#90781) - rust-lang#132754 (Simplify the internal API for declaring command-line options) - rust-lang#132772 (use `download-rustc="if-unchanged"` as a global default) - rust-lang#132774 (Use lld with non-LLVM backends) - rust-lang#132799 (Make `Ty::primitive_symbol` recognize `str`) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Nov 9, 2024
Rollup merge of rust-lang#132799 - zachs18:str-primitive-symbol, r=compiler-errors Make `Ty::primitive_symbol` recognize `str` Make `Ty::primitive_symbol` recognize `str`, which makes `str` eligible for the "expected primitive, found local type" (and vice versa) [diagnostic](https://github.com/rust-lang/rust/blob/master/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs#L1430-L1437) that already exists for other primitives. <details><summary> diagnostic difference</summary> ```rs #[allow(non_camel_case_types)] struct str; fn foo() { let _: &str = "hello"; let _: &core::primitive::str = &str; } ``` `rustc --crate-type lib --edition 2021 a.rs` Current nightly: ```rs error[E0308]: mismatched types --> a.rs:5:19 | 5 | let _: &str = "hello"; | ---- ^^^^^^^ expected `str`, found a different `str` | | | expected due to this | = note: expected reference `&str` found reference `&'static str` error[E0308]: mismatched types --> a.rs:6:36 | 6 | let _: &core::primitive::str = &str; | --------------------- ^^^^ expected `str`, found a different `str` | | | expected due to this | = note: expected reference `&str` (`str`) found reference `&str` (`str`) error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0308`. ``` With this patch: ```rs error[E0308]: mismatched types --> a.rs:5:19 | 5 | let _: &str = "hello"; | ---- ^^^^^^^ expected `str`, found a different `str` | | | expected due to this | = note: str and `str` have similar names, but are actually distinct types = note: str is a primitive defined by the language note: `str` is defined in the current crate --> a.rs:2:1 | 2 | struct str; | ^^^^^^^^^^ error[E0308]: mismatched types --> a.rs:6:36 | 6 | let _: &core::primitive::str = &str; | --------------------- ^^^^ expected `str`, found a different `str` | | | expected due to this | = note: str and `str` have similar names, but are actually distinct types = note: str is a primitive defined by the language note: `str` is defined in the current crate --> a.rs:2:1 | 2 | struct str; | ^^^^^^^^^^ error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0308`. ``` </details>
mati865
pushed a commit
to mati865/rust
that referenced
this pull request
Nov 12, 2024
…mpiler-errors Make `Ty::primitive_symbol` recognize `str` Make `Ty::primitive_symbol` recognize `str`, which makes `str` eligible for the "expected primitive, found local type" (and vice versa) [diagnostic](https://github.com/rust-lang/rust/blob/master/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs#L1430-L1437) that already exists for other primitives. <details><summary> diagnostic difference</summary> ```rs #[allow(non_camel_case_types)] struct str; fn foo() { let _: &str = "hello"; let _: &core::primitive::str = &str; } ``` `rustc --crate-type lib --edition 2021 a.rs` Current nightly: ```rs error[E0308]: mismatched types --> a.rs:5:19 | 5 | let _: &str = "hello"; | ---- ^^^^^^^ expected `str`, found a different `str` | | | expected due to this | = note: expected reference `&str` found reference `&'static str` error[E0308]: mismatched types --> a.rs:6:36 | 6 | let _: &core::primitive::str = &str; | --------------------- ^^^^ expected `str`, found a different `str` | | | expected due to this | = note: expected reference `&str` (`str`) found reference `&str` (`str`) error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0308`. ``` With this patch: ```rs error[E0308]: mismatched types --> a.rs:5:19 | 5 | let _: &str = "hello"; | ---- ^^^^^^^ expected `str`, found a different `str` | | | expected due to this | = note: str and `str` have similar names, but are actually distinct types = note: str is a primitive defined by the language note: `str` is defined in the current crate --> a.rs:2:1 | 2 | struct str; | ^^^^^^^^^^ error[E0308]: mismatched types --> a.rs:6:36 | 6 | let _: &core::primitive::str = &str; | --------------------- ^^^^ expected `str`, found a different `str` | | | expected due to this | = note: str and `str` have similar names, but are actually distinct types = note: str is a primitive defined by the language note: `str` is defined in the current crate --> a.rs:2:1 | 2 | struct str; | ^^^^^^^^^^ error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0308`. ``` </details>
mati865
pushed a commit
to mati865/rust
that referenced
this pull request
Nov 12, 2024
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#132341 (Reject raw lifetime followed by `'`, like regular lifetimes do) - rust-lang#132363 (Enforce that raw lifetimes must be valid raw identifiers) - rust-lang#132744 (add regression test for rust-lang#90781) - rust-lang#132754 (Simplify the internal API for declaring command-line options) - rust-lang#132772 (use `download-rustc="if-unchanged"` as a global default) - rust-lang#132774 (Use lld with non-LLVM backends) - rust-lang#132799 (Make `Ty::primitive_symbol` recognize `str`) r? `@ghost` `@rustbot` modify labels: rollup
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Make
Ty::primitive_symbol
recognizestr
, which makesstr
eligible for the "expected primitive, found local type" (and vice versa) diagnostic that already exists for other primitives.diagnostic difference
rustc --crate-type lib --edition 2021 a.rs
Current nightly:
With this patch: