Repository: rust
Issue: Change in unrelated line causes compilation failure
Labels: P-medium,T-compiler,C-bug

Hi, when I tried to incorporate `rhai` into my project, compilation fails with a strange (incorrect?) compiler error.

# Steps to reproduce

I use Rust 1.57.0 (at the time of writing: stable):

```
rustc 1.57.0 (f1edd0429 2021-11-29)
binary: rustc
commit-hash: f1edd0429582dd29cccacaf50fd134b05593bd9c
commit-date: 2021-11-29
host: x86_64-unknown-linux-gnu
release: 1.57.0
LLVM version: 13.0.0
```

Ideally, I'd like to provide a minimal example, but I just do not have enough time, so I'd be glad if you could try this:

```
git clone -b compiler_bug https://github.com/phimuemue/openschafkopf.git # check out a specific branch showcasing my problem
cd openschafkopf
cargo check -j16 # Fails to compile, but I do not see why.
```

The last commit on the `compiler_bug` branch from my project introduces no significant changes, but Rust cannot compile it anymore.

# Expected outcome

I think my code is valid and should compile without errors, especially as the last commit on the specific branch should not introduce significant changes.

# Observed outcome

Rust fails to compile the code:

```
warning: unused import: `rhai::Engine`
  --> main/src/subcommands/hand_stats.rs:31:17
   |
31 |             use rhai::Engine;
   |                 ^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

error[E0277]: cannot add `&std::string::String` to `std::string::String`
   --> main/src/game_analysis/mod.rs:190:5
    |
190 |     + &crate::ai::suspicion::player_table(epi_self, |epi| {
    |     ^ no implementation for `std::string::String + &std::string::String`
    |
    = help: the trait `Add<&std::string::String>` is not implemented for `std::string::String`

error[E0277]: cannot add `&std::string::String` to `std::string::String`
   --> main/src/skui/mod.rs:196:9
    |
196 |         + &format!("Stock: {}", n_stock)
    |         ^ no implementation for `std::string::String + &std::string::String`
    |
    = help: the trait `Add<&std::string::String>` is not implemented for `std::string::String`

For more information about this error, try `rustc --explain E0277`.
warning: `openschafkopf` (bin "openschafkopf") generated 1 warning
error: could not compile `openschafkopf` due to 2 previous errors; 1 warning emitted
```

Contrary to what the compiler says, the offending line appears to be `main/src/subcommands/hand_stats.rs:31` (it says `use rhai::Engine;`) - removing it allows the project to be compiled. 

I see that [`String` implements `Add<&str>`](https://doc.rust-lang.org/std/string/struct.String.html#impl-Add%3C%26%27_%20str%3E), and maybe Rust cannot do type coercion anymore (if I do `as &str` manually, it compiles), but I do not see why that should be affected by a change in an unrelated file.

# Workaround

As said above, the problem can be worked-around by explicitly telling the compiler to borrow `as &str`.

<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_ASSIGN_START -->

<!-- TRIAGEBOT_ASSIGN_DATA_START$${"user":"compiler-errors"}$$TRIAGEBOT_ASSIGN_DATA_END -->

<!-- TRIAGEBOT_ASSIGN_END -->
<!-- TRIAGEBOT_END -->