rust/tests
Matthias Krüger 3aa1a24799
Rollup merge of #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>
2024-11-09 19:16:46 +01:00
..
assembly remove support for rustc_safe_intrinsic attribute; use rustc_intrinsic functions instead 2024-11-08 09:16:00 +01:00
auxiliary Fix typo in tests/auxiliary/minicore.rs 2024-11-03 17:32:33 +09:00
codegen Rollup merge of #132777 - durin42:llvm-20-poison-prop, r=nikic 2024-11-09 10:52:04 +01:00
codegen-units
coverage
coverage-run-rustdoc
crashes Auto merge of #132710 - matthiaskrgr:padautz, r=jieyouxu 2024-11-07 07:21:20 +00:00
debuginfo
incremental
mir-opt Rollup merge of #131913 - jieyouxu:only_debug_assertions, r=onur-ozkan 2024-11-07 18:48:21 -08:00
pretty
run-make Rollup merge of #132754 - Zalathar:opts, r=GuillaumeGomez,jieyouxu 2024-11-09 19:16:44 +01:00
rustdoc Rollup merge of #132744 - lolbinarycat:test-90781, r=aDotInTheVoid 2024-11-09 19:16:44 +01:00
rustdoc-gui
rustdoc-js
rustdoc-js-std
rustdoc-json
rustdoc-ui Add UI regressions tests for rustdoc --show-coverage option 2024-11-04 14:46:04 +01:00
ui Rollup merge of #132799 - zachs18:str-primitive-symbol, r=compiler-errors 2024-11-09 19:16:46 +01:00
ui-fulldeps Rollup merge of #132131 - celinval:smir-crate-defs, r=compiler-errors 2024-11-07 18:48:22 -08:00
COMPILER_TESTS.md