This is really useful information, will this mean that the lexer token will need to represent strings differently as well? Or is the std::string in the lexer still ok?
The change you made above has the problem that reference types like, arrays are forms of what rust calls covariant types since they might contain an inference variable, so they require lookup to determine the base type. Its likely there is a reference cycle here. Though this change will not be correct for type checking purposes. The design of the type system is purely about rust type checking and inferring types. So for example this change will break the case of:
Since the TypePath of str can't know the size of the expected array at compilation time. And the error message will end up with something like "expected str got [i8, 4]"; As for the string implementation, I did some experimentation this morning and it looks as though strings in rust are a kind of slice that we still need to support so, for example, you can see in this gdb session the implicit struct for the slice:
```
Temporary breakpoint 1, test::main () at
test.rs:88 let a = "Hello World %i\n";
(gdb) n
9 let b = a as *const str;
(gdb) p a
$1 = "Hello World %i\n"
(gdb) p b
No symbol 'b' in current context
(gdb) n
10 let c = b as *const i8;
(gdb) p b
$2 = *const str {data_ptr: 0x555555588000 "Hello World %i\n\000", length: 15}
(gdb) p b.data_ptr
$3 = (*mut u8) 0x555555588000 "Hello World %i\n\000"
```
So to me, this is something that we will need to do in the backend with a bunch of implicit code and types, it seems as though for this rust code:
```
unsafe {
let a:&str = "Hello World %i\n";
let b = a as *const str;
let c = b as *const i8;
printf(c, 123);
}
```
we would be creating something like:
```
struct Str {
data_ptr: i8*;
length: usize;
}
const char *const_string = "hello world %i\n";
Str& a = &Slice{data_ptr: const_string, l5};
Str* b = a;
const unsigned char* c = b->data_ptr;
```
I think we should be able to fix this when we get slices working in the compiler.
What do you think?
--Phil