Skip to content
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

impl Add<char> and AddAssign<char> for String #66504

Conversation

Ruster-a11y
Copy link

This is the new working code for the functionalities mentioned in the title. This also means the previous pull request ( #66215) can now be relegated to just as the implementation for AddAssign<char> for Cow<'_, str>.

This makes the following operations possible:

  • String = String + char
  • String += char

These further code modifications were needed due to the already open issue #51916. Since that issue is beyond the scope for this PR and feature-set, this commit only attempts at getting around that issue by further adding implementations for:

  • impl Add<&&str> for String
  • impl Add<&String> for String
  • impl Add<&&String> for String
  • impl AddAssign<&String> for String

Without these impl additions, the rust compiler complains about lacking the respective implementations for String operations since impl Add<char> for String adds a layer of ambiguity for the compiler.
@LukasKalbertodt, thanks for your suggestions! (#66215 (comment))

Note:

Build only tested on latest Windows 10.
Earlier PR #66490 has been closed since commits had unforeseen changes from submodules and all my rebase/cherry-pick attempts failed to fix that.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @withoutboats (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 18, 2019
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-11-18T01:54:14.1891902Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-11-18T01:54:14.2062739Z ##[command]git config gc.auto 0
2019-11-18T01:54:14.2133744Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-11-18T01:54:14.2199206Z ##[command]git config --get-all http.proxy
2019-11-18T01:54:14.2334726Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/66504/merge:refs/remotes/pull/66504/merge
---
2019-11-18T02:54:49.6053365Z .................................................................................................... 1500/9251
2019-11-18T02:54:55.9577472Z .................................................................................................... 1600/9251
2019-11-18T02:55:04.8281076Z .................................................................................................... 1700/9251
2019-11-18T02:55:14.1529629Z ........i........................................................................................... 1800/9251
2019-11-18T02:55:21.0872504Z .............................................................................................iiiii.. 1900/9251
2019-11-18T02:55:43.4873658Z .................................................................................................... 2100/9251
2019-11-18T02:55:46.0414069Z .................................................................................................... 2200/9251
2019-11-18T02:55:48.6059563Z .................................................................................................... 2300/9251
2019-11-18T02:55:54.8943751Z .................................................................................................... 2400/9251
---
2019-11-18T02:59:43.5953685Z .................................................................................................... 5400/9251
2019-11-18T02:59:54.3913692Z ...............................................................................i.................... 5500/9251
2019-11-18T03:00:02.4454898Z .................................................................................................... 5600/9251
2019-11-18T03:00:09.0534422Z .................................................................................................... 5700/9251
2019-11-18T03:00:19.7906592Z .................................................................ii...i..ii...........i............. 5800/9251
2019-11-18T03:00:42.7780640Z .................................................................................................... 6000/9251
2019-11-18T03:00:51.2714638Z .................................................................................................... 6100/9251
2019-11-18T03:00:51.2714638Z .................................................................................................... 6100/9251
2019-11-18T03:00:55.5512298Z ....................................................................................i..ii........... 6200/9251
2019-11-18T03:01:23.5945714Z .................................................................................................... 6400/9251
2019-11-18T03:01:28.5464232Z ....................................................i............................................... 6500/9251
2019-11-18T03:01:30.8443829Z .................................................................................................... 6600/9251
2019-11-18T03:01:33.3285865Z .........................................i.......................................................... 6700/9251
---
2019-11-18T03:06:29.9126413Z -    = note: expected type `&str`
2019-11-18T03:06:29.9126867Z -               found type `std::string::String`
2019-11-18T03:06:29.9127103Z +    = help: the trait `std::ops::Add` is not implemented for `std::string::String`
2019-11-18T03:06:29.9127288Z 78 
2019-11-18T03:06:29.9127455Z 79 error[E0369]: binary operation `+` cannot be applied to type `&std::string::String`
2019-11-18T03:06:29.9127874Z 80   --> $DIR/issue-39018.rs:30:15
2019-11-18T03:06:29.9128212Z 182 
2019-11-18T03:06:29.9128389Z 183 error: aborting due to 14 previous errors
2019-11-18T03:06:29.9128540Z 184 
2019-11-18T03:06:29.9128988Z - Some errors have detailed explanations: E0308, E0369.
---
2019-11-18T03:06:29.9130478Z 
2019-11-18T03:06:29.9130610Z 
2019-11-18T03:06:29.9130806Z The actual stderr differed from the expected stderr.
2019-11-18T03:06:29.9131300Z Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/span/issue-39018/issue-39018.stderr
2019-11-18T03:06:29.9131779Z To update references, rerun the tests and pass the `--bless` flag
2019-11-18T03:06:29.9132602Z To only update this specific test, also pass `--test-args span/issue-39018.rs`
2019-11-18T03:06:29.9132995Z error: 1 errors occurred comparing output.
2019-11-18T03:06:29.9133173Z status: exit code: 1
2019-11-18T03:06:29.9133173Z status: exit code: 1
2019-11-18T03:06:29.9134177Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/span/issue-39018.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/span/issue-39018" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/span/issue-39018/auxiliary" "-A" "unused"
2019-11-18T03:06:29.9134870Z ------------------------------------------
2019-11-18T03:06:29.9135049Z 
2019-11-18T03:06:29.9135501Z ------------------------------------------
2019-11-18T03:06:29.9135701Z stderr:
2019-11-18T03:06:29.9135701Z stderr:
2019-11-18T03:06:29.9136100Z ------------------------------------------
2019-11-18T03:06:29.9136324Z error[E0369]: binary operation `+` cannot be applied to type `&str`
2019-11-18T03:06:29.9136900Z   --> /checkout/src/test/ui/span/issue-39018.rs:2:22
2019-11-18T03:06:29.9137152Z    |
2019-11-18T03:06:29.9137350Z LL |     let x = "Hello " + "World!";
2019-11-18T03:06:29.9137787Z    |             -------- ^ -------- &str
2019-11-18T03:06:29.9138025Z    |             |        |
2019-11-18T03:06:29.9138196Z    |             |        `+` cannot be used to concatenate two `&str` strings
2019-11-18T03:06:29.9138378Z    |             &str
2019-11-18T03:06:29.9138552Z    |
2019-11-18T03:06:29.9138745Z help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
2019-11-18T03:06:29.9138938Z    |
2019-11-18T03:06:29.9139110Z LL |     let x = "Hello ".to_owned() + "World!";
2019-11-18T03:06:29.9139413Z 
2019-11-18T03:06:29.9139413Z 
2019-11-18T03:06:29.9139597Z error[E0369]: binary operation `+` cannot be applied to type `World`
2019-11-18T03:06:29.9140043Z   --> /checkout/src/test/ui/span/issue-39018.rs:8:26
2019-11-18T03:06:29.9140249Z    |
2019-11-18T03:06:29.9140411Z LL |     let y = World::Hello + World::Goodbye;
2019-11-18T03:06:29.9140852Z    |             ------------ ^ -------------- World
2019-11-18T03:06:29.9141235Z    |             World
2019-11-18T03:06:29.9141386Z    |
2019-11-18T03:06:29.9141386Z    |
2019-11-18T03:06:29.9141544Z    = note: an implementation of `std::ops::Add` might be missing for `World`
2019-11-18T03:06:29.9141698Z 
2019-11-18T03:06:29.9141861Z error[E0369]: binary operation `+` cannot be applied to type `&str`
2019-11-18T03:06:29.9142365Z   --> /checkout/src/test/ui/span/issue-39018.rs:11:22
2019-11-18T03:06:29.9142589Z    |
2019-11-18T03:06:29.9142749Z LL |     let x = "Hello " + "World!".to_owned();
2019-11-18T03:06:29.9145999Z    |             -------- ^ ------------------- std::string::String
2019-11-18T03:06:29.9149318Z    |             |        |
2019-11-18T03:06:29.9149801Z    |             |        `+` cannot be used to concatenate a `&str` with a `String`
2019-11-18T03:06:29.9150127Z    |             &str
2019-11-18T03:06:29.9150380Z    |
2019-11-18T03:06:29.9150676Z help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
2019-11-18T03:06:29.9150938Z    |
2019-11-18T03:06:29.9151176Z LL |     let x = "Hello ".to_owned() + &"World!".to_owned();
2019-11-18T03:06:29.9151663Z 
2019-11-18T03:06:29.9151663Z 
2019-11-18T03:06:29.9152731Z error[E0369]: binary operation `+` cannot be applied to type `&std::string::String`
2019-11-18T03:06:29.9153497Z   --> /checkout/src/test/ui/span/issue-39018.rs:26:16
2019-11-18T03:06:29.9153735Z    |
2019-11-18T03:06:29.9153922Z LL |     let _ = &a + &b; //~ ERROR binary operation
2019-11-18T03:06:29.9154381Z    |             -- ^ -- &std::string::String
2019-11-18T03:06:29.9154594Z    |             |  |
2019-11-18T03:06:29.9154783Z    |             |  `+` cannot be used to concatenate two `&str` strings
2019-11-18T03:06:29.9154964Z    |             &std::string::String
2019-11-18T03:06:29.9155115Z    |
2019-11-18T03:06:29.9155318Z help: String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
2019-11-18T03:06:29.9155503Z    |
2019-11-18T03:06:29.9155672Z LL |     let _ = a + &b; //~ ERROR binary operation
2019-11-18T03:06:29.9156003Z 
2019-11-18T03:06:29.9156003Z 
2019-11-18T03:06:29.9156192Z error[E0369]: binary operation `+` cannot be applied to type `&std::string::String`
2019-11-18T03:06:29.9156725Z   --> /checkout/src/test/ui/span/issue-39018.rs:27:16
2019-11-18T03:06:29.9156955Z    |
2019-11-18T03:06:29.9157124Z LL |     let _ = &a + b; //~ ERROR binary operation
2019-11-18T03:06:29.9157744Z    |             -- ^ - std::string::String
2019-11-18T03:06:29.9158018Z    |             |  |
2019-11-18T03:06:29.9158496Z    |             |  `+` cannot be used to concatenate a `&str` with a `String`
2019-11-18T03:06:29.9163048Z    |             &std::string::String
2019-11-18T03:06:29.9163324Z    |
2019-11-18T03:06:29.9163525Z help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
2019-11-18T03:06:29.9163740Z    |
2019-11-18T03:06:29.9163903Z LL |     let _ = a + &b; //~ ERROR binary operation
2019-11-18T03:06:29.9164583Z 
2019-11-18T03:06:29.9164754Z error[E0277]: cannot add `std::string::String` to `std::string::String`
2019-11-18T03:06:29.9165368Z   --> /checkout/src/test/ui/span/issue-39018.rs:29:15
2019-11-18T03:06:29.9165595Z    |
2019-11-18T03:06:29.9165595Z    |
2019-11-18T03:06:29.9165772Z LL |     let _ = a + b; //~ ERROR mismatched types
2019-11-18T03:06:29.9165957Z    |               ^ no implementation for `std::string::String + std::string::String`
2019-11-18T03:06:29.9166281Z    = help: the trait `std::ops::Add` is not implemented for `std::string::String`
2019-11-18T03:06:29.9166446Z 
2019-11-18T03:06:29.9166446Z 
2019-11-18T03:06:29.9166606Z error[E0369]: binary operation `+` cannot be applied to type `&std::string::String`
2019-11-18T03:06:29.9167074Z   --> /checkout/src/test/ui/span/issue-39018.rs:30:15
2019-11-18T03:06:29.9167283Z    |
2019-11-18T03:06:29.9167448Z LL |     let _ = e + b; //~ ERROR binary operation
2019-11-18T03:06:29.9167894Z    |             - ^ - std::string::String
2019-11-18T03:06:29.9168125Z    |             | |
2019-11-18T03:06:29.9168296Z    |             | `+` cannot be used to concatenate a `&str` with a `String`
2019-11-18T03:06:29.9168482Z    |             &std::string::String
2019-11-18T03:06:29.9169552Z    |
2019-11-18T03:06:29.9169920Z help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
2019-11-18T03:06:29.9170153Z    |
2019-11-18T03:06:29.9170323Z LL |     let _ = e.to_owned() + &b; //~ ERROR binary operation
2019-11-18T03:06:29.9170665Z 
2019-11-18T03:06:29.9170665Z 
2019-11-18T03:06:29.9170856Z error[E0369]: binary operation `+` cannot be applied to type `&std::string::String`
2019-11-18T03:06:29.9171446Z   --> /checkout/src/test/ui/span/issue-39018.rs:31:15
2019-11-18T03:06:29.9171687Z    |
2019-11-18T03:06:29.9172439Z LL |     let _ = e + &b; //~ ERROR binary operation
2019-11-18T03:06:29.9172972Z    |             - ^ -- &std::string::String
2019-11-18T03:06:29.9173230Z    |             | |
2019-11-18T03:06:29.9173416Z    |             | `+` cannot be used to concatenate two `&str` strings
2019-11-18T03:06:29.9173589Z    |             &std::string::String
2019-11-18T03:06:29.9173744Z    |
2019-11-18T03:06:29.9173945Z help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
2019-11-18T03:06:29.9174119Z    |
2019-11-18T03:06:29.9174276Z LL |     let _ = e.to_owned() + &b; //~ ERROR binary operation
2019-11-18T03:06:29.9174568Z 
2019-11-18T03:06:29.9174568Z 
2019-11-18T03:06:29.9174766Z error[E0369]: binary operation `+` cannot be applied to type `&std::string::String`
2019-11-18T03:06:29.9175215Z   --> /checkout/src/test/ui/span/issue-39018.rs:32:15
2019-11-18T03:06:29.9175437Z    |
2019-11-18T03:06:29.9175596Z LL |     let _ = e + d; //~ ERROR binary operation
2019-11-18T03:06:29.9176011Z    |             - ^ - &str
2019-11-18T03:06:29.9176223Z    |             | |
2019-11-18T03:06:29.9176560Z    |             | `+` cannot be used to concatenate two `&str` strings
2019-11-18T03:06:29.9176777Z    |             &std::string::String
2019-11-18T03:06:29.9176933Z    |
2019-11-18T03:06:29.9177118Z help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
2019-11-18T03:06:29.9177304Z    |
2019-11-18T03:06:29.9177461Z LL |     let _ = e.to_owned() + d; //~ ERROR binary operation
2019-11-18T03:06:29.9177775Z 
2019-11-18T03:06:29.9177775Z 
2019-11-18T03:06:29.9177941Z error[E0369]: binary operation `+` cannot be applied to type `&std::string::String`
2019-11-18T03:06:29.9178444Z   --> /checkout/src/test/ui/span/issue-39018.rs:33:15
2019-11-18T03:06:29.9178658Z    |
2019-11-18T03:06:29.9178832Z LL |     let _ = e + &d; //~ ERROR binary operation
2019-11-18T03:06:29.9179231Z    |             - ^ -- &&str
2019-11-18T03:06:29.9179449Z    |             | |
2019-11-18T03:06:29.9179704Z    |             | `+` cannot be used to concatenate two `&str` strings
2019-11-18T03:06:29.9179874Z    |             &std::string::String
2019-11-18T03:06:29.9180055Z    |
2019-11-18T03:06:29.9180280Z help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
2019-11-18T03:06:29.9180467Z    |
2019-11-18T03:06:29.9180637Z LL |     let _ = e.to_owned() + &d; //~ ERROR binary operation
2019-11-18T03:06:29.9180984Z 
2019-11-18T03:06:29.9180984Z 
2019-11-18T03:06:29.9181176Z error[E0369]: binary operation `+` cannot be applied to type `&&str`
2019-11-18T03:06:29.9181662Z   --> /checkout/src/test/ui/span/issue-39018.rs:34:16
2019-11-18T03:06:29.9181885Z    |
2019-11-18T03:06:29.9182361Z LL |     let _ = &c + &d; //~ ERROR binary operation
2019-11-18T03:06:29.9182885Z    |             -- ^ -- &&str
2019-11-18T03:06:29.9183965Z    |             &&str
2019-11-18T03:06:29.9184143Z    |
2019-11-18T03:06:29.9184305Z    = note: an implementation of `std::ops::Add` might be missing for `&&str`
2019-11-18T03:06:29.9184443Z 
2019-11-18T03:06:29.9184443Z 
2019-11-18T03:06:29.9184619Z error[E0369]: binary operation `+` cannot be applied to type `&&str`
2019-11-18T03:06:29.9185123Z   --> /checkout/src/test/ui/span/issue-39018.rs:35:16
2019-11-18T03:06:29.9185336Z    |
2019-11-18T03:06:29.9185513Z LL |     let _ = &c + d; //~ ERROR binary operation
2019-11-18T03:06:29.9185901Z    |             -- ^ - &str
2019-11-18T03:06:29.9186495Z    |             &&str
2019-11-18T03:06:29.9186654Z    |
2019-11-18T03:06:29.9186831Z    = note: an implementation of `std::ops::Add` might be missing for `&&str`
2019-11-18T03:06:29.9186970Z 
2019-11-18T03:06:29.9186970Z 
2019-11-18T03:06:29.9187137Z error[E0369]: binary operation `+` cannot be applied to type `&str`
2019-11-18T03:06:29.9187618Z   --> /checkout/src/test/ui/span/issue-39018.rs:36:15
2019-11-18T03:06:29.9187825Z    |
2019-11-18T03:06:29.9187981Z LL |     let _ = c + &d; //~ ERROR binary operation
2019-11-18T03:06:29.9188382Z    |             - ^ -- &&str
2019-11-18T03:06:29.9188589Z    |             | |
2019-11-18T03:06:29.9188753Z    |             | `+` cannot be used to concatenate two `&str` strings
2019-11-18T03:06:29.9188921Z    |             &str
2019-11-18T03:06:29.9189067Z    |
2019-11-18T03:06:29.9189250Z help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
2019-11-18T03:06:29.9189455Z    |
2019-11-18T03:06:29.9189608Z LL |     let _ = c.to_owned() + &d; //~ ERROR binary operation
2019-11-18T03:06:29.9189910Z 
2019-11-18T03:06:29.9189910Z 
2019-11-18T03:06:29.9190183Z error[E0369]: binary operation `+` cannot be applied to type `&str`
2019-11-18T03:06:29.9190681Z   --> /checkout/src/test/ui/span/issue-39018.rs:37:15
2019-11-18T03:06:29.9190910Z    |
2019-11-18T03:06:29.9191065Z LL |     let _ = c + d; //~ ERROR binary operation
2019-11-18T03:06:29.9191467Z    |             - ^ - &str
2019-11-18T03:06:29.9191670Z    |             | |
2019-11-18T03:06:29.9191829Z    |             | `+` cannot be used to concatenate two `&str` strings
2019-11-18T03:06:29.9192376Z    |             &str
2019-11-18T03:06:29.9192618Z    |
2019-11-18T03:06:29.9192802Z help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
2019-11-18T03:06:29.9193027Z    |
2019-11-18T03:06:29.9193194Z LL |     let _ = c.to_owned() + d; //~ ERROR binary operation
2019-11-18T03:06:29.9193528Z 
2019-11-18T03:06:29.9193690Z error: aborting due to 14 previous errors
2019-11-18T03:06:29.9193831Z 
2019-11-18T03:06:29.9194011Z Some errors have detailed explanations: E0277, E0369.
---
2019-11-18T03:06:29.9197650Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:537:22
2019-11-18T03:06:29.9197893Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-11-18T03:06:29.9198051Z 
2019-11-18T03:06:29.9198195Z 
2019-11-18T03:06:29.9200263Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2019-11-18T03:06:29.9200988Z 
2019-11-18T03:06:29.9201156Z 
2019-11-18T03:06:29.9201324Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-11-18T03:06:29.9201497Z Build completed unsuccessfully in 1:06:03
2019-11-18T03:06:29.9201497Z Build completed unsuccessfully in 1:06:03
2019-11-18T03:06:29.9224297Z == clock drift check ==
2019-11-18T03:06:29.9244808Z   local time: Mon Nov 18 03:06:29 UTC 2019
2019-11-18T03:06:29.9609789Z   network time: Mon, 18 Nov 2019 03:06:29 GMT
2019-11-18T03:06:29.9609962Z == end clock drift check ==
2019-11-18T03:06:30.7081727Z 
2019-11-18T03:06:30.7195173Z ##[error]Bash exited with code '1'.
2019-11-18T03:06:30.7235916Z ##[section]Starting: Checkout
2019-11-18T03:06:30.7237821Z ==============================================================================
2019-11-18T03:06:30.7237900Z Task         : Get sources
2019-11-18T03:06:30.7237953Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@LukasKalbertodt
Copy link
Member

I attempted to rebase my local git with the latest commit on master (0f0c640). somehow it's including various submodule changes even though I never made or staged those changes.

Oh, I forgot to mention that, sorry. This is easily fixed by git submodule update. You hardly ever need to create a new PR for technical reasons, though. So you could have kept the old one. But now that you created a new one anyway, we can use this ^_^

Another meta-hint on the side: if in question about what to do, just ask (as you did) and give us a day or two to answer. From personal experience I know very well that it can often be frustrating trying to figure everything out on your own, especially given the long compile times and complex test system. And since others can often tell you what you have to do, that avoids a lot of that frustration.

Regarding the test failures found in CI: those are UI tests. You might fix them all by just looking at the output that @rust-highfive posted. But if you want to test locally, try this ./x.py test src/test/ui --stage 1. Sadly you have to test with stage 1, so that takes a while to build. But if you only change the tests afterwards, retesting is quick. You can also run ./x.py test --no-doc --stage 1 to run slightly more tests.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-11-19T07:54:05.8008451Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-11-19T07:54:05.8191456Z ##[command]git config gc.auto 0
2019-11-19T07:54:05.8252797Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-11-19T07:54:05.8323143Z ##[command]git config --get-all http.proxy
2019-11-19T07:54:05.8490709Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/66504/merge:refs/remotes/pull/66504/merge
---
2019-11-19T08:51:18.0812795Z .................................................................................................... 1500/9253
2019-11-19T08:51:23.8869933Z .................................................................................................... 1600/9253
2019-11-19T08:51:32.3393842Z .................................................................................................... 1700/9253
2019-11-19T08:51:40.9950583Z ........i........................................................................................... 1800/9253
2019-11-19T08:51:47.3508669Z .............................................................................................iiiii.. 1900/9253
2019-11-19T08:52:07.6806601Z .................................................................................................... 2100/9253
2019-11-19T08:52:09.9313745Z .................................................................................................... 2200/9253
2019-11-19T08:52:12.3414972Z .................................................................................................... 2300/9253
2019-11-19T08:52:18.1071319Z .................................................................................................... 2400/9253
---
2019-11-19T08:55:50.4170729Z .................................................................................................... 5400/9253
2019-11-19T08:56:00.3597051Z ...............................................................................i.................... 5500/9253
2019-11-19T08:56:07.7866640Z .................................................................................................... 5600/9253
2019-11-19T08:56:13.9334675Z .................................................................................................... 5700/9253
2019-11-19T08:56:23.5584778Z .................................................................ii...i..ii...........i............. 5800/9253
2019-11-19T08:56:44.5175372Z .................................................................................................... 6000/9253
2019-11-19T08:56:52.5043377Z .................................................................................................... 6100/9253
2019-11-19T08:56:52.5043377Z .................................................................................................... 6100/9253
2019-11-19T08:56:56.6101135Z ......................................................................................i..ii......... 6200/9253
2019-11-19T08:57:22.7713192Z .................................................................................................... 6400/9253
2019-11-19T08:57:27.6630860Z ......................................................i............................................. 6500/9253
2019-11-19T08:57:29.7046254Z .................................................................................................... 6600/9253
2019-11-19T08:57:32.1529095Z ...........................................i........................................................ 6700/9253
---
2019-11-19T09:02:18.3636630Z 
2019-11-19T09:02:18.3636654Z 
2019-11-19T09:02:18.3636698Z The actual stderr differed from the expected stderr.
2019-11-19T09:02:18.3637173Z Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/span/issue-39018/issue-39018.stderr
2019-11-19T09:02:18.3637396Z To update references, rerun the tests and pass the `--bless` flag
2019-11-19T09:02:18.3638155Z To only update this specific test, also pass `--test-args span/issue-39018.rs`
2019-11-19T09:02:18.3638247Z error: 1 errors occurred comparing output.
2019-11-19T09:02:18.3638294Z status: exit code: 1
2019-11-19T09:02:18.3638294Z status: exit code: 1
2019-11-19T09:02:18.3639113Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/span/issue-39018.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/span/issue-39018" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/span/issue-39018/auxiliary" "-A" "unused"
2019-11-19T09:02:18.3639452Z ------------------------------------------
2019-11-19T09:02:18.3639485Z 
2019-11-19T09:02:18.3639695Z ------------------------------------------
2019-11-19T09:02:18.3639757Z stderr:
2019-11-19T09:02:18.3639757Z stderr:
2019-11-19T09:02:18.3639964Z ------------------------------------------
2019-11-19T09:02:18.3640016Z error[E0369]: binary operation `+` cannot be applied to type `&str`
2019-11-19T09:02:18.3640262Z   --> /checkout/src/test/ui/span/issue-39018.rs:2:22
2019-11-19T09:02:18.3640314Z    |
2019-11-19T09:02:18.3640362Z LL |     let x = "Hello " + "World!";
2019-11-19T09:02:18.3640615Z    |             -------- ^ -------- &str
2019-11-19T09:02:18.3640683Z    |             |        |
2019-11-19T09:02:18.3640745Z    |             |        `+` cannot be used to concatenate two `&str` strings
2019-11-19T09:02:18.3640797Z    |             &str
2019-11-19T09:02:18.3640858Z    |
2019-11-19T09:02:18.3640937Z help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
2019-11-19T09:02:18.3641017Z    |
2019-11-19T09:02:18.3641068Z LL |     let x = "Hello ".to_owned() + "World!";
2019-11-19T09:02:18.3641304Z 
2019-11-19T09:02:18.3641304Z 
2019-11-19T09:02:18.3641364Z error[E0369]: binary operation `+` cannot be applied to type `World`
2019-11-19T09:02:18.3641894Z   --> /checkout/src/test/ui/span/issue-39018.rs:8:26
2019-11-19T09:02:18.3641932Z    |
2019-11-19T09:02:18.3641984Z LL |     let y = World::Hello + World::Goodbye;
2019-11-19T09:02:18.3642166Z    |             ------------ ^ -------------- World
2019-11-19T09:02:18.3642265Z    |             World
2019-11-19T09:02:18.3642300Z    |
2019-11-19T09:02:18.3642300Z    |
2019-11-19T09:02:18.3642339Z    = note: an implementation of `std::ops::Add` might be missing for `World`
2019-11-19T09:02:18.3642373Z 
2019-11-19T09:02:18.3642425Z error[E0369]: binary operation `+` cannot be applied to type `&str`
2019-11-19T09:02:18.3642618Z   --> /checkout/src/test/ui/span/issue-39018.rs:11:22
2019-11-19T09:02:18.3642656Z    |
2019-11-19T09:02:18.3642708Z LL |     let x = "Hello " + "World!".to_owned();
2019-11-19T09:02:18.3642903Z    |             -------- ^ ------------------- std::string::String
2019-11-19T09:02:18.3642944Z    |             |        |
2019-11-19T09:02:18.3642986Z    |             |        `+` cannot be used to concatenate a `&str` with a `String`
2019-11-19T09:02:18.3643045Z    |             &str
2019-11-19T09:02:18.3643078Z    |
2019-11-19T09:02:18.3643242Z help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
2019-11-19T09:02:18.3643366Z    |
2019-11-19T09:02:18.3643404Z LL |     let x = "Hello ".to_owned() + &"World!".to_owned();
2019-11-19T09:02:18.3643486Z 
2019-11-19T09:02:18.3643486Z 
2019-11-19T09:02:18.3643525Z error[E0369]: binary operation `+` cannot be applied to type `&std::string::String`
2019-11-19T09:02:18.3643751Z   --> /checkout/src/test/ui/span/issue-39018.rs:26:16
2019-11-19T09:02:18.3643804Z    |
2019-11-19T09:02:18.3643841Z LL |     let _ = &a + &b; //~ ERROR binary operation
2019-11-19T09:02:18.3644020Z    |             -- ^ -- &std::string::String
2019-11-19T09:02:18.3644077Z    |             |  |
2019-11-19T09:02:18.3644117Z    |             |  `+` cannot be used to concatenate two `&str` strings
2019-11-19T09:02:18.3644156Z    |             &std::string::String
2019-11-19T09:02:18.3644190Z    |
2019-11-19T09:02:18.3644264Z help: String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
2019-11-19T09:02:18.3644313Z    |
2019-11-19T09:02:18.3644349Z LL |     let _ = a + &b; //~ ERROR binary operation
2019-11-19T09:02:18.3644426Z 
2019-11-19T09:02:18.3644426Z 
2019-11-19T09:02:18.3644464Z error[E0369]: binary operation `+` cannot be applied to type `&std::string::String`
2019-11-19T09:02:18.3644676Z   --> /checkout/src/test/ui/span/issue-39018.rs:27:16
2019-11-19T09:02:18.3644713Z    |
2019-11-19T09:02:18.3644749Z LL |     let _ = &a + b; //~ ERROR binary operation
2019-11-19T09:02:18.3644923Z    |             -- ^ - std::string::String
2019-11-19T09:02:18.3644977Z    |             |  |
2019-11-19T09:02:18.3645017Z    |             |  `+` cannot be used to concatenate a `&str` with a `String`
2019-11-19T09:02:18.3645056Z    |             &std::string::String
2019-11-19T09:02:18.3645108Z    |
2019-11-19T09:02:18.3645169Z help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
2019-11-19T09:02:18.3645223Z    |
2019-11-19T09:02:18.3645274Z LL |     let _ = a + &b; //~ ERROR binary operation
2019-11-19T09:02:18.3645332Z 
2019-11-19T09:02:18.3645386Z error[E0277]: cannot add `std::string::String` to `std::string::String`
2019-11-19T09:02:18.3645581Z   --> /checkout/src/test/ui/span/issue-39018.rs:29:15
2019-11-19T09:02:18.3645619Z    |
2019-11-19T09:02:18.3645619Z    |
2019-11-19T09:02:18.3645654Z LL |     let _ = a + b; //~ ERROR E0277
2019-11-19T09:02:18.3645713Z    |               ^ no implementation for `std::string::String + std::string::String`
2019-11-19T09:02:18.3645789Z    = help: the trait `std::ops::Add` is not implemented for `std::string::String`
2019-11-19T09:02:18.3645833Z 
2019-11-19T09:02:18.3645833Z 
2019-11-19T09:02:18.3645878Z error[E0369]: binary operation `+` cannot be applied to type `&std::string::String`
2019-11-19T09:02:18.3646077Z   --> /checkout/src/test/ui/span/issue-39018.rs:30:15
2019-11-19T09:02:18.3646130Z    |
2019-11-19T09:02:18.3646166Z LL |     let _ = e + b; //~ ERROR binary operation
2019-11-19T09:02:18.3646342Z    |             - ^ - std::string::String
2019-11-19T09:02:18.3646381Z    |             | |
2019-11-19T09:02:18.3646437Z    |             | `+` cannot be used to concatenate a `&str` with a `String`
2019-11-19T09:02:18.3646477Z    |             &std::string::String
2019-11-19T09:02:18.3646510Z    |
2019-11-19T09:02:18.3646582Z help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
2019-11-19T09:02:18.3646630Z    |
2019-11-19T09:02:18.3646849Z LL |     let _ = e.to_owned() + &b; //~ ERROR binary operation
2019-11-19T09:02:18.3647012Z 
2019-11-19T09:02:18.3647012Z 
2019-11-19T09:02:18.3647054Z error[E0369]: binary operation `+` cannot be applied to type `&std::string::String`
2019-11-19T09:02:18.3647883Z   --> /checkout/src/test/ui/span/issue-39018.rs:31:15
2019-11-19T09:02:18.3647936Z    |
2019-11-19T09:02:18.3647981Z LL |     let _ = e + &b; //~ ERROR binary operation
2019-11-19T09:02:18.3648259Z    |             - ^ -- &std::string::String
2019-11-19T09:02:18.3648307Z    |             | |
2019-11-19T09:02:18.3648355Z    |             | `+` cannot be used to concatenate two `&str` strings
2019-11-19T09:02:18.3648404Z    |             &std::string::String
2019-11-19T09:02:18.3648462Z    |
2019-11-19T09:02:18.3648528Z help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
2019-11-19T09:02:18.3648599Z    |
2019-11-19T09:02:18.3648663Z LL |     let _ = e.to_owned() + &b; //~ ERROR binary operation
2019-11-19T09:02:18.3648747Z 
2019-11-19T09:02:18.3648747Z 
2019-11-19T09:02:18.3648811Z error[E0369]: binary operation `+` cannot be applied to type `&std::string::String`
2019-11-19T09:02:18.3649050Z   --> /checkout/src/test/ui/span/issue-39018.rs:32:15
2019-11-19T09:02:18.3649095Z    |
2019-11-19T09:02:18.3649155Z LL |     let _ = e + d; //~ ERROR binary operation
2019-11-19T09:02:18.3649356Z    |             - ^ - &str
2019-11-19T09:02:18.3649403Z    |             | |
2019-11-19T09:02:18.3649450Z    |             | `+` cannot be used to concatenate two `&str` strings
2019-11-19T09:02:18.3649515Z    |             &std::string::String
2019-11-19T09:02:18.3649557Z    |
2019-11-19T09:02:18.3649632Z help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
2019-11-19T09:02:18.3649708Z    |
2019-11-19T09:02:18.3649760Z LL |     let _ = e.to_owned() + d; //~ ERROR binary operation
2019-11-19T09:02:18.3649851Z 
2019-11-19T09:02:18.3649851Z 
2019-11-19T09:02:18.3649898Z error[E0369]: binary operation `+` cannot be applied to type `&std::string::String`
2019-11-19T09:02:18.3650136Z   --> /checkout/src/test/ui/span/issue-39018.rs:33:15
2019-11-19T09:02:18.3650197Z    |
2019-11-19T09:02:18.3650241Z LL |     let _ = e + &d; //~ ERROR binary operation
2019-11-19T09:02:18.3650443Z    |             - ^ -- &&str
2019-11-19T09:02:18.3650488Z    |             | |
2019-11-19T09:02:18.3650553Z    |             | `+` cannot be used to concatenate two `&str` strings
2019-11-19T09:02:18.3650602Z    |             &std::string::String
2019-11-19T09:02:18.3650643Z    |
2019-11-19T09:02:18.3650734Z help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
2019-11-19T09:02:18.3650800Z    |
2019-11-19T09:02:18.3650847Z LL |     let _ = e.to_owned() + &d; //~ ERROR binary operation
2019-11-19T09:02:18.3650938Z 
2019-11-19T09:02:18.3650938Z 
2019-11-19T09:02:18.3650983Z error[E0369]: binary operation `+` cannot be applied to type `&&str`
2019-11-19T09:02:18.3651388Z   --> /checkout/src/test/ui/span/issue-39018.rs:34:16
2019-11-19T09:02:18.3651592Z    |
2019-11-19T09:02:18.3651630Z LL |     let _ = &c + &d; //~ ERROR binary operation
2019-11-19T09:02:18.3651795Z    |             -- ^ -- &&str
2019-11-19T09:02:18.3651884Z    |             &&str
2019-11-19T09:02:18.3651917Z    |
2019-11-19T09:02:18.3651973Z    = note: an implementation of `std::ops::Add` might be missing for `&&str`
2019-11-19T09:02:18.3652000Z 
2019-11-19T09:02:18.3652000Z 
2019-11-19T09:02:18.3652141Z error[E0369]: binary operation `+` cannot be applied to type `&&str`
2019-11-19T09:02:18.3652366Z   --> /checkout/src/test/ui/span/issue-39018.rs:35:16
2019-11-19T09:02:18.3652491Z    |
2019-11-19T09:02:18.3652526Z LL |     let _ = &c + d; //~ ERROR binary operation
2019-11-19T09:02:18.3652712Z    |             -- ^ - &str
2019-11-19T09:02:18.3652976Z    |             &&str
2019-11-19T09:02:18.3653013Z    |
2019-11-19T09:02:18.3653069Z    = note: an implementation of `std::ops::Add` might be missing for `&&str`
2019-11-19T09:02:18.3653096Z 
2019-11-19T09:02:18.3653096Z 
2019-11-19T09:02:18.3653134Z error[E0369]: binary operation `+` cannot be applied to type `&str`
2019-11-19T09:02:18.3653551Z   --> /checkout/src/test/ui/span/issue-39018.rs:36:15
2019-11-19T09:02:18.3653609Z    |
2019-11-19T09:02:18.3653647Z LL |     let _ = c + &d; //~ ERROR binary operation
2019-11-19T09:02:18.3653823Z    |             - ^ -- &&str
2019-11-19T09:02:18.3653878Z    |             | |
2019-11-19T09:02:18.3653928Z    |             | `+` cannot be used to concatenate two `&str` strings
2019-11-19T09:02:18.3653968Z    |             &str
2019-11-19T09:02:18.3654153Z    |
2019-11-19T09:02:18.3654211Z help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
2019-11-19T09:02:18.3654262Z    |
2019-11-19T09:02:18.3654317Z LL |     let _ = c.to_owned() + &d; //~ ERROR binary operation
2019-11-19T09:02:18.3654383Z 
2019-11-19T09:02:18.3654383Z 
2019-11-19T09:02:18.3654421Z error[E0369]: binary operation `+` cannot be applied to type `&str`
2019-11-19T09:02:18.3654646Z   --> /checkout/src/test/ui/span/issue-39018.rs:37:15
2019-11-19T09:02:18.3654686Z    |
2019-11-19T09:02:18.3654725Z LL |     let _ = c + d; //~ ERROR binary operation
2019-11-19T09:02:18.3654911Z    |             - ^ - &str
2019-11-19T09:02:18.3654958Z    |             | |
2019-11-19T09:02:18.3654999Z    |             | `+` cannot be used to concatenate two `&str` strings
2019-11-19T09:02:18.3655061Z    |             &str
2019-11-19T09:02:18.3655096Z    |
2019-11-19T09:02:18.3655153Z help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
2019-11-19T09:02:18.3655221Z    |
2019-11-19T09:02:18.3655260Z LL |     let _ = c.to_owned() + d; //~ ERROR binary operation
2019-11-19T09:02:18.3655325Z 
2019-11-19T09:02:18.3655378Z error: aborting due to 14 previous errors
2019-11-19T09:02:18.3655404Z 
2019-11-19T09:02:18.3655442Z Some errors have detailed explanations: E0277, E0369.
---
2019-11-19T09:02:18.3680157Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:537:22
2019-11-19T09:02:18.3680239Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-11-19T09:02:18.3701891Z 
2019-11-19T09:02:18.3701959Z 
2019-11-19T09:02:18.3705826Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2019-11-19T09:02:18.3706123Z 
2019-11-19T09:02:18.3706151Z 
2019-11-19T09:02:18.3706577Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-11-19T09:02:18.3706643Z Build completed unsuccessfully in 1:02:17
2019-11-19T09:02:18.3706643Z Build completed unsuccessfully in 1:02:17
2019-11-19T09:02:18.3764414Z == clock drift check ==
2019-11-19T09:02:18.3778161Z   local time: Tue Nov 19 09:02:18 UTC 2019
2019-11-19T09:02:18.9251608Z   network time: Tue, 19 Nov 2019 09:02:18 GMT
2019-11-19T09:02:18.9251730Z == end clock drift check ==
2019-11-19T09:02:19.7911794Z 
2019-11-19T09:02:19.7971746Z ##[error]Bash exited with code '1'.
2019-11-19T09:02:19.8000219Z ##[section]Starting: Checkout
2019-11-19T09:02:19.8001981Z ==============================================================================
2019-11-19T09:02:19.8002026Z Task         : Get sources
2019-11-19T09:02:19.8002079Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@Ruster-a11y
Copy link
Author

@Centril @KodrAus @jonas-schievink Can we move this forward please?

@Centril
Copy link
Contributor

Centril commented Nov 19, 2019

r? @dtolnay

@Centril Centril added relnotes Marks issues that should be documented in the release notes of the next release. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Nov 19, 2019
@Centril Centril added this to the 1.41 milestone Nov 19, 2019
@Ruster-a11y
Copy link
Author

21 hours and still no review.

@Centril What to do?

@LukasKalbertodt
Copy link
Member

@Ruster-a11y Don't worry, this is completely normal. It usually takes a few days (sometimes weeks) until the reviewer gets active. Also, just as a hint: I'm sure that is not your intention at all, but some people might interpret your comments as trying to rush people or to tell people they are too slow. And we wouldn't want people to feel bad/angry because of that.

As an open source contributor you have to have some patience. So let's just wait :)

@bors
Copy link
Contributor

bors commented Nov 21, 2019

☔ The latest upstream changes (presumably #66389) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect that this would still break a large amount of code even with the extra impls for &String and &&String. :(

This sort of thing compiles today and applies the right chain of derefs to invoke impl Add<&str> for String:

let lhs = String::new();
let rhs = String::new();
let _ = lhs + &&&&&&&rhs;

Nobody would write it exactly like this, but I have found that especially beginners and especially with "match ergonomics" it's very easy to end up with a surprising number of & without realizing.

fn f(input: Option<&str>) {
    let mut string = String::new();
    match &input {
        None => {}
        Some(ref input) => {
            string += &input; // already dealing with &&&str
        }
    }
}

Beginners often end up with this type of code because every part of this locally looks like something they have seen before or copied from somewhere.

  • Option<&str> -- common
  • match &input {...} -- common
  • Some(ref input) -- common
  • string += &input -- common

Is there anything like impl<T> Add<&&T> for String we could do to keep existing code working regardless of the number of references?

Comment on lines 70 to 71
LL | let _ = a + b;
| ^
| |
| expected &str, found struct `std::string::String`
| help: consider borrowing here: `&b`
| ^ no implementation for `std::string::String + std::string::String`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be an unfortunate error message regression. It doesn't necessarily mean we can't add the impl, but we would definitely want to follow up with a dedicated diagnostic to show that the user should write a + &b.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I talked to Ruster-a11y about this and suggested they ignore it for now as a better error message can still be added later. Or do you think we should have a better error message in this PR already? My reasoning was that we first have to decide on the whole "breakage" situation anyway. Implementing the error message beforehand might be a waste of time.

I could have a go at implementing the better error message, if Ruster-a11y does not want to/does not have the time to.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't need to be in this PR but it would be good to have something underway, so that we don't end up with the worse message for years. The code that the original message is explaining exactly how to fix is one of the things that many beginners struggle with.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely! I'd say that the new impl and the better error message should hit stable at the same time. So absolutely not "years" in between.

@LukasKalbertodt
Copy link
Member

Is there anything like impl<T> Add<&&T> for String we could do to keep existing code working regardless of the number of references?

Great idea! It indeed seems to work. I implemented it with AsRef now. But we should think about how many & that impl should have. If we do it with two (&&) like you suggested and I implemented, then libstd can't add any other Add<&&_> impls in the future (due to overlapping impls). So I would probably only add that impl with three or four & to make sure libstd has some room for new impls still. Though, I agree that this number is super arbitrary and thus it doesn't quite feel right.

While it's good to know that we could add this impl to avoid all breakage, I still prefer not to add it, I think. @dtolnay do you think we can simply run crater on this PR?

@dtolnay
Copy link
Member

dtolnay commented Nov 24, 2019

@bors try

@bors
Copy link
Contributor

bors commented Nov 24, 2019

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout impl-char-add-operation-for-String2 (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self impl-char-add-operation-for-String2 --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
Auto-merging src/test/ui/span/issue-39018.stderr
CONFLICT (content): Merge conflict in src/test/ui/span/issue-39018.stderr
Automatic merge failed; fix conflicts and then commit the result.

@dtolnay
Copy link
Member

dtolnay commented Nov 25, 2019

Looks like this will need a rebase to get a crater going.

Rather than building on AsRef, would it maybe be viable to do it this way?:

impl<'a, T> Add<&&'a T> for String 
where
    String: Add<&'a T>

This seems safer because the only impls it could conflict with are ones that we would never want to behave a different way, i.e. we wouldn't want a String + &&T impl that isn't just the same as String + &T.

I tried it briefly in your playground but the trait solver goes nuts, though naively it seems like the sort of thing that should be possible to make work.

@Ruster-a11y Ruster-a11y force-pushed the impl-char-add-operation-for-String2 branch from 77e1329 to b7b8eed Compare November 25, 2019 06:24
@LukasKalbertodt
Copy link
Member

Rather than building on AsRef, would it maybe be viable to do it this way?:
[...]
I tried it briefly in your playground but the trait solver goes nuts.

That's what I tried first, and not so briefly. But I also always got the recursion limit error from the trait solver. No idea why it's happening as it seems like we are never adding a & layer recursively, where such a type blowup could happen. Maybe I'll look into it again some time.

But maybe crater results will be nice, so we don't have to worry about that impl ;-)

@craterbot craterbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 1, 2019
@Mark-Simulacrum
Copy link
Member

There are ~60 root regressions based on crater-generate-report: https://gist.github.com/Mark-Simulacrum/3139e9307eaa63eb37cea965465de384#file-roots-pr-66504-md.

I think given the scope of the failures here we probably can't land this -- it poses too large a breaking change for very little benefit. My earlier comment I think may provide a plausible path forward, but it may make sense to just open a different PR for that approach.

@Ruster-a11y
Copy link
Author

Ruster-a11y commented Dec 1, 2019

One possible alternative might be to add an inherent add method to String which can take any of &str, char, &String, etc. via a trait

@Mark-Simulacrum Alright, this sounds like a good idea. I'll start working on this, and let's see how that plays out. Hopefully, it should work out, it makes a lot more sense than the approach taken in this PR.

@LukasKalbertodt
Copy link
Member

I'm not a big fan of the inherent add method, to be honest. To me it feels like String + char should just work. I think before completely giving up on the Add impl, we should try adding another & impl, (i.e. Add<&&String> and Add<&&str>) and/or adding the AsRef impl I provided above (which should fix most problems). As a note: we can rerun crater on the regressed crates only, which should be quite fast.

@Ruster-a11y
Copy link
Author

@LukasKalbertodt Yep, makes sense. I'll add a working commit at the earliest, might do it using macro_rules! if everything goes well.

If further additions don't play well in the Crater tool test, we can then move on to the AsRef approach as you did in that Rust Playground example?

@Mark-Simulacrum
Copy link
Member

Is this ready for another try + crater?


@LukasKalbertodt I agree that String + char should probably just work; I don't feel like the add method is particularly bad, but it is unfortunate if it is the only non-breaking solution. It feels plausible that we're going to need to wait for default type parameter fallback to be implemented (so that we can introduce new impls without inference breakage, in theory) for more impls on String/char/str to be feasible.

It's also interesting to note that at least hypothetically, String + char is less efficient than String + str -- the latter does not need to do UTF-32 to UTF-8 re-encoding. But this likely isn't important.

@LukasKalbertodt
Copy link
Member

LukasKalbertodt commented Dec 2, 2019

Is this ready for another try + crater?

I think so, yes.

For reference:

  • The first crater run had impls for Add<T> for T = char, &&str, &String
    and &&String.
  • The current state has impls for T = char, &&str, &&&str, &&&&str, &String, &&String, &&&String and &&&&String.

Testing the 1180 regression should only take an hour at most, I guess. So we can probably test all of them for different configurations as well (i.e. with the AsRef impl linked above).

@Mark-Simulacrum
Copy link
Member

Testing the 1180 regression should only take an hour at most, I guess. So we can probably test all of them for different configurations as well (i.e. with the AsRef impl linked above).

We can spawn a shorter crater run with that, but I think we should actually do a full crater run, right? In particular, the changes may uncover breakage in crates that weren't detected as broken by this crater run.

In any case though, @bors try -- that way we can get to a crater run more quickly regardless of which type we choose.

@bors
Copy link
Contributor

bors commented Dec 2, 2019

⌛ Trying commit fca8180 with merge 1a608893c03d7722effeb0058e82770bd36b4b3c...

@bors
Copy link
Contributor

bors commented Dec 3, 2019

☀️ Try build successful - checks-azure
Build commit: 1a608893c03d7722effeb0058e82770bd36b4b3c (1a608893c03d7722effeb0058e82770bd36b4b3c)

@Mark-Simulacrum
Copy link
Member

@craterbot check

@craterbot
Copy link
Collaborator

👌 Experiment pr-66504-1 created and queued.
🤖 Automatically detected try build 1a608893c03d7722effeb0058e82770bd36b4b3c
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 11, 2019
@craterbot
Copy link
Collaborator

🚧 Experiment pr-66504-1 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added the S-waiting-on-crater Status: Waiting on a crater run to be completed. label Dec 11, 2019
@craterbot
Copy link
Collaborator

🎉 Experiment pr-66504-1 is completed!
📊 985 regressed and 0 fixed (81904 total)
📰 Open the full report.

⚠️ If you notice any spurious failure please add them to the blacklist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Dec 13, 2019
@LukasKalbertodt
Copy link
Member

Oof, that's still a lot of regressions.

Skimming through the results shows a few patterns:

  • String + &Cow
  • String + some_string.as_ref(). More generally, where the right hand side has non-inferred types. For example String implements AsRef<[u8]> and AsRef<str>, so the type of some_string.as_ref() is not clear. Before this change, type inference could kick in and try to eagerly make it fit the expected &str.
  • String + &Foo where Foo is a custom type that derefs to str

There are also some common root regressions (tera and pulldown-cmark, for example). In total, there are roughly 100 root regressions (judging from my personal incomplete analysis scripts).


The Cow and Foo cases could be solved with the T: AsRef<str> impl linked above. The type inference cases are way more tricky, I think. I don't see a way to avoid breaking those.

Unsatisfying situation :/

@Centril Centril modified the milestones: 1.41, 1.42 Dec 20, 2019
@Dylan-DPC-zz Dylan-DPC-zz added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 25, 2019
@joelpalmer
Copy link

Ping from Triage: Any updates @Ruster-a11y?

@dtolnay
Copy link
Member

dtolnay commented Jan 10, 2020

I think we've explored these Add impls pretty thoroughly and all the approaches have turned out to be too disruptive for not a great amount of benefit, so I'll go ahead and close the PR. Thanks anyway! I would recommend that instead of String + char, that people make a local variable for the String and then .push(...) chars into it.

The idea of fn add(self: String, other: impl Stringy) -> String could be explored separately but my first reaction is that I'm not in love with it -- I would need to see a compelling example where it really comes out much more readable than using a local String and push, to justify the new API surface area.

@dtolnay dtolnay closed this Jan 10, 2020
@Centril Centril removed the relnotes Marks issues that should be documented in the release notes of the next release. label Jan 31, 2020
@Centril Centril removed this from the 1.42 milestone Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.