Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1933,6 +1933,7 @@ impl<'tcx> Ty<'tcx> {
ty::UintTy::U64 => Some(sym::u64),
ty::UintTy::U128 => Some(sym::u128),
},
ty::Str => Some(sym::str),
_ => None,
}
}
Expand Down
4 changes: 4 additions & 0 deletions tests/ui/mismatched_types/similar_paths_primitive.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#![allow(non_camel_case_types)]

struct bool;
struct str;

fn foo(_: bool) {}
fn bar(_: &str) {}

fn main() {
foo(true);
//~^ ERROR mismatched types [E0308]
bar("hello");
//~^ ERROR mismatched types [E0308]
}
27 changes: 24 additions & 3 deletions tests/ui/mismatched_types/similar_paths_primitive.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/similar_paths_primitive.rs:8:9
--> $DIR/similar_paths_primitive.rs:10:9
|
LL | foo(true);
| --- ^^^^ expected `bool`, found a different `bool`
Expand All @@ -14,11 +14,32 @@ note: `bool` is defined in the current crate
LL | struct bool;
| ^^^^^^^^^^^
note: function defined here
--> $DIR/similar_paths_primitive.rs:5:4
--> $DIR/similar_paths_primitive.rs:6:4
|
LL | fn foo(_: bool) {}
| ^^^ -------

error: aborting due to 1 previous error
error[E0308]: mismatched types
--> $DIR/similar_paths_primitive.rs:12:9
|
LL | bar("hello");
| --- ^^^^^^^ expected `str`, found a different `str`
| |
| arguments to this function are incorrect
|
= 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
--> $DIR/similar_paths_primitive.rs:4:1
|
LL | struct str;
| ^^^^^^^^^^
note: function defined here
--> $DIR/similar_paths_primitive.rs:7:4
|
LL | fn bar(_: &str) {}
| ^^^ -------

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
Loading