From 9bf577311473aa0accbf0d456cbd26b7530b200f Mon Sep 17 00:00:00 2001 From: William Chargin Date: Sun, 8 Sep 2019 14:03:09 -0700 Subject: [PATCH 01/63] Fix `Stdio::piped` example code and lint Summary: Invoking `rev` does not add a trailing newline when none is present in the input (at least on my Debian). Nearby examples use `echo` rather than `rev`, which probably explains the source of the discrepancy. Also, a `mut` qualifier is unused. Test Plan: Copy the code block into with a `fn main` wrapper, and run it. Note that it compiles and runs cleanly; prior to this commit, it would emit an `unused_mut` warning and then panic. wchargin-branch: stdio-piped-docs --- src/libstd/process.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 000f80f99e7a9..cecd9a5ab56b7 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -935,12 +935,12 @@ impl Stdio { /// .expect("Failed to spawn child process"); /// /// { - /// let mut stdin = child.stdin.as_mut().expect("Failed to open stdin"); + /// let stdin = child.stdin.as_mut().expect("Failed to open stdin"); /// stdin.write_all("Hello, world!".as_bytes()).expect("Failed to write to stdin"); /// } /// /// let output = child.wait_with_output().expect("Failed to read stdout"); - /// assert_eq!(String::from_utf8_lossy(&output.stdout), "!dlrow ,olleH\n"); + /// assert_eq!(String::from_utf8_lossy(&output.stdout), "!dlrow ,olleH"); /// ``` #[stable(feature = "process", since = "1.0.0")] pub fn piped() -> Stdio { Stdio(imp::Stdio::MakePipe) } From 299d696b91e833f01f37e97b69767fcf6f5cccf0 Mon Sep 17 00:00:00 2001 From: Caio Date: Thu, 29 Aug 2019 20:44:30 -0300 Subject: [PATCH 02/63] Stabilize `param_attrs` in Rust 1.39.0 --- .../src/language-features/param-attrs.md | 27 ----- src/libsyntax/feature_gate/accepted.rs | 2 + src/libsyntax/feature_gate/active.rs | 3 - src/libsyntax/feature_gate/check.rs | 1 - src/libsyntax/parse/attr.rs | 7 -- src/libsyntax/parse/mod.rs | 2 - src/libsyntax/parse/parser.rs | 4 +- src/libsyntax/parse/parser/expr.rs | 2 +- src/test/ui/lint/lint-unused-mut-variables.rs | 2 +- src/test/ui/lint/lint-unused-variables.rs | 2 +- src/test/ui/parser/fn-arg-doc-comment.rs | 4 - src/test/ui/parser/fn-arg-doc-comment.stderr | 33 ++---- .../rfc-2565-param-attrs/param-attrs-2018.rs | 2 - .../param-attrs-2018.stderr | 2 +- .../param-attrs-allowed.rs | 1 - .../param-attrs-builtin-attrs.rs | 2 - .../param-attrs-builtin-attrs.stderr | 104 +++++++++--------- .../rfc-2565-param-attrs/param-attrs-cfg.rs | 2 +- .../param-attrs-feature-gate.rs | 16 --- .../param-attrs-feature-gate.stderr | 27 ----- .../param-attrs-pretty.rs | 1 - .../proc-macro-cannot-be-used.rs | 1 - .../proc-macro-cannot-be-used.stderr | 50 ++++----- 23 files changed, 93 insertions(+), 204 deletions(-) delete mode 100644 src/doc/unstable-book/src/language-features/param-attrs.md delete mode 100644 src/test/ui/rfc-2565-param-attrs/param-attrs-feature-gate.rs delete mode 100644 src/test/ui/rfc-2565-param-attrs/param-attrs-feature-gate.stderr diff --git a/src/doc/unstable-book/src/language-features/param-attrs.md b/src/doc/unstable-book/src/language-features/param-attrs.md deleted file mode 100644 index 4b83c204ba105..0000000000000 --- a/src/doc/unstable-book/src/language-features/param-attrs.md +++ /dev/null @@ -1,27 +0,0 @@ -# `param_attrs` - -The tracking issue for this feature is: [#60406] - -[#60406]: https://github.com/rust-lang/rust/issues/60406 - -Allow attributes in formal function parameter position so external tools and compiler internals can -take advantage of the additional information that the parameters provide. - -Enables finer conditional compilation with `#[cfg(..)]` and linting control of variables. Moreover, -opens the path to richer DSLs created by users. - ------------------------- - -Example: - -```rust -#![feature(param_attrs)] - -fn len( - #[cfg(windows)] slice: &[u16], - #[cfg(not(windows))] slice: &[u8], -) -> usize -{ - slice.len() -} -``` diff --git a/src/libsyntax/feature_gate/accepted.rs b/src/libsyntax/feature_gate/accepted.rs index eff9f90a8619e..5538daf388e2f 100644 --- a/src/libsyntax/feature_gate/accepted.rs +++ b/src/libsyntax/feature_gate/accepted.rs @@ -243,6 +243,8 @@ declare_features! ( (accepted, async_await, "1.39.0", Some(50547), None), /// Allows mixing bind-by-move in patterns and references to those identifiers in guards. (accepted, bind_by_move_pattern_guards, "1.39.0", Some(15287), None), + /// Allows attributes in formal function parameters. + (accepted, param_attrs, "1.39.0", Some(60406), None), // ------------------------------------------------------------------------- // feature-group-end: accepted features diff --git a/src/libsyntax/feature_gate/active.rs b/src/libsyntax/feature_gate/active.rs index dd78777b56986..38c16dbac6ab7 100644 --- a/src/libsyntax/feature_gate/active.rs +++ b/src/libsyntax/feature_gate/active.rs @@ -489,9 +489,6 @@ declare_features! ( /// Allows the user of associated type bounds. (active, associated_type_bounds, "1.34.0", Some(52662), None), - /// Attributes on formal function params. - (active, param_attrs, "1.36.0", Some(60406), None), - /// Allows calling constructor functions in `const fn`. (active, const_constructor, "1.37.0", Some(61456), None), diff --git a/src/libsyntax/feature_gate/check.rs b/src/libsyntax/feature_gate/check.rs index 5711b269ff092..6b76a6a60c3d6 100644 --- a/src/libsyntax/feature_gate/check.rs +++ b/src/libsyntax/feature_gate/check.rs @@ -892,7 +892,6 @@ pub fn check_crate(krate: &ast::Crate, } } - gate_all!(param_attrs, "attributes on function parameters are unstable"); gate_all!(let_chains, "`let` expressions in this position are experimental"); gate_all!(async_closure, "async closures are unstable"); gate_all!(yields, generators, "yield syntax is experimental"); diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index 9aa1ec0b14fe9..bba70973631fe 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -19,13 +19,6 @@ const DEFAULT_UNEXPECTED_INNER_ATTR_ERR_MSG: &str = "an inner attribute is not \ permitted in this context"; impl<'a> Parser<'a> { - crate fn parse_param_attributes(&mut self) -> PResult<'a, Vec> { - let attrs = self.parse_outer_attributes()?; - self.sess.gated_spans.param_attrs.borrow_mut() - .extend(attrs.iter().map(|a| a.span)); - Ok(attrs) - } - /// Parses attributes that appear before an item. crate fn parse_outer_attributes(&mut self) -> PResult<'a, Vec> { let mut attrs: Vec = Vec::new(); diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index bc1bc00ac8405..6a8a64f369d99 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -42,8 +42,6 @@ pub type PResult<'a, T> = Result>; /// used and should be feature gated accordingly in `check_crate`. #[derive(Default)] pub struct GatedSpans { - /// Spans collected for gating `param_attrs`, e.g. `fn foo(#[attr] x: u8) {}`. - pub param_attrs: Lock>, /// Spans collected for gating `let_chains`, e.g. `if a && let b = c {}`. pub let_chains: Lock>, /// Spans collected for gating `async_closure`, e.g. `async || ..`. diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index fcebfa2996233..b2b6504919e96 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -979,7 +979,7 @@ impl<'a> Parser<'a> { is_name_required: impl Fn(&token::Token) -> bool, ) -> PResult<'a, Param> { let lo = self.token.span; - let attrs = self.parse_param_attributes()?; + let attrs = self.parse_outer_attributes()?; if let Some(mut param) = self.parse_self_param()? { param.attrs = attrs.into(); return self.recover_bad_self_param(param, is_trait_item); @@ -1362,7 +1362,7 @@ impl<'a> Parser<'a> { /// Returns the parsed optional self parameter with attributes and whether a self /// shortcut was used. fn parse_self_parameter_with_attrs(&mut self) -> PResult<'a, Option> { - let attrs = self.parse_param_attributes()?; + let attrs = self.parse_outer_attributes()?; let param_opt = self.parse_self_param()?; Ok(param_opt.map(|mut param| { param.attrs = attrs.into(); diff --git a/src/libsyntax/parse/parser/expr.rs b/src/libsyntax/parse/parser/expr.rs index 31b28443abbc3..b383498b7b64d 100644 --- a/src/libsyntax/parse/parser/expr.rs +++ b/src/libsyntax/parse/parser/expr.rs @@ -1176,7 +1176,7 @@ impl<'a> Parser<'a> { /// Parses a parameter in a closure header (e.g., `|arg, arg|`). fn parse_fn_block_param(&mut self) -> PResult<'a, Param> { let lo = self.token.span; - let attrs = self.parse_param_attributes()?; + let attrs = self.parse_outer_attributes()?; let pat = self.parse_pat(PARAM_EXPECTED)?; let t = if self.eat(&token::Colon) { self.parse_ty()? diff --git a/src/test/ui/lint/lint-unused-mut-variables.rs b/src/test/ui/lint/lint-unused-mut-variables.rs index f140546b04819..1af44ecf362bf 100644 --- a/src/test/ui/lint/lint-unused-mut-variables.rs +++ b/src/test/ui/lint/lint-unused-mut-variables.rs @@ -3,7 +3,7 @@ // Exercise the unused_mut attribute in some positive and negative cases #![deny(unused_mut)] -#![feature(async_closure, param_attrs)] +#![feature(async_closure)] async fn baz_async( mut a: i32, diff --git a/src/test/ui/lint/lint-unused-variables.rs b/src/test/ui/lint/lint-unused-variables.rs index 06b818636f956..1a6b5183f0fae 100644 --- a/src/test/ui/lint/lint-unused-variables.rs +++ b/src/test/ui/lint/lint-unused-variables.rs @@ -1,7 +1,7 @@ // compile-flags: --cfg something // edition:2018 -#![feature(async_closure, param_attrs)] +#![feature(async_closure)] #![deny(unused_variables)] async fn foo_async( diff --git a/src/test/ui/parser/fn-arg-doc-comment.rs b/src/test/ui/parser/fn-arg-doc-comment.rs index 4a4f959e21353..995eb62d0bb59 100644 --- a/src/test/ui/parser/fn-arg-doc-comment.rs +++ b/src/test/ui/parser/fn-arg-doc-comment.rs @@ -2,14 +2,10 @@ pub fn f( /// Comment //~^ ERROR documentation comments cannot be applied to function parameters //~| NOTE doc comments are not allowed here - //~| ERROR attributes on function parameters are unstable - //~| NOTE https://github.com/rust-lang/rust/issues/60406 id: u8, /// Other //~^ ERROR documentation comments cannot be applied to function parameters //~| NOTE doc comments are not allowed here - //~| ERROR attributes on function parameters are unstable - //~| NOTE https://github.com/rust-lang/rust/issues/60406 a: u8, ) {} diff --git a/src/test/ui/parser/fn-arg-doc-comment.stderr b/src/test/ui/parser/fn-arg-doc-comment.stderr index d8884de1fe84d..669785af45f93 100644 --- a/src/test/ui/parser/fn-arg-doc-comment.stderr +++ b/src/test/ui/parser/fn-arg-doc-comment.stderr @@ -1,5 +1,5 @@ error: attributes cannot be applied to a function parameter's type - --> $DIR/fn-arg-doc-comment.rs:16:12 + --> $DIR/fn-arg-doc-comment.rs:12:12 | LL | fn bar(id: #[allow(dead_code)] i32) {} | ^^^^^^^^^^^^^^^^^^^ attributes are not allowed here @@ -11,31 +11,13 @@ LL | /// Comment | ^^^^^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/fn-arg-doc-comment.rs:8:5 + --> $DIR/fn-arg-doc-comment.rs:6:5 | LL | /// Other | ^^^^^^^^^ doc comments are not allowed here -error[E0658]: attributes on function parameters are unstable - --> $DIR/fn-arg-doc-comment.rs:2:5 - | -LL | /// Comment - | ^^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/60406 - = help: add `#![feature(param_attrs)]` to the crate attributes to enable - -error[E0658]: attributes on function parameters are unstable - --> $DIR/fn-arg-doc-comment.rs:8:5 - | -LL | /// Other - | ^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/60406 - = help: add `#![feature(param_attrs)]` to the crate attributes to enable - error[E0308]: mismatched types - --> $DIR/fn-arg-doc-comment.rs:22:7 + --> $DIR/fn-arg-doc-comment.rs:18:7 | LL | f("", ""); | ^^ expected u8, found reference @@ -44,7 +26,7 @@ LL | f("", ""); found type `&'static str` error[E0308]: mismatched types - --> $DIR/fn-arg-doc-comment.rs:22:11 + --> $DIR/fn-arg-doc-comment.rs:18:11 | LL | f("", ""); | ^^ expected u8, found reference @@ -53,7 +35,7 @@ LL | f("", ""); found type `&'static str` error[E0308]: mismatched types - --> $DIR/fn-arg-doc-comment.rs:29:9 + --> $DIR/fn-arg-doc-comment.rs:25:9 | LL | bar(""); | ^^ expected i32, found reference @@ -61,7 +43,6 @@ LL | bar(""); = note: expected type `i32` found type `&'static str` -error: aborting due to 8 previous errors +error: aborting due to 6 previous errors -Some errors have detailed explanations: E0308, E0658. -For more information about an error, try `rustc --explain E0308`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.rs b/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.rs index d71711336b06e..a6f693bd5b5f4 100644 --- a/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.rs +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.rs @@ -1,7 +1,5 @@ // edition:2018 -#![feature(param_attrs)] - trait Trait2015 { fn foo(#[allow(C)] i32); } //~^ ERROR expected one of `:`, `@`, or `|`, found `)` diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.stderr b/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.stderr index 26b414e426805..9860e9805b2ed 100644 --- a/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.stderr +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.stderr @@ -1,5 +1,5 @@ error: expected one of `:`, `@`, or `|`, found `)` - --> $DIR/param-attrs-2018.rs:5:41 + --> $DIR/param-attrs-2018.rs:3:41 | LL | trait Trait2015 { fn foo(#[allow(C)] i32); } | ^ expected one of `:`, `@`, or `|` here diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-allowed.rs b/src/test/ui/rfc-2565-param-attrs/param-attrs-allowed.rs index 5eeda66173ded..1217f89cb3168 100644 --- a/src/test/ui/rfc-2565-param-attrs/param-attrs-allowed.rs +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-allowed.rs @@ -2,7 +2,6 @@ // compile-flags: --cfg something #![deny(unused_mut)] -#![feature(param_attrs)] extern "C" { fn ffi( diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs b/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs index a8fe5d6c1f60e..c4684a3fa82b0 100644 --- a/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs @@ -1,5 +1,3 @@ -#![feature(param_attrs)] - extern "C" { fn ffi( /// Foo diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr b/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr index 8ab3fc39a0ccb..0fc6ca2f7f37a 100644 --- a/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr @@ -1,311 +1,311 @@ error: expected an inert attribute, found an attribute macro - --> $DIR/param-attrs-builtin-attrs.rs:7:9 + --> $DIR/param-attrs-builtin-attrs.rs:5:9 | LL | #[test] a: i32, | ^^^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/param-attrs-builtin-attrs.rs:23:5 + --> $DIR/param-attrs-builtin-attrs.rs:21:5 | LL | #[test] a: u32, | ^^^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/param-attrs-builtin-attrs.rs:38:5 + --> $DIR/param-attrs-builtin-attrs.rs:36:5 | LL | #[test] a: u32, | ^^^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/param-attrs-builtin-attrs.rs:58:9 + --> $DIR/param-attrs-builtin-attrs.rs:56:9 | LL | #[test] a: i32, | ^^^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/param-attrs-builtin-attrs.rs:79:9 + --> $DIR/param-attrs-builtin-attrs.rs:77:9 | LL | #[test] a: i32, | ^^^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/param-attrs-builtin-attrs.rs:98:9 + --> $DIR/param-attrs-builtin-attrs.rs:96:9 | LL | #[test] a: i32, | ^^^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/param-attrs-builtin-attrs.rs:117:9 + --> $DIR/param-attrs-builtin-attrs.rs:115:9 | LL | #[test] a: i32, | ^^^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/param-attrs-builtin-attrs.rs:134:9 + --> $DIR/param-attrs-builtin-attrs.rs:132:9 | LL | #[test] a: u32, | ^^^^^^^ error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:5:9 + --> $DIR/param-attrs-builtin-attrs.rs:3:9 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:9:9 + --> $DIR/param-attrs-builtin-attrs.rs:7:9 | LL | /// Bar | ^^^^^^^ doc comments are not allowed here error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:11:9 + --> $DIR/param-attrs-builtin-attrs.rs:9:9 | LL | #[must_use] | ^^^^^^^^^^^ error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:13:9 + --> $DIR/param-attrs-builtin-attrs.rs:11:9 | LL | /// Baz | ^^^^^^^ doc comments are not allowed here error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:15:9 + --> $DIR/param-attrs-builtin-attrs.rs:13:9 | LL | #[no_mangle] b: i32, | ^^^^^^^^^^^^ error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:21:5 + --> $DIR/param-attrs-builtin-attrs.rs:19:5 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:25:5 + --> $DIR/param-attrs-builtin-attrs.rs:23:5 | LL | /// Bar | ^^^^^^^ doc comments are not allowed here error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:27:5 + --> $DIR/param-attrs-builtin-attrs.rs:25:5 | LL | #[must_use] | ^^^^^^^^^^^ error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:29:5 + --> $DIR/param-attrs-builtin-attrs.rs:27:5 | LL | /// Baz | ^^^^^^^ doc comments are not allowed here error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:31:5 + --> $DIR/param-attrs-builtin-attrs.rs:29:5 | LL | #[no_mangle] b: i32, | ^^^^^^^^^^^^ error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:36:5 + --> $DIR/param-attrs-builtin-attrs.rs:34:5 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:40:5 + --> $DIR/param-attrs-builtin-attrs.rs:38:5 | LL | /// Bar | ^^^^^^^ doc comments are not allowed here error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:42:5 + --> $DIR/param-attrs-builtin-attrs.rs:40:5 | LL | #[must_use] | ^^^^^^^^^^^ error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:44:5 + --> $DIR/param-attrs-builtin-attrs.rs:42:5 | LL | /// Baz | ^^^^^^^ doc comments are not allowed here error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:46:5 + --> $DIR/param-attrs-builtin-attrs.rs:44:5 | LL | #[no_mangle] b: i32, | ^^^^^^^^^^^^ error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:53:9 + --> $DIR/param-attrs-builtin-attrs.rs:51:9 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:56:9 + --> $DIR/param-attrs-builtin-attrs.rs:54:9 | LL | /// Bar | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:60:9 + --> $DIR/param-attrs-builtin-attrs.rs:58:9 | LL | /// Baz | ^^^^^^^ doc comments are not allowed here error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:62:9 + --> $DIR/param-attrs-builtin-attrs.rs:60:9 | LL | #[must_use] | ^^^^^^^^^^^ error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:64:9 + --> $DIR/param-attrs-builtin-attrs.rs:62:9 | LL | /// Qux | ^^^^^^^ doc comments are not allowed here error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:66:9 + --> $DIR/param-attrs-builtin-attrs.rs:64:9 | LL | #[no_mangle] b: i32, | ^^^^^^^^^^^^ error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:74:9 + --> $DIR/param-attrs-builtin-attrs.rs:72:9 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:77:9 + --> $DIR/param-attrs-builtin-attrs.rs:75:9 | LL | /// Bar | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:81:9 + --> $DIR/param-attrs-builtin-attrs.rs:79:9 | LL | /// Baz | ^^^^^^^ doc comments are not allowed here error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:83:9 + --> $DIR/param-attrs-builtin-attrs.rs:81:9 | LL | #[must_use] | ^^^^^^^^^^^ error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:85:9 + --> $DIR/param-attrs-builtin-attrs.rs:83:9 | LL | /// Qux | ^^^^^^^ doc comments are not allowed here error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:87:9 + --> $DIR/param-attrs-builtin-attrs.rs:85:9 | LL | #[no_mangle] b: i32, | ^^^^^^^^^^^^ error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:93:9 + --> $DIR/param-attrs-builtin-attrs.rs:91:9 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:96:9 + --> $DIR/param-attrs-builtin-attrs.rs:94:9 | LL | /// Bar | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:100:9 + --> $DIR/param-attrs-builtin-attrs.rs:98:9 | LL | /// Baz | ^^^^^^^ doc comments are not allowed here error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:102:9 + --> $DIR/param-attrs-builtin-attrs.rs:100:9 | LL | #[must_use] | ^^^^^^^^^^^ error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:104:9 + --> $DIR/param-attrs-builtin-attrs.rs:102:9 | LL | /// Qux | ^^^^^^^ doc comments are not allowed here error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:106:9 + --> $DIR/param-attrs-builtin-attrs.rs:104:9 | LL | #[no_mangle] b: i32, | ^^^^^^^^^^^^ error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:112:9 + --> $DIR/param-attrs-builtin-attrs.rs:110:9 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:115:9 + --> $DIR/param-attrs-builtin-attrs.rs:113:9 | LL | /// Bar | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:119:9 + --> $DIR/param-attrs-builtin-attrs.rs:117:9 | LL | /// Baz | ^^^^^^^ doc comments are not allowed here error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:121:9 + --> $DIR/param-attrs-builtin-attrs.rs:119:9 | LL | #[must_use] | ^^^^^^^^^^^ error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:123:9 + --> $DIR/param-attrs-builtin-attrs.rs:121:9 | LL | /// Qux | ^^^^^^^ doc comments are not allowed here error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:125:9 + --> $DIR/param-attrs-builtin-attrs.rs:123:9 | LL | #[no_mangle] b: i32, | ^^^^^^^^^^^^ error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:132:9 + --> $DIR/param-attrs-builtin-attrs.rs:130:9 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:136:9 + --> $DIR/param-attrs-builtin-attrs.rs:134:9 | LL | /// Bar | ^^^^^^^ doc comments are not allowed here error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:138:9 + --> $DIR/param-attrs-builtin-attrs.rs:136:9 | LL | #[must_use] | ^^^^^^^^^^^ error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:140:9 + --> $DIR/param-attrs-builtin-attrs.rs:138:9 | LL | /// Baz | ^^^^^^^ doc comments are not allowed here error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:142:9 + --> $DIR/param-attrs-builtin-attrs.rs:140:9 | LL | #[no_mangle] b: i32 | ^^^^^^^^^^^^ diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.rs b/src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.rs index 5ad6e23cf2a63..d44ff14e99247 100644 --- a/src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.rs +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.rs @@ -1,7 +1,7 @@ // compile-flags: --cfg something // edition:2018 -#![feature(async_closure, param_attrs)] +#![feature(async_closure)] #![deny(unused_variables)] extern "C" { diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-feature-gate.rs b/src/test/ui/rfc-2565-param-attrs/param-attrs-feature-gate.rs deleted file mode 100644 index a7f4855915b24..0000000000000 --- a/src/test/ui/rfc-2565-param-attrs/param-attrs-feature-gate.rs +++ /dev/null @@ -1,16 +0,0 @@ -// gate-test-param_attrs - -#![deny(unused_variables)] - -fn foo( - /// Foo - //~^ ERROR documentation comments cannot be applied to function parameters - //~| NOTE doc comments are not allowed here - //~| ERROR attributes on function parameters are unstable - //~| NOTE https://github.com/rust-lang/rust/issues/60406 - #[allow(unused_variables)] a: u8 - //~^ ERROR attributes on function parameters are unstable - //~| NOTE https://github.com/rust-lang/rust/issues/60406 -) {} - -fn main() {} diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-feature-gate.stderr b/src/test/ui/rfc-2565-param-attrs/param-attrs-feature-gate.stderr deleted file mode 100644 index 0bb9d05dca0ac..0000000000000 --- a/src/test/ui/rfc-2565-param-attrs/param-attrs-feature-gate.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-feature-gate.rs:6:5 - | -LL | /// Foo - | ^^^^^^^ doc comments are not allowed here - -error[E0658]: attributes on function parameters are unstable - --> $DIR/param-attrs-feature-gate.rs:6:5 - | -LL | /// Foo - | ^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/60406 - = help: add `#![feature(param_attrs)]` to the crate attributes to enable - -error[E0658]: attributes on function parameters are unstable - --> $DIR/param-attrs-feature-gate.rs:11:5 - | -LL | #[allow(unused_variables)] a: u8 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/60406 - = help: add `#![feature(param_attrs)]` to the crate attributes to enable - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-pretty.rs b/src/test/ui/rfc-2565-param-attrs/param-attrs-pretty.rs index 1a7e948174506..fb86020d992e9 100644 --- a/src/test/ui/rfc-2565-param-attrs/param-attrs-pretty.rs +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-pretty.rs @@ -2,7 +2,6 @@ // check-pass -#![feature(param_attrs)] #![feature(c_variadic)] extern crate param_attrs; diff --git a/src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs b/src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs index 7f00308925442..9f4e2710dc420 100644 --- a/src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs +++ b/src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs @@ -1,6 +1,5 @@ // aux-build:ident-mac.rs -#![feature(param_attrs)] #![feature(c_variadic)] extern crate ident_mac; diff --git a/src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr b/src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr index 3b72e8ab4bdf9..b4946fa74943f 100644 --- a/src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr +++ b/src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr @@ -1,149 +1,149 @@ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:11:21 + --> $DIR/proc-macro-cannot-be-used.rs:10:21 | LL | extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); } | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:11:38 + --> $DIR/proc-macro-cannot-be-used.rs:10:38 | LL | extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); } | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:15:38 + --> $DIR/proc-macro-cannot-be-used.rs:14:38 | LL | unsafe extern "C" fn cvar(arg1: i32, #[id] mut args: ...) {} | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:18:28 + --> $DIR/proc-macro-cannot-be-used.rs:17:28 | LL | type Alias = extern "C" fn(#[id] u8, #[id] ...); | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:18:38 + --> $DIR/proc-macro-cannot-be-used.rs:17:38 | LL | type Alias = extern "C" fn(#[id] u8, #[id] ...); | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:22:9 + --> $DIR/proc-macro-cannot-be-used.rs:21:9 | LL | fn free(#[id] arg1: u8) { | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:24:16 + --> $DIR/proc-macro-cannot-be-used.rs:23:16 | LL | let lam = |#[id] W(x), #[id] y| (); | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:24:28 + --> $DIR/proc-macro-cannot-be-used.rs:23:28 | LL | let lam = |#[id] W(x), #[id] y| (); | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:30:18 + --> $DIR/proc-macro-cannot-be-used.rs:29:18 | LL | fn inherent1(#[id] self, #[id] arg1: u8) {} | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:30:30 + --> $DIR/proc-macro-cannot-be-used.rs:29:30 | LL | fn inherent1(#[id] self, #[id] arg1: u8) {} | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:33:18 + --> $DIR/proc-macro-cannot-be-used.rs:32:18 | LL | fn inherent2(#[id] &self, #[id] arg1: u8) {} | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:33:31 + --> $DIR/proc-macro-cannot-be-used.rs:32:31 | LL | fn inherent2(#[id] &self, #[id] arg1: u8) {} | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:36:22 + --> $DIR/proc-macro-cannot-be-used.rs:35:22 | LL | fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {} | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:36:42 + --> $DIR/proc-macro-cannot-be-used.rs:35:42 | LL | fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {} | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:39:22 + --> $DIR/proc-macro-cannot-be-used.rs:38:22 | LL | fn inherent4<'a>(#[id] self: Box, #[id] arg1: u8) {} | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:39:45 + --> $DIR/proc-macro-cannot-be-used.rs:38:45 | LL | fn inherent4<'a>(#[id] self: Box, #[id] arg1: u8) {} | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:45:15 + --> $DIR/proc-macro-cannot-be-used.rs:44:15 | LL | fn trait1(#[id] self, #[id] arg1: u8); | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:45:27 + --> $DIR/proc-macro-cannot-be-used.rs:44:27 | LL | fn trait1(#[id] self, #[id] arg1: u8); | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:48:15 + --> $DIR/proc-macro-cannot-be-used.rs:47:15 | LL | fn trait2(#[id] &self, #[id] arg1: u8); | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:48:28 + --> $DIR/proc-macro-cannot-be-used.rs:47:28 | LL | fn trait2(#[id] &self, #[id] arg1: u8); | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:51:19 + --> $DIR/proc-macro-cannot-be-used.rs:50:19 | LL | fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8); | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:51:39 + --> $DIR/proc-macro-cannot-be-used.rs:50:39 | LL | fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8); | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:54:19 + --> $DIR/proc-macro-cannot-be-used.rs:53:19 | LL | fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec); | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:54:42 + --> $DIR/proc-macro-cannot-be-used.rs:53:42 | LL | fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec); | ^^^^^ error: expected an inert attribute, found an attribute macro - --> $DIR/proc-macro-cannot-be-used.rs:54:58 + --> $DIR/proc-macro-cannot-be-used.rs:53:58 | LL | fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec); | ^^^^^ From 144b8450735f61270cae223c1fd12e2f605c5b34 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 10 Sep 2019 13:48:30 +0200 Subject: [PATCH 03/63] Add long error explanation for E0312 --- src/librustc/error_codes.rs | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/librustc/error_codes.rs b/src/librustc/error_codes.rs index eee33846139e6..f6564f1fcd4c1 100644 --- a/src/librustc/error_codes.rs +++ b/src/librustc/error_codes.rs @@ -1347,6 +1347,39 @@ struct Foo { ``` "##, +E0312: r##" +Reference's lifetime of borrowed content doesn't match the expected lifetime. + +Erroneous code example: + +```compile_fail,E0312 +pub fn opt_str<'a>(maybestr: &'a Option) -> &'static str { + if maybestr.is_none() { + "(none)" + } else { + let s: &'a str = maybestr.as_ref().unwrap(); + s // Invalid lifetime! + } +} +``` + +To fix this error, either lessen the expected lifetime or find a way to not have +to use this reference outside of its current scope (by running the code directly +in the same block for example?): + +``` +// In this case, we can fix the issue by switching from "static" lifetime to 'a +pub fn opt_str<'a>(maybestr: &'a Option) -> &'a str { + if maybestr.is_none() { + "(none)" + } else { + let s: &'a str = maybestr.as_ref().unwrap(); + s // Ok! + } +} +``` +"##, + E0317: r##" This error occurs when an `if` expression without an `else` block is used in a context where a type other than `()` is expected, for example a `let` @@ -2202,7 +2235,6 @@ static X: u32 = 42; // E0304, // expected signed integer constant // E0305, // expected constant E0311, // thing may not live long enough - E0312, // lifetime of reference outlives lifetime of borrowed content E0313, // lifetime of borrowed pointer outlives lifetime of captured // variable E0314, // closure outlives stack frame From cf6a1feda65525b947bfd33279c8b74c00f098c6 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 12 Sep 2019 13:25:42 +0200 Subject: [PATCH 04/63] update ui tests --- src/test/ui/issues/issue-10291.stderr | 1 + src/test/ui/issues/issue-52533.stderr | 1 + src/test/ui/lub-if.stderr | 1 + src/test/ui/lub-match.stderr | 1 + src/test/ui/nll/issue-52742.stderr | 1 + src/test/ui/nll/issue-55401.stderr | 1 + .../ui/nll/user-annotations/constant-in-expr-normalize.stderr | 1 + .../nll/user-annotations/constant-in-expr-trait-item-1.stderr | 1 + .../nll/user-annotations/constant-in-expr-trait-item-2.stderr | 1 + src/test/ui/regions/regions-early-bound-error-method.stderr | 1 + src/test/ui/regions/regions-early-bound-error.stderr | 1 + src/test/ui/regions/regions-nested-fns.stderr | 1 + src/test/ui/regions/regions-static-bound.migrate.stderr | 3 ++- ...ed-closures-infer-argument-types-two-region-pointers.stderr | 1 + src/test/ui/wf/wf-static-method.stderr | 3 ++- 15 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/test/ui/issues/issue-10291.stderr b/src/test/ui/issues/issue-10291.stderr index 5e63469da59f5..a836593e0da10 100644 --- a/src/test/ui/issues/issue-10291.stderr +++ b/src/test/ui/issues/issue-10291.stderr @@ -20,3 +20,4 @@ LL | fn test<'x>(x: &'x isize) { error: aborting due to previous error +For more information about this error, try `rustc --explain E0312`. diff --git a/src/test/ui/issues/issue-52533.stderr b/src/test/ui/issues/issue-52533.stderr index 1ed740c421e0f..586548002072e 100644 --- a/src/test/ui/issues/issue-52533.stderr +++ b/src/test/ui/issues/issue-52533.stderr @@ -17,3 +17,4 @@ LL | foo(|a, b| b) error: aborting due to previous error +For more information about this error, try `rustc --explain E0312`. diff --git a/src/test/ui/lub-if.stderr b/src/test/ui/lub-if.stderr index bb772d4c6c695..26f756c91833b 100644 --- a/src/test/ui/lub-if.stderr +++ b/src/test/ui/lub-if.stderr @@ -26,3 +26,4 @@ LL | pub fn opt_str3<'a>(maybestr: &'a Option) -> &'static str { error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0312`. diff --git a/src/test/ui/lub-match.stderr b/src/test/ui/lub-match.stderr index 090af25143670..0cb0a23c6f2df 100644 --- a/src/test/ui/lub-match.stderr +++ b/src/test/ui/lub-match.stderr @@ -26,3 +26,4 @@ LL | pub fn opt_str3<'a>(maybestr: &'a Option) -> &'static str { error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0312`. diff --git a/src/test/ui/nll/issue-52742.stderr b/src/test/ui/nll/issue-52742.stderr index b982915800294..90a35177f4c3b 100644 --- a/src/test/ui/nll/issue-52742.stderr +++ b/src/test/ui/nll/issue-52742.stderr @@ -20,3 +20,4 @@ LL | | } error: aborting due to previous error +For more information about this error, try `rustc --explain E0312`. diff --git a/src/test/ui/nll/issue-55401.stderr b/src/test/ui/nll/issue-55401.stderr index 50debc6386f6a..4ec16ba055a4c 100644 --- a/src/test/ui/nll/issue-55401.stderr +++ b/src/test/ui/nll/issue-55401.stderr @@ -13,3 +13,4 @@ LL | fn static_to_a_to_static_through_ref_in_tuple<'a>(x: &'a u32) -> &'static u error: aborting due to previous error +For more information about this error, try `rustc --explain E0312`. diff --git a/src/test/ui/nll/user-annotations/constant-in-expr-normalize.stderr b/src/test/ui/nll/user-annotations/constant-in-expr-normalize.stderr index f49d68458bea5..0a8ad4221c986 100644 --- a/src/test/ui/nll/user-annotations/constant-in-expr-normalize.stderr +++ b/src/test/ui/nll/user-annotations/constant-in-expr-normalize.stderr @@ -13,3 +13,4 @@ LL | fn foo<'a>(_: &'a u32) -> &'static u32 { error: aborting due to previous error +For more information about this error, try `rustc --explain E0312`. diff --git a/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-1.stderr b/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-1.stderr index 451bcf41e42a9..d596aaf098f77 100644 --- a/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-1.stderr +++ b/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-1.stderr @@ -13,3 +13,4 @@ LL | fn foo<'a>(_: &'a u32) -> &'static u32 { error: aborting due to previous error +For more information about this error, try `rustc --explain E0312`. diff --git a/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-2.stderr b/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-2.stderr index d129e55e1e6f6..80ff9a043d4d5 100644 --- a/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-2.stderr +++ b/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-2.stderr @@ -13,3 +13,4 @@ LL | fn foo<'a, T: Foo<'a>>() -> &'static u32 { error: aborting due to previous error +For more information about this error, try `rustc --explain E0312`. diff --git a/src/test/ui/regions/regions-early-bound-error-method.stderr b/src/test/ui/regions/regions-early-bound-error-method.stderr index 2e5f55f8742cc..7b9f2c9503b2f 100644 --- a/src/test/ui/regions/regions-early-bound-error-method.stderr +++ b/src/test/ui/regions/regions-early-bound-error-method.stderr @@ -17,3 +17,4 @@ LL | fn or<'b,G:GetRef<'b>>(&self, g2: G) -> &'a isize { error: aborting due to previous error +For more information about this error, try `rustc --explain E0312`. diff --git a/src/test/ui/regions/regions-early-bound-error.stderr b/src/test/ui/regions/regions-early-bound-error.stderr index bc52f4bef7eaa..a68355b78f54c 100644 --- a/src/test/ui/regions/regions-early-bound-error.stderr +++ b/src/test/ui/regions/regions-early-bound-error.stderr @@ -17,3 +17,4 @@ LL | fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize { error: aborting due to previous error +For more information about this error, try `rustc --explain E0312`. diff --git a/src/test/ui/regions/regions-nested-fns.stderr b/src/test/ui/regions/regions-nested-fns.stderr index 15c9c9ca4ddbb..904dee6998c9b 100644 --- a/src/test/ui/regions/regions-nested-fns.stderr +++ b/src/test/ui/regions/regions-nested-fns.stderr @@ -57,3 +57,4 @@ LL | fn nested<'x>(x: &'x isize) { error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0312`. diff --git a/src/test/ui/regions/regions-static-bound.migrate.stderr b/src/test/ui/regions/regions-static-bound.migrate.stderr index fc8cca929d389..21ead8b768f47 100644 --- a/src/test/ui/regions/regions-static-bound.migrate.stderr +++ b/src/test/ui/regions/regions-static-bound.migrate.stderr @@ -30,4 +30,5 @@ LL | static_id_indirect(&v); error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0621`. +Some errors have detailed explanations: E0312, E0621. +For more information about an error, try `rustc --explain E0312`. diff --git a/src/test/ui/unboxed-closures/unboxed-closures-infer-argument-types-two-region-pointers.stderr b/src/test/ui/unboxed-closures/unboxed-closures-infer-argument-types-two-region-pointers.stderr index 728efadf4196e..526055ba04b65 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-infer-argument-types-two-region-pointers.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-infer-argument-types-two-region-pointers.stderr @@ -23,3 +23,4 @@ LL | | }); error: aborting due to previous error +For more information about this error, try `rustc --explain E0312`. diff --git a/src/test/ui/wf/wf-static-method.stderr b/src/test/ui/wf/wf-static-method.stderr index f82526aa88ebf..3ec90f00448a9 100644 --- a/src/test/ui/wf/wf-static-method.stderr +++ b/src/test/ui/wf/wf-static-method.stderr @@ -105,4 +105,5 @@ LL | ::static_evil(b) error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0478`. +Some errors have detailed explanations: E0312, E0478. +For more information about an error, try `rustc --explain E0312`. From 6e5ada43bf84b15a8dd4d55f5bee3ba1a9939bfe Mon Sep 17 00:00:00 2001 From: Tim Vermeulen Date: Sat, 31 Aug 2019 23:00:15 +0200 Subject: [PATCH 05/63] Add cmp::{min_by, min_by_key, max_by, max_by_key} --- src/libcore/cmp.rs | 90 +++++++++++++++++++++++++++++++++++++++- src/libcore/tests/cmp.rs | 24 ++++++++++- src/libcore/tests/lib.rs | 1 + 3 files changed, 112 insertions(+), 3 deletions(-) diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 7ec2295f97e36..4e2b1627e15ef 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -570,7 +570,7 @@ pub trait Ord: Eq + PartialOrd { #[inline] fn max(self, other: Self) -> Self where Self: Sized { - if other >= self { other } else { self } + max_by(self, other, Ord::cmp) } /// Compares and returns the minimum of two values. @@ -587,7 +587,7 @@ pub trait Ord: Eq + PartialOrd { #[inline] fn min(self, other: Self) -> Self where Self: Sized { - if self <= other { self } else { other } + min_by(self, other, Ord::cmp) } /// Restrict a value to a certain interval. @@ -898,6 +898,49 @@ pub fn min(v1: T, v2: T) -> T { v1.min(v2) } +/// Returns the minimum of two values with respect to the specified comparison function. +/// +/// Returns the first argument if the comparison determines them to be equal. +/// +/// # Examples +/// +/// ``` +/// #![feature(cmp_min_max_by)] +/// +/// use std::cmp; +/// +/// assert_eq!(cmp::min_by(-2, 1, |x: &i32, y: &i32| x.abs().cmp(&y.abs())), 1); +/// assert_eq!(cmp::min_by(-2, 2, |x: &i32, y: &i32| x.abs().cmp(&y.abs())), -2); +/// ``` +#[inline] +#[unstable(feature = "cmp_min_max_by", issue = "64460")] +pub fn min_by Ordering>(v1: T, v2: T, compare: F) -> T { + match compare(&v1, &v2) { + Ordering::Less | Ordering::Equal => v1, + Ordering::Greater => v2, + } +} + +/// Returns the element that gives the minimum value from the specified function. +/// +/// Returns the first argument if the comparison determines them to be equal. +/// +/// # Examples +/// +/// ``` +/// #![feature(cmp_min_max_by)] +/// +/// use std::cmp; +/// +/// assert_eq!(cmp::min_by_key(-2, 1, |x: &i32| x.abs()), 1); +/// assert_eq!(cmp::min_by_key(-2, 2, |x: &i32| x.abs()), -2); +/// ``` +#[inline] +#[unstable(feature = "cmp_min_max_by", issue = "64460")] +pub fn min_by_key K, K: Ord>(v1: T, v2: T, mut f: F) -> T { + min_by(v1, v2, |v1, v2| f(v1).cmp(&f(v2))) +} + /// Compares and returns the maximum of two values. /// /// Returns the second argument if the comparison determines them to be equal. @@ -918,6 +961,49 @@ pub fn max(v1: T, v2: T) -> T { v1.max(v2) } +/// Returns the maximum of two values with respect to the specified comparison function. +/// +/// Returns the second argument if the comparison determines them to be equal. +/// +/// # Examples +/// +/// ``` +/// #![feature(cmp_min_max_by)] +/// +/// use std::cmp; +/// +/// assert_eq!(cmp::max_by(-2, 1, |x: &i32, y: &i32| x.abs().cmp(&y.abs())), -2); +/// assert_eq!(cmp::max_by(-2, 2, |x: &i32, y: &i32| x.abs().cmp(&y.abs())), 2); +/// ``` +#[inline] +#[unstable(feature = "cmp_min_max_by", issue = "64460")] +pub fn max_by Ordering>(v1: T, v2: T, compare: F) -> T { + match compare(&v1, &v2) { + Ordering::Less | Ordering::Equal => v2, + Ordering::Greater => v1, + } +} + +/// Returns the element that gives the maximum value from the specified function. +/// +/// Returns the second argument if the comparison determines them to be equal. +/// +/// # Examples +/// +/// ``` +/// #![feature(cmp_min_max_by)] +/// +/// use std::cmp; +/// +/// assert_eq!(cmp::max_by_key(-2, 1, |x: &i32| x.abs()), -2); +/// assert_eq!(cmp::max_by_key(-2, 2, |x: &i32| x.abs()), 2); +/// ``` +#[inline] +#[unstable(feature = "cmp_min_max_by", issue = "64460")] +pub fn max_by_key K, K: Ord>(v1: T, v2: T, mut f: F) -> T { + max_by(v1, v2, |v1, v2| f(v1).cmp(&f(v2))) +} + // Implementation of PartialEq, Eq, PartialOrd and Ord for primitive types mod impls { use crate::cmp::Ordering::{self, Less, Greater, Equal}; diff --git a/src/libcore/tests/cmp.rs b/src/libcore/tests/cmp.rs index 4e624e5eb126e..5e6778e222a29 100644 --- a/src/libcore/tests/cmp.rs +++ b/src/libcore/tests/cmp.rs @@ -1,4 +1,4 @@ -use core::cmp::Ordering::{Less, Greater, Equal}; +use core::cmp::{self, Ordering::*}; #[test] fn test_int_totalord() { @@ -28,6 +28,28 @@ fn test_ord_max_min() { assert_eq!(1.min(1), 1); } +#[test] +fn test_ord_min_max_by() { + let f = |x: &i32, y: &i32| x.abs().cmp(&y.abs()); + assert_eq!(cmp::min_by(1, -1, f), 1); + assert_eq!(cmp::min_by(1, -2, f), 1); + assert_eq!(cmp::min_by(2, -1, f), -1); + assert_eq!(cmp::max_by(1, -1, f), -1); + assert_eq!(cmp::max_by(1, -2, f), -2); + assert_eq!(cmp::max_by(2, -1, f), 2); +} + +#[test] +fn test_ord_min_max_by_key() { + let f = |x: &i32| x.abs(); + assert_eq!(cmp::min_by_key(1, -1, f), 1); + assert_eq!(cmp::min_by_key(1, -2, f), 1); + assert_eq!(cmp::min_by_key(2, -1, f), -1); + assert_eq!(cmp::max_by_key(1, -1, f), -1); + assert_eq!(cmp::max_by_key(1, -2, f), -2); + assert_eq!(cmp::max_by_key(2, -1, f), 2); +} + #[test] fn test_ordering_reverse() { assert_eq!(Less.reverse(), Greater); diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs index 050195cd2ef51..35661356028cb 100644 --- a/src/libcore/tests/lib.rs +++ b/src/libcore/tests/lib.rs @@ -34,6 +34,7 @@ #![feature(iter_partition_in_place)] #![feature(iter_is_partitioned)] #![feature(iter_order_by)] +#![feature(cmp_min_max_by)] extern crate test; From 72175915d6ae5abbc45cf2860a90508d2b4a38ea Mon Sep 17 00:00:00 2001 From: Tim Vermeulen Date: Sat, 14 Sep 2019 21:24:50 +0200 Subject: [PATCH 06/63] Simplify Iterator::{min_by, max_by} using cmp::{min_by, max_by} --- src/libcore/iter/traits/iterator.rs | 48 ++++++++++------------------- 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/src/libcore/iter/traits/iterator.rs b/src/libcore/iter/traits/iterator.rs index c09df3f7f22cb..da49223dfb285 100644 --- a/src/libcore/iter/traits/iterator.rs +++ b/src/libcore/iter/traits/iterator.rs @@ -1,4 +1,4 @@ -use crate::cmp::Ordering; +use crate::cmp::{self, Ordering}; use crate::ops::{Add, Try}; use super::super::LoopState; @@ -2223,13 +2223,12 @@ pub trait Iterator { move |x| (f(&x), x) } - // switch to y even if it is only equal, to preserve stability. #[inline] - fn select((x_p, _): &(B, T), (y_p, _): &(B, T)) -> bool { - x_p <= y_p + fn compare((x_p, _): &(B, T), (y_p, _): &(B, T)) -> Ordering { + x_p.cmp(y_p) } - let (_, x) = select_fold1(self.map(key(f)), select)?; + let (_, x) = self.map(key(f)).max_by(compare)?; Some(x) } @@ -2252,13 +2251,12 @@ pub trait Iterator { fn max_by(self, compare: F) -> Option where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Ordering, { - // switch to y even if it is only equal, to preserve stability. #[inline] - fn select(mut compare: impl FnMut(&T, &T) -> Ordering) -> impl FnMut(&T, &T) -> bool { - move |x, y| compare(x, y) != Ordering::Greater + fn fold(mut compare: impl FnMut(&T, &T) -> Ordering) -> impl FnMut(T, T) -> T { + move |x, y| cmp::max_by(x, y, &mut compare) } - select_fold1(self, select(compare)) + fold1(self, fold(compare)) } /// Returns the element that gives the minimum value from the @@ -2285,13 +2283,12 @@ pub trait Iterator { move |x| (f(&x), x) } - // only switch to y if it is strictly smaller, to preserve stability. #[inline] - fn select((x_p, _): &(B, T), (y_p, _): &(B, T)) -> bool { - x_p > y_p + fn compare((x_p, _): &(B, T), (y_p, _): &(B, T)) -> Ordering { + x_p.cmp(y_p) } - let (_, x) = select_fold1(self.map(key(f)), select)?; + let (_, x) = self.map(key(f)).min_by(compare)?; Some(x) } @@ -2314,13 +2311,12 @@ pub trait Iterator { fn min_by(self, compare: F) -> Option where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Ordering, { - // only switch to y if it is strictly smaller, to preserve stability. #[inline] - fn select(mut compare: impl FnMut(&T, &T) -> Ordering) -> impl FnMut(&T, &T) -> bool { - move |x, y| compare(x, y) == Ordering::Greater + fn fold(mut compare: impl FnMut(&T, &T) -> Ordering) -> impl FnMut(T, T) -> T { + move |x, y| cmp::min_by(x, y, &mut compare) } - select_fold1(self, select(compare)) + fold1(self, fold(compare)) } @@ -2958,28 +2954,18 @@ pub trait Iterator { } } -/// Select an element from an iterator based on the given "comparison" -/// function. -/// -/// This is an idiosyncratic helper to try to factor out the -/// commonalities of {max,min}{,_by}. In particular, this avoids -/// having to implement optimizations several times. +/// Fold an iterator without having to provide an initial value. #[inline] -fn select_fold1(mut it: I, f: F) -> Option +fn fold1(mut it: I, f: F) -> Option where I: Iterator, - F: FnMut(&I::Item, &I::Item) -> bool, + F: FnMut(I::Item, I::Item) -> I::Item, { - #[inline] - fn select(mut f: impl FnMut(&T, &T) -> bool) -> impl FnMut(T, T) -> T { - move |sel, x| if f(&sel, &x) { x } else { sel } - } - // start with the first element as our selection. This avoids // having to use `Option`s inside the loop, translating to a // sizeable performance gain (6x in one case). let first = it.next()?; - Some(it.fold(first, select(f))) + Some(it.fold(first, f)) } #[stable(feature = "rust1", since = "1.0.0")] From 194d357e03dcee73bfdb32a45175c97f4c3ce422 Mon Sep 17 00:00:00 2001 From: Charles Gleason Date: Tue, 3 Sep 2019 18:42:58 -0400 Subject: [PATCH 07/63] Document `From` trait for `LhsExpr` --- src/libsyntax/parse/parser/expr.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libsyntax/parse/parser/expr.rs b/src/libsyntax/parse/parser/expr.rs index 5b9f0f1df6718..c38b134154d62 100644 --- a/src/libsyntax/parse/parser/expr.rs +++ b/src/libsyntax/parse/parser/expr.rs @@ -66,6 +66,10 @@ pub(super) enum LhsExpr { } impl From>> for LhsExpr { + /// Converts `Some(attrs)` into `LhsExpr::AttributesParsed(attrs)` + /// and `None` into `LhsExpr::NotYetParsed`. + /// + /// This conversion does not allocate. fn from(o: Option>) -> Self { if let Some(attrs) = o { LhsExpr::AttributesParsed(attrs) @@ -76,6 +80,9 @@ impl From>> for LhsExpr { } impl From> for LhsExpr { + /// Converts the `expr: P` into `LhsExpr::AlreadyParsed(expr)`. + /// + /// This conversion does not allocate. fn from(expr: P) -> Self { LhsExpr::AlreadyParsed(expr) } From cdd805506e7a01d60906f8b153afb697d687609d Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 7 Sep 2019 09:57:11 -0400 Subject: [PATCH 08/63] Replace DiagnosticBuilder with Diagnostic when emitting error --- src/librustc/session/mod.rs | 14 +++++++--- src/librustc_codegen_ssa/back/write.rs | 4 +-- src/librustc_driver/lib.rs | 1 + .../annotate_snippet_emitter_writer.rs | 12 ++++++--- src/librustc_errors/emitter.rs | 20 +++++++++----- src/librustc_errors/lib.rs | 3 ++- src/librustdoc/core.rs | 2 ++ src/librustdoc/test.rs | 2 +- src/libsyntax/json.rs | 26 +++++++++++++------ src/libsyntax/parse/lexer/tests.rs | 1 + src/libsyntax/tests.rs | 1 + 11 files changed, 60 insertions(+), 26 deletions(-) diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 8656ebb2e6d72..af9cb5a0941e5 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -1040,6 +1040,7 @@ fn default_emitter( source_map: &Lrc, emitter_dest: Option>, ) -> Box { + let external_macro_backtrace = sopts.debugging_opts.external_macro_backtrace; match (sopts.error_format, emitter_dest) { (config::ErrorOutputType::HumanReadable(kind), dst) => { let (short, color_config) = kind.unzip(); @@ -1048,6 +1049,7 @@ fn default_emitter( let emitter = AnnotateSnippetEmitterWriter::new( Some(source_map.clone()), short, + external_macro_backtrace, ); Box::new(emitter.ui_testing(sopts.debugging_opts.ui_testing)) } else { @@ -1058,6 +1060,7 @@ fn default_emitter( short, sopts.debugging_opts.teach, sopts.debugging_opts.terminal_width, + external_macro_backtrace, ), Some(dst) => EmitterWriter::new( dst, @@ -1066,6 +1069,7 @@ fn default_emitter( false, // no teach messages when writing to a buffer false, // no colors when writing to a buffer None, // no terminal width + external_macro_backtrace, ), }; Box::new(emitter.ui_testing(sopts.debugging_opts.ui_testing)) @@ -1077,6 +1081,7 @@ fn default_emitter( source_map.clone(), pretty, json_rendered, + external_macro_backtrace, ).ui_testing(sopts.debugging_opts.ui_testing), ), (config::ErrorOutputType::Json { pretty, json_rendered }, Some(dst)) => Box::new( @@ -1086,6 +1091,7 @@ fn default_emitter( source_map.clone(), pretty, json_rendered, + external_macro_backtrace, ).ui_testing(sopts.debugging_opts.ui_testing), ), } @@ -1382,10 +1388,10 @@ pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! { let emitter: Box = match output { config::ErrorOutputType::HumanReadable(kind) => { let (short, color_config) = kind.unzip(); - Box::new(EmitterWriter::stderr(color_config, None, short, false, None)) + Box::new(EmitterWriter::stderr(color_config, None, short, false, None, false)) } config::ErrorOutputType::Json { pretty, json_rendered } => - Box::new(JsonEmitter::basic(pretty, json_rendered)), + Box::new(JsonEmitter::basic(pretty, json_rendered, false)), }; let handler = errors::Handler::with_emitter(true, None, emitter); handler.emit(&MultiSpan::new(), msg, errors::Level::Fatal); @@ -1396,10 +1402,10 @@ pub fn early_warn(output: config::ErrorOutputType, msg: &str) { let emitter: Box = match output { config::ErrorOutputType::HumanReadable(kind) => { let (short, color_config) = kind.unzip(); - Box::new(EmitterWriter::stderr(color_config, None, short, false, None)) + Box::new(EmitterWriter::stderr(color_config, None, short, false, None, false)) } config::ErrorOutputType::Json { pretty, json_rendered } => - Box::new(JsonEmitter::basic(pretty, json_rendered)), + Box::new(JsonEmitter::basic(pretty, json_rendered, false)), }; let handler = errors::Handler::with_emitter(true, None, emitter); handler.emit(&MultiSpan::new(), msg, errors::Level::Warning); diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs index eec098426239c..38a0818d290bd 100644 --- a/src/librustc_codegen_ssa/back/write.rs +++ b/src/librustc_codegen_ssa/back/write.rs @@ -22,7 +22,7 @@ use rustc::util::common::{time_depth, set_time_depth, print_time_passes_entry}; use rustc::util::profiling::SelfProfiler; use rustc_fs_util::link_or_copy; use rustc_data_structures::svh::Svh; -use rustc_errors::{Handler, Level, DiagnosticBuilder, FatalError, DiagnosticId}; +use rustc_errors::{Handler, Level, FatalError, DiagnosticId}; use rustc_errors::emitter::{Emitter}; use rustc_target::spec::MergeFunctions; use syntax::attr; @@ -1725,7 +1725,7 @@ impl SharedEmitter { } impl Emitter for SharedEmitter { - fn emit_diagnostic(&mut self, db: &DiagnosticBuilder<'_>) { + fn emit_diagnostic(&mut self, db: &rustc_errors::Diagnostic) { drop(self.sender.send(SharedEmitterMessage::Diagnostic(Diagnostic { msg: db.message(), code: db.code.clone(), diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 8c5d8536c32fa..3a09f459e9c1f 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -1196,6 +1196,7 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) { false, false, None, + false, )); let handler = errors::Handler::with_emitter(true, None, emitter); diff --git a/src/librustc_errors/annotate_snippet_emitter_writer.rs b/src/librustc_errors/annotate_snippet_emitter_writer.rs index c626dd0434d52..0281d10fd930e 100644 --- a/src/librustc_errors/annotate_snippet_emitter_writer.rs +++ b/src/librustc_errors/annotate_snippet_emitter_writer.rs @@ -7,7 +7,7 @@ use syntax_pos::{SourceFile, MultiSpan, Loc}; use crate::{ - Level, CodeSuggestion, DiagnosticBuilder, Emitter, + Level, CodeSuggestion, Diagnostic, Emitter, SourceMapperDyn, SubDiagnostic, DiagnosticId }; use crate::emitter::FileWithAnnotatedLines; @@ -25,11 +25,13 @@ pub struct AnnotateSnippetEmitterWriter { short_message: bool, /// If true, will normalize line numbers with `LL` to prevent noise in UI test diffs. ui_testing: bool, + + external_macro_backtrace: bool, } impl Emitter for AnnotateSnippetEmitterWriter { /// The entry point for the diagnostics generation - fn emit_diagnostic(&mut self, db: &DiagnosticBuilder<'_>) { + fn emit_diagnostic(&mut self, db: &Diagnostic) { let mut children = db.children.clone(); let (mut primary_span, suggestions) = self.primary_span_formatted(&db); @@ -37,7 +39,7 @@ impl Emitter for AnnotateSnippetEmitterWriter { &mut primary_span, &mut children, &db.level, - db.handler().flags.external_macro_backtrace); + self.external_macro_backtrace); self.emit_messages_default(&db.level, db.message(), @@ -163,12 +165,14 @@ impl<'a> DiagnosticConverter<'a> { impl AnnotateSnippetEmitterWriter { pub fn new( source_map: Option>, - short_message: bool + short_message: bool, + external_macro_backtrace: bool, ) -> Self { Self { source_map, short_message, ui_testing: false, + external_macro_backtrace, } } diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 66608361c8d44..c5274c7e99a51 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -12,7 +12,7 @@ use Destination::*; use syntax_pos::{SourceFile, Span, MultiSpan}; use crate::{ - Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic, + Level, CodeSuggestion, Diagnostic, SubDiagnostic, SuggestionStyle, SourceMapperDyn, DiagnosticId, }; use crate::Level::Error; @@ -52,10 +52,12 @@ impl HumanReadableErrorType { source_map: Option>, teach: bool, terminal_width: Option, + external_macro_backtrace: bool, ) -> EmitterWriter { let (short, color_config) = self.unzip(); let color = color_config.suggests_using_colors(); - EmitterWriter::new(dst, source_map, short, teach, color, terminal_width) + EmitterWriter::new(dst, source_map, short, teach, color, terminal_width, + external_macro_backtrace) } } @@ -180,7 +182,7 @@ const ANONYMIZED_LINE_NUM: &str = "LL"; /// Emitter trait for emitting errors. pub trait Emitter { /// Emit a structured diagnostic. - fn emit_diagnostic(&mut self, db: &DiagnosticBuilder<'_>); + fn emit_diagnostic(&mut self, db: &Diagnostic); /// Emit a notification that an artifact has been output. /// This is currently only supported for the JSON format, @@ -204,7 +206,7 @@ pub trait Emitter { /// we return the original `primary_span` and the original suggestions. fn primary_span_formatted<'a>( &mut self, - db: &'a DiagnosticBuilder<'_> + db: &'a Diagnostic ) -> (MultiSpan, &'a [CodeSuggestion]) { let mut primary_span = db.span.clone(); if let Some((sugg, rest)) = db.suggestions.split_first() { @@ -377,7 +379,7 @@ pub trait Emitter { } impl Emitter for EmitterWriter { - fn emit_diagnostic(&mut self, db: &DiagnosticBuilder<'_>) { + fn emit_diagnostic(&mut self, db: &Diagnostic) { let mut children = db.children.clone(); let (mut primary_span, suggestions) = self.primary_span_formatted(&db); @@ -385,7 +387,7 @@ impl Emitter for EmitterWriter { &mut primary_span, &mut children, &db.level, - db.handler().flags.external_macro_backtrace); + self.external_macro_backtrace); self.emit_messages_default(&db.level, &db.styled_message(), @@ -449,6 +451,8 @@ pub struct EmitterWriter { teach: bool, ui_testing: bool, terminal_width: Option, + + external_macro_backtrace: bool, } #[derive(Debug)] @@ -465,6 +469,7 @@ impl EmitterWriter { short_message: bool, teach: bool, terminal_width: Option, + external_macro_backtrace: bool, ) -> EmitterWriter { let dst = Destination::from_stderr(color_config); EmitterWriter { @@ -474,6 +479,7 @@ impl EmitterWriter { teach, ui_testing: false, terminal_width, + external_macro_backtrace, } } @@ -484,6 +490,7 @@ impl EmitterWriter { teach: bool, colored: bool, terminal_width: Option, + external_macro_backtrace: bool, ) -> EmitterWriter { EmitterWriter { dst: Raw(dst, colored), @@ -492,6 +499,7 @@ impl EmitterWriter { teach, ui_testing: false, terminal_width, + external_macro_backtrace, } } diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index c1fba416d6433..4ff18578bca6a 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -383,7 +383,8 @@ impl Handler { cm: Option>, flags: HandlerFlags) -> Handler { - let emitter = Box::new(EmitterWriter::stderr(color_config, cm, false, false, None)); + let emitter = Box::new(EmitterWriter::stderr( + color_config, cm, false, false, None, flags.external_macro_backtrace)); Handler::with_emitter_and_flags(emitter, flags) } diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 57b016a08c2fe..010e4cf6cd0d5 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -193,6 +193,7 @@ pub fn new_handler(error_format: ErrorOutputType, short, sessopts.debugging_opts.teach, sessopts.debugging_opts.terminal_width, + false, ).ui_testing(ui_testing) ) }, @@ -205,6 +206,7 @@ pub fn new_handler(error_format: ErrorOutputType, source_map, pretty, json_rendered, + false, ).ui_testing(ui_testing) ) }, diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 482c69c1ab5b5..424239c998237 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -401,7 +401,7 @@ pub fn make_test(s: &str, // Any errors in parsing should also appear when the doctest is compiled for real, so just // send all the errors that libsyntax emits directly into a `Sink` instead of stderr. let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); - let emitter = EmitterWriter::new(box io::sink(), None, false, false, false, None); + let emitter = EmitterWriter::new(box io::sink(), None, false, false, false, None, false); // FIXME(misdreavus): pass `-Z treat-err-as-bug` to the doctest parser let handler = Handler::with_emitter(false, None, box emitter); let sess = ParseSess::with_span_handler(handler, cm); diff --git a/src/libsyntax/json.rs b/src/libsyntax/json.rs index ada46f7bc5a74..5cdea3aabbe11 100644 --- a/src/libsyntax/json.rs +++ b/src/libsyntax/json.rs @@ -12,7 +12,7 @@ use crate::source_map::{SourceMap, FilePathMapping}; use errors::registry::Registry; -use errors::{DiagnosticBuilder, SubDiagnostic, CodeSuggestion, SourceMapper}; +use errors::{SubDiagnostic, CodeSuggestion, SourceMapper}; use errors::{DiagnosticId, Applicability}; use errors::emitter::{Emitter, HumanReadableErrorType}; @@ -32,6 +32,7 @@ pub struct JsonEmitter { pretty: bool, ui_testing: bool, json_rendered: HumanReadableErrorType, + external_macro_backtrace: bool, } impl JsonEmitter { @@ -40,6 +41,7 @@ impl JsonEmitter { source_map: Lrc, pretty: bool, json_rendered: HumanReadableErrorType, + external_macro_backtrace: bool, ) -> JsonEmitter { JsonEmitter { dst: Box::new(io::stderr()), @@ -48,13 +50,18 @@ impl JsonEmitter { pretty, ui_testing: false, json_rendered, + external_macro_backtrace, } } - pub fn basic(pretty: bool, json_rendered: HumanReadableErrorType) -> JsonEmitter { + pub fn basic( + pretty: bool, + json_rendered: HumanReadableErrorType, + external_macro_backtrace: bool, + ) -> JsonEmitter { let file_path_mapping = FilePathMapping::empty(); JsonEmitter::stderr(None, Lrc::new(SourceMap::new(file_path_mapping)), - pretty, json_rendered) + pretty, json_rendered, external_macro_backtrace) } pub fn new( @@ -63,6 +70,7 @@ impl JsonEmitter { source_map: Lrc, pretty: bool, json_rendered: HumanReadableErrorType, + external_macro_backtrace: bool, ) -> JsonEmitter { JsonEmitter { dst, @@ -71,6 +79,7 @@ impl JsonEmitter { pretty, ui_testing: false, json_rendered, + external_macro_backtrace, } } @@ -80,8 +89,8 @@ impl JsonEmitter { } impl Emitter for JsonEmitter { - fn emit_diagnostic(&mut self, db: &DiagnosticBuilder<'_>) { - let data = Diagnostic::from_diagnostic_builder(db, self); + fn emit_diagnostic(&mut self, db: &errors::Diagnostic) { + let data = Diagnostic::from_errors_diagnostic(db, self); let result = if self.pretty { writeln!(&mut self.dst, "{}", as_pretty_json(&data)) } else { @@ -189,7 +198,7 @@ struct ArtifactNotification<'a> { } impl Diagnostic { - fn from_diagnostic_builder(db: &DiagnosticBuilder<'_>, + fn from_errors_diagnostic(db: &errors::Diagnostic, je: &JsonEmitter) -> Diagnostic { let sugg = db.suggestions.iter().map(|sugg| { @@ -219,8 +228,9 @@ impl Diagnostic { } let buf = BufWriter::default(); let output = buf.clone(); - je.json_rendered.new_emitter(Box::new(buf), Some(je.sm.clone()), false, None) - .ui_testing(je.ui_testing).emit_diagnostic(db); + je.json_rendered.new_emitter( + Box::new(buf), Some(je.sm.clone()), false, None, je.external_macro_backtrace + ).ui_testing(je.ui_testing).emit_diagnostic(db); let output = Arc::try_unwrap(output.0).unwrap().into_inner().unwrap(); let output = String::from_utf8(output).unwrap(); diff --git a/src/libsyntax/parse/lexer/tests.rs b/src/libsyntax/parse/lexer/tests.rs index c1ec41902e2be..de301b1fc499d 100644 --- a/src/libsyntax/parse/lexer/tests.rs +++ b/src/libsyntax/parse/lexer/tests.rs @@ -18,6 +18,7 @@ fn mk_sess(sm: Lrc) -> ParseSess { false, false, None, + false, ); ParseSess::with_span_handler(Handler::with_emitter(true, None, Box::new(emitter)), sm) } diff --git a/src/libsyntax/tests.rs b/src/libsyntax/tests.rs index 540881b0a5496..f510ac9273d09 100644 --- a/src/libsyntax/tests.rs +++ b/src/libsyntax/tests.rs @@ -147,6 +147,7 @@ fn test_harness(file_text: &str, span_labels: Vec, expected_output: & false, false, None, + false, ); let handler = Handler::with_emitter(true, None, Box::new(emitter)); handler.span_err(msp, "foo"); From 0b586b436d6ea2dddc213c18bf17f2314441c32f Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 7 Sep 2019 10:03:15 -0400 Subject: [PATCH 09/63] Take Diagnostic in Handler::emit_diagnostic --- src/librustc/session/config.rs | 2 +- src/librustc_errors/diagnostic_builder.rs | 10 +--------- src/librustc_errors/lib.rs | 14 ++++++++------ 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 723855c7c29cf..5eda3df378126 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1855,7 +1855,7 @@ pub fn rustc_optgroups() -> Vec { struct NullEmitter; impl errors::emitter::Emitter for NullEmitter { - fn emit_diagnostic(&mut self, _: &errors::DiagnosticBuilder<'_>) {} + fn emit_diagnostic(&mut self, _: &errors::Diagnostic) {} } // Converts strings provided as `--cfg [cfgspec]` into a `crate_cfg`. diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs index 7b8902f125aee..25ffb146da756 100644 --- a/src/librustc_errors/diagnostic_builder.rs +++ b/src/librustc_errors/diagnostic_builder.rs @@ -99,17 +99,9 @@ impl<'a> DerefMut for DiagnosticBuilder<'a> { } impl<'a> DiagnosticBuilder<'a> { - pub fn handler(&self) -> &'a Handler{ - self.0.handler - } - /// Emit the diagnostic. pub fn emit(&mut self) { - if self.cancelled() { - return; - } - - self.0.handler.emit_db(&self); + self.0.handler.emit_diagnostic(&self); self.cancel(); } diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 4ff18578bca6a..11e2265cf3618 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -589,7 +589,7 @@ impl Handler { } fn delay_as_bug(&self, diagnostic: Diagnostic) { if self.flags.report_delayed_bugs { - DiagnosticBuilder::new_diagnostic(self, diagnostic.clone()).emit(); + self.emit_diagnostic(&diagnostic); } self.delayed_span_bugs.borrow_mut().push(diagnostic); } @@ -747,8 +747,10 @@ impl Handler { db.cancel(); } - fn emit_db(&self, db: &DiagnosticBuilder<'_>) { - let diagnostic = &**db; + fn emit_diagnostic(&self, diagnostic: &Diagnostic) { + if diagnostic.cancelled() { + return; + } TRACK_DIAGNOSTICS.with(|track_diagnostics| { track_diagnostics.get()(diagnostic); @@ -768,12 +770,12 @@ impl Handler { // Only emit the diagnostic if we haven't already emitted an equivalent // one: if self.emitted_diagnostics.borrow_mut().insert(diagnostic_hash) { - self.emitter.borrow_mut().emit_diagnostic(db); - if db.is_error() { + self.emitter.borrow_mut().emit_diagnostic(diagnostic); + if diagnostic.is_error() { self.deduplicated_err_count.fetch_add(1, SeqCst); } } - if db.is_error() { + if diagnostic.is_error() { self.bump_err_count(); } } From 2a3930d43ced5204f53a6e1eebd741a81c4c1e9a Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 7 Sep 2019 10:20:56 -0400 Subject: [PATCH 10/63] Privatize DiagnosticBuilder constructors --- src/librustc/dep_graph/graph.rs | 4 ++-- src/librustc/ty/query/plumbing.rs | 7 +++---- src/librustc_errors/diagnostic_builder.rs | 5 +++-- src/librustc_errors/lib.rs | 5 ++--- src/librustc_mir/borrow_check/mod.rs | 2 +- src/librustc_typeck/check/writeback.rs | 3 +-- src/libsyntax/ext/proc_macro_server.rs | 4 ++-- src/libsyntax/lib.rs | 4 ++-- src/libsyntax/parse/mod.rs | 2 +- 9 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index 7eea336cbbfa1..e76a70350b33e 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -1,4 +1,4 @@ -use errors::{Diagnostic, DiagnosticBuilder}; +use errors::Diagnostic; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; @@ -819,7 +819,7 @@ impl DepGraph { let handle = tcx.sess.diagnostic(); for diagnostic in diagnostics { - DiagnosticBuilder::new_diagnostic(handle, diagnostic).emit(); + handle.emit_diagnostic(&diagnostic); } // Mark the node as green now that diagnostics are emitted diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index d199a26475be7..a1828bb5ab7a7 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -330,14 +330,13 @@ impl<'tcx> TyCtxt<'tcx> { let mut i = 0; while let Some(query) = current_query { - let mut db = DiagnosticBuilder::new(icx.tcx.sess.diagnostic(), - Level::FailureNote, + let mut diag = Diagnostic::new(Level::FailureNote, &format!("#{} [{}] {}", i, query.info.query.name(), query.info.query.describe(icx.tcx))); - db.set_span(icx.tcx.sess.source_map().def_span(query.info.span)); - icx.tcx.sess.diagnostic().force_print_db(db); + diag.span = icx.tcx.sess.source_map().def_span(query.info.span).into(); + icx.tcx.sess.diagnostic().force_print_diagnostic(diag); current_query = query.parent.clone(); i += 1; diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs index 25ffb146da756..e85388bfea29c 100644 --- a/src/librustc_errors/diagnostic_builder.rs +++ b/src/librustc_errors/diagnostic_builder.rs @@ -346,7 +346,7 @@ impl<'a> DiagnosticBuilder<'a> { /// Convenience function for internal use, clients should use one of the /// struct_* methods on Handler. - pub fn new(handler: &'a Handler, level: Level, message: &str) -> DiagnosticBuilder<'a> { + crate fn new(handler: &'a Handler, level: Level, message: &str) -> DiagnosticBuilder<'a> { DiagnosticBuilder::new_with_code(handler, level, None, message) } @@ -363,7 +363,8 @@ impl<'a> DiagnosticBuilder<'a> { /// Creates a new `DiagnosticBuilder` with an already constructed /// diagnostic. - pub fn new_diagnostic(handler: &'a Handler, diagnostic: Diagnostic) -> DiagnosticBuilder<'a> { + crate fn new_diagnostic(handler: &'a Handler, diagnostic: Diagnostic) + -> DiagnosticBuilder<'a> { DiagnosticBuilder(Box::new(DiagnosticBuilderInner { handler, diagnostic, diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 11e2265cf3618..51309f37e174f 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -742,12 +742,11 @@ impl Handler { self.taught_diagnostics.borrow_mut().insert(code.clone()) } - pub fn force_print_db(&self, mut db: DiagnosticBuilder<'_>) { + pub fn force_print_diagnostic(&self, db: Diagnostic) { self.emitter.borrow_mut().emit_diagnostic(&db); - db.cancel(); } - fn emit_diagnostic(&self, diagnostic: &Diagnostic) { + pub fn emit_diagnostic(&self, diagnostic: &Diagnostic) { if diagnostic.cancelled() { return; } diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 1d3576244c4af..32c6dd67a4b5a 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -402,7 +402,7 @@ fn do_mir_borrowck<'a, 'tcx>( } for diag in mbcx.errors_buffer.drain(..) { - DiagnosticBuilder::new_diagnostic(mbcx.infcx.tcx.sess.diagnostic(), diag).emit(); + mbcx.infcx.tcx.sess.diagnostic().emit_diagnostic(&diag); } } diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 487dc8ec2ae0c..1cc71ea5649de 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -3,7 +3,6 @@ // substitutions. use crate::check::FnCtxt; -use errors::DiagnosticBuilder; use rustc::hir; use rustc::hir::def_id::{DefId, DefIndex}; use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; @@ -407,7 +406,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { if !errors_buffer.is_empty() { errors_buffer.sort_by_key(|diag| diag.span.primary_span()); for diag in errors_buffer.drain(..) { - DiagnosticBuilder::new_diagnostic(self.tcx().sess.diagnostic(), diag).emit(); + self.tcx().sess.diagnostic().emit_diagnostic(&diag); } } } diff --git a/src/libsyntax/ext/proc_macro_server.rs b/src/libsyntax/ext/proc_macro_server.rs index 544ec789d80a9..dfec9ee28809a 100644 --- a/src/libsyntax/ext/proc_macro_server.rs +++ b/src/libsyntax/ext/proc_macro_server.rs @@ -4,7 +4,7 @@ use crate::parse::{self, token, ParseSess}; use crate::parse::lexer::comments; use crate::tokenstream::{self, DelimSpan, IsJoint::*, TokenStream, TreeAndJoint}; -use errors::{Diagnostic, DiagnosticBuilder}; +use errors::Diagnostic; use rustc_data_structures::sync::Lrc; use syntax_pos::{BytePos, FileName, MultiSpan, Pos, SourceFile, Span}; use syntax_pos::symbol::{kw, sym, Symbol}; @@ -650,7 +650,7 @@ impl server::Diagnostic for Rustc<'_> { diag.sub(level.to_internal(), msg, MultiSpan::from_spans(spans), None); } fn emit(&mut self, diag: Self::Diagnostic) { - DiagnosticBuilder::new_diagnostic(&self.sess.span_diagnostic, diag).emit() + self.sess.span_diagnostic.emit_diagnostic(&diag); } } diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index aaf6f3e537eb6..b4ae1e87bca28 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -60,12 +60,12 @@ macro_rules! panictry { macro_rules! panictry_buffer { ($handler:expr, $e:expr) => ({ use std::result::Result::{Ok, Err}; - use errors::{FatalError, DiagnosticBuilder}; + use errors::FatalError; match $e { Ok(e) => e, Err(errs) => { for e in errs { - DiagnosticBuilder::new_diagnostic($handler, e).emit(); + $handler.emit_diagnostic(&e); } FatalError.raise() } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 2441a027f9940..c4f31bcd9b041 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -306,7 +306,7 @@ fn file_to_source_file(sess: &ParseSess, path: &Path, spanopt: Option) match try_file_to_source_file(sess, path, spanopt) { Ok(source_file) => source_file, Err(d) => { - DiagnosticBuilder::new_diagnostic(&sess.span_diagnostic, d).emit(); + sess.span_diagnostic.emit_diagnostic(&d); FatalError.raise(); } } From 998df0d70b0c837d52a1c8100773409390df840c Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 7 Sep 2019 10:38:02 -0400 Subject: [PATCH 11/63] Remove Handler::cancel --- src/librustc/infer/error_reporting/mod.rs | 2 +- src/librustc_errors/lib.rs | 4 ---- src/libsyntax/parse/attr.rs | 4 ++-- src/libsyntax/parse/diagnostics.rs | 8 +------- src/libsyntax/parse/parser/expr.rs | 2 +- src/libsyntax/parse/parser/pat.rs | 2 +- src/libsyntax/parse/parser/stmt.rs | 2 +- 7 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index ab24b3f2f059f..0b6740d7bbbc8 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -1119,7 +1119,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { Some((expected, found)) => Some((expected, found)), None => { // Derived error. Cancel the emitter. - self.tcx.sess.diagnostic().cancel(diag); + diag.cancel(); return; } }; diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 51309f37e174f..47ac2e5a667d5 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -520,10 +520,6 @@ impl Handler { DiagnosticBuilder::new(self, Level::Fatal, msg) } - pub fn cancel(&self, err: &mut DiagnosticBuilder<'_>) { - err.cancel(); - } - fn panic_if_treat_err_as_bug(&self) { if self.treat_err_as_bug() { let s = match (self.err_count(), self.flags.treat_err_as_bug.unwrap_or(0)) { diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index 9aa1ec0b14fe9..9fbed66854c64 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -309,14 +309,14 @@ impl<'a> Parser<'a> { Ok(lit) => { return Ok(ast::NestedMetaItem::Literal(lit)) } - Err(ref mut err) => self.diagnostic().cancel(err) + Err(ref mut err) => err.cancel(), } match self.parse_meta_item() { Ok(mi) => { return Ok(ast::NestedMetaItem::MetaItem(mi)) } - Err(ref mut err) => self.diagnostic().cancel(err) + Err(ref mut err) => err.cancel(), } let found = self.this_token_to_string(); diff --git a/src/libsyntax/parse/diagnostics.rs b/src/libsyntax/parse/diagnostics.rs index b74f2492c351f..1e7058ff71563 100644 --- a/src/libsyntax/parse/diagnostics.rs +++ b/src/libsyntax/parse/diagnostics.rs @@ -197,10 +197,6 @@ impl<'a> Parser<'a> { self.sess.span_diagnostic.span_bug(sp, m) } - crate fn cancel(&self, err: &mut DiagnosticBuilder<'_>) { - self.sess.span_diagnostic.cancel(err) - } - crate fn diagnostic(&self) -> &'a errors::Handler { &self.sess.span_diagnostic } @@ -426,15 +422,13 @@ impl<'a> Parser<'a> { /// Eats and discards tokens until one of `kets` is encountered. Respects token trees, /// passes through any errors encountered. Used for error recovery. crate fn eat_to_tokens(&mut self, kets: &[&TokenKind]) { - let handler = self.diagnostic(); - if let Err(ref mut err) = self.parse_seq_to_before_tokens( kets, SeqSep::none(), TokenExpectType::Expect, |p| Ok(p.parse_token_tree()), ) { - handler.cancel(err); + err.cancel(); } } diff --git a/src/libsyntax/parse/parser/expr.rs b/src/libsyntax/parse/parser/expr.rs index 31b28443abbc3..5764934b3cd16 100644 --- a/src/libsyntax/parse/parser/expr.rs +++ b/src/libsyntax/parse/parser/expr.rs @@ -770,7 +770,7 @@ impl<'a> Parser<'a> { ex = ExprKind::Lit(literal); } Err(mut err) => { - self.cancel(&mut err); + err.cancel(); return Err(self.expected_expression_found()); } } diff --git a/src/libsyntax/parse/parser/pat.rs b/src/libsyntax/parse/parser/pat.rs index 08ee3a6bd86d4..3c624959eadb1 100644 --- a/src/libsyntax/parse/parser/pat.rs +++ b/src/libsyntax/parse/parser/pat.rs @@ -537,7 +537,7 @@ impl<'a> Parser<'a> { mut err: DiagnosticBuilder<'a>, expected: Expected, ) -> PResult<'a, P> { - self.cancel(&mut err); + err.cancel(); let expected = expected.unwrap_or("pattern"); let msg = format!("expected {}, found {}", expected, self.this_token_descr()); diff --git a/src/libsyntax/parse/parser/stmt.rs b/src/libsyntax/parse/parser/stmt.rs index 04bd61a4cfb5b..02da56f6e35a7 100644 --- a/src/libsyntax/parse/parser/stmt.rs +++ b/src/libsyntax/parse/parser/stmt.rs @@ -361,7 +361,7 @@ impl<'a> Parser<'a> { } Err(mut e) => { self.recover_stmt_(SemiColonMode::Break, BlockMode::Ignore); - self.cancel(&mut e); + e.cancel(); } _ => () } From b304e60131a081930382a6bf327aa11c6432698c Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 7 Sep 2019 11:21:17 -0400 Subject: [PATCH 12/63] Remove Handler::{emit, emit_with_code} --- src/librustc/session/mod.rs | 4 +- src/librustc_codegen_ssa/back/write.rs | 18 +++----- src/librustc_driver/lib.rs | 12 +++--- src/librustc_errors/lib.rs | 59 ++++++++++++-------------- 4 files changed, 40 insertions(+), 53 deletions(-) diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index af9cb5a0941e5..afaea54006018 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -1394,7 +1394,7 @@ pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! { Box::new(JsonEmitter::basic(pretty, json_rendered, false)), }; let handler = errors::Handler::with_emitter(true, None, emitter); - handler.emit(&MultiSpan::new(), msg, errors::Level::Fatal); + handler.struct_fatal(msg).emit(); errors::FatalError.raise(); } @@ -1408,7 +1408,7 @@ pub fn early_warn(output: config::ErrorOutputType, msg: &str) { Box::new(JsonEmitter::basic(pretty, json_rendered, false)), }; let handler = errors::Handler::with_emitter(true, None, emitter); - handler.emit(&MultiSpan::new(), msg, errors::Level::Warning); + handler.struct_warn(msg).emit(); } pub type CompileResult = Result<(), ErrorReported>; diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs index 38a0818d290bd..1bba479c1fd5d 100644 --- a/src/librustc_codegen_ssa/back/write.rs +++ b/src/librustc_codegen_ssa/back/write.rs @@ -27,7 +27,6 @@ use rustc_errors::emitter::{Emitter}; use rustc_target::spec::MergeFunctions; use syntax::attr; use syntax::ext::hygiene::ExpnId; -use syntax_pos::MultiSpan; use syntax_pos::symbol::{Symbol, sym}; use jobserver::{Client, Acquired}; @@ -1760,19 +1759,12 @@ impl SharedEmitterMain { match message { Ok(SharedEmitterMessage::Diagnostic(diag)) => { let handler = sess.diagnostic(); - match diag.code { - Some(ref code) => { - handler.emit_with_code(&MultiSpan::new(), - &diag.msg, - code.clone(), - diag.lvl); - } - None => { - handler.emit(&MultiSpan::new(), - &diag.msg, - diag.lvl); - } + let mut d = rustc_errors::Diagnostic::new(diag.lvl, &diag.msg); + if let Some(code) = diag.code { + d.code(code); } + handler.emit_diagnostic(&d); + handler.abort_if_errors_and_should_abort(); } Ok(SharedEmitterMessage::InlineAsmError(cookie, msg)) => { sess.span_err(ExpnId::from_u32(cookie).expn_data().call_site, &msg) diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 3a09f459e9c1f..f99e65b4494a7 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -66,7 +66,7 @@ use syntax::source_map::FileLoader; use syntax::feature_gate::{GatedCfg, UnstableFeatures}; use syntax::parse::{self, PResult}; use syntax::symbol::sym; -use syntax_pos::{DUMMY_SP, MultiSpan, FileName}; +use syntax_pos::{DUMMY_SP, FileName}; pub mod pretty; mod args; @@ -1203,9 +1203,9 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) { // a .span_bug or .bug call has already printed what // it wants to print. if !info.payload().is::() { - handler.emit(&MultiSpan::new(), - "unexpected panic", - errors::Level::Bug); + let d = errors::Diagnostic::new(errors::Level::Bug, "unexpected panic"); + handler.emit_diagnostic(&d); + handler.abort_if_errors_and_should_abort(); } let mut xs: Vec> = vec![ @@ -1225,9 +1225,7 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) { } for note in &xs { - handler.emit(&MultiSpan::new(), - note, - errors::Level::Note); + handler.note_without_error(¬e); } // If backtraces are enabled, also print the query stack diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 47ac2e5a667d5..b74a6035032fa 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -539,7 +539,8 @@ impl Handler { } pub fn span_fatal>(&self, sp: S, msg: &str) -> FatalError { - self.emit(&sp.into(), msg, Fatal); + self.emit_diagnostic(Diagnostic::new(Fatal, msg).set_span(sp)); + self.abort_if_errors_and_should_abort(); FatalError } pub fn span_fatal_with_code>(&self, @@ -547,11 +548,13 @@ impl Handler { msg: &str, code: DiagnosticId) -> FatalError { - self.emit_with_code(&sp.into(), msg, code, Fatal); + self.emit_diagnostic(Diagnostic::new_with_code(Fatal, Some(code), msg).set_span(sp)); + self.abort_if_errors_and_should_abort(); FatalError } pub fn span_err>(&self, sp: S, msg: &str) { - self.emit(&sp.into(), msg, Error); + self.emit_diagnostic(Diagnostic::new(Error, msg).set_span(sp)); + self.abort_if_errors_and_should_abort(); } pub fn mut_span_err>(&self, sp: S, @@ -562,16 +565,20 @@ impl Handler { result } pub fn span_err_with_code>(&self, sp: S, msg: &str, code: DiagnosticId) { - self.emit_with_code(&sp.into(), msg, code, Error); + self.emit_diagnostic(Diagnostic::new_with_code(Error, Some(code), msg).set_span(sp)); + self.abort_if_errors_and_should_abort(); } pub fn span_warn>(&self, sp: S, msg: &str) { - self.emit(&sp.into(), msg, Warning); + self.emit_diagnostic(Diagnostic::new(Warning, msg).set_span(sp)); + self.abort_if_errors_and_should_abort(); } pub fn span_warn_with_code>(&self, sp: S, msg: &str, code: DiagnosticId) { - self.emit_with_code(&sp.into(), msg, code, Warning); + self.emit_diagnostic(Diagnostic::new_with_code(Warning, Some(code), msg).set_span(sp)); + self.abort_if_errors_and_should_abort(); } pub fn span_bug>(&self, sp: S, msg: &str) -> ! { - self.emit(&sp.into(), msg, Bug); + self.emit_diagnostic(Diagnostic::new(Bug, msg).set_span(sp)); + self.abort_if_errors_and_should_abort(); panic!(ExplicitBug); } pub fn delay_span_bug>(&self, sp: S, msg: &str) { @@ -590,10 +597,12 @@ impl Handler { self.delayed_span_bugs.borrow_mut().push(diagnostic); } pub fn span_bug_no_panic>(&self, sp: S, msg: &str) { - self.emit(&sp.into(), msg, Bug); + self.emit_diagnostic(Diagnostic::new(Bug, msg).set_span(sp)); + self.abort_if_errors_and_should_abort(); } pub fn span_note_without_error>(&self, sp: S, msg: &str) { - self.emit(&sp.into(), msg, Note); + self.emit_diagnostic(Diagnostic::new(Note, msg).set_span(sp)); + self.abort_if_errors_and_should_abort(); } pub fn span_note_diag(&self, sp: Span, @@ -701,31 +710,15 @@ impl Handler { } } - pub fn abort_if_errors(&self) { - if self.has_errors() { + pub fn abort_if_errors_and_should_abort(&self) { + if self.has_errors() && !self.continue_after_error.load(SeqCst) { FatalError.raise(); } } - pub fn emit(&self, msp: &MultiSpan, msg: &str, lvl: Level) { - if lvl == Warning && !self.flags.can_emit_warnings { - return; - } - let mut db = DiagnosticBuilder::new(self, lvl, msg); - db.set_span(msp.clone()); - db.emit(); - if !self.continue_after_error.load(SeqCst) { - self.abort_if_errors(); - } - } - pub fn emit_with_code(&self, msp: &MultiSpan, msg: &str, code: DiagnosticId, lvl: Level) { - if lvl == Warning && !self.flags.can_emit_warnings { - return; - } - let mut db = DiagnosticBuilder::new_with_code(self, lvl, Some(code), msg); - db.set_span(msp.clone()); - db.emit(); - if !self.continue_after_error.load(SeqCst) { - self.abort_if_errors(); + + pub fn abort_if_errors(&self) { + if self.has_errors() { + FatalError.raise(); } } @@ -747,6 +740,10 @@ impl Handler { return; } + if diagnostic.level == Warning && !self.flags.can_emit_warnings { + return; + } + TRACK_DIAGNOSTICS.with(|track_diagnostics| { track_diagnostics.get()(diagnostic); }); From 2a767eec0cae5aedb197d8fb823df67d93257fbd Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 7 Sep 2019 11:26:32 -0400 Subject: [PATCH 13/63] Remove unused methods from Handler --- src/librustc/session/mod.rs | 6 ------ src/librustc_errors/lib.rs | 6 ------ src/libsyntax/ext/base.rs | 3 --- 3 files changed, 15 deletions(-) diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index afaea54006018..a24fed8f21c5a 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -365,12 +365,6 @@ impl Session { pub fn span_note_without_error>(&self, sp: S, msg: &str) { self.diagnostic().span_note_without_error(sp, msg) } - pub fn span_unimpl>(&self, sp: S, msg: &str) -> ! { - self.diagnostic().span_unimpl(sp, msg) - } - pub fn unimpl(&self, msg: &str) -> ! { - self.diagnostic().unimpl(msg) - } pub fn buffer_lint>( &self, diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index b74a6035032fa..bd57cc41ef335 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -612,9 +612,6 @@ impl Handler { db.set_span(sp); db } - pub fn span_unimpl>(&self, sp: S, msg: &str) -> ! { - self.span_bug(sp, &format!("unimplemented {}", msg)); - } pub fn failure(&self, msg: &str) { DiagnosticBuilder::new(self, FailureNote, msg).emit() } @@ -648,9 +645,6 @@ impl Handler { db.emit(); panic!(ExplicitBug); } - pub fn unimpl(&self, msg: &str) -> ! { - self.bug(&format!("unimplemented {}", msg)); - } fn bump_err_count(&self) { self.err_count.fetch_add(1, SeqCst); diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 384c0555c85bd..a6be5b101788e 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -1048,9 +1048,6 @@ impl<'a> ExtCtxt<'a> { pub fn span_warn>(&self, sp: S, msg: &str) { self.parse_sess.span_diagnostic.span_warn(sp, msg); } - pub fn span_unimpl>(&self, sp: S, msg: &str) -> ! { - self.parse_sess.span_diagnostic.span_unimpl(sp, msg); - } pub fn span_bug>(&self, sp: S, msg: &str) -> ! { self.parse_sess.span_diagnostic.span_bug(sp, msg); } From 4cc5aaada2f8ffd444a7fbb10394b83ba3156525 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 7 Sep 2019 12:09:52 -0400 Subject: [PATCH 14/63] Protect error handler fields with single lock This avoids concurrency-related bugs when locks are acquired for too short a time and similar cases. --- src/librustc/session/config/tests.rs | 6 +- src/librustc_errors/lib.rs | 336 ++++++++++++++++----------- 2 files changed, 207 insertions(+), 135 deletions(-) diff --git a/src/librustc/session/config/tests.rs b/src/librustc/session/config/tests.rs index 3d6312548a47b..9eb68056bfd97 100644 --- a/src/librustc/session/config/tests.rs +++ b/src/librustc/session/config/tests.rs @@ -87,7 +87,7 @@ fn test_can_print_warnings() { let registry = errors::registry::Registry::new(&[]); let (sessopts, _) = build_session_options_and_crate_config(&matches); let sess = build_session(sessopts, None, registry); - assert!(!sess.diagnostic().flags.can_emit_warnings); + assert!(!sess.diagnostic().can_emit_warnings()); }); syntax::with_default_globals(|| { @@ -97,7 +97,7 @@ fn test_can_print_warnings() { let registry = errors::registry::Registry::new(&[]); let (sessopts, _) = build_session_options_and_crate_config(&matches); let sess = build_session(sessopts, None, registry); - assert!(sess.diagnostic().flags.can_emit_warnings); + assert!(sess.diagnostic().can_emit_warnings()); }); syntax::with_default_globals(|| { @@ -105,7 +105,7 @@ fn test_can_print_warnings() { let registry = errors::registry::Registry::new(&[]); let (sessopts, _) = build_session_options_and_crate_config(&matches); let sess = build_session(sessopts, None, registry); - assert!(sess.diagnostic().flags.can_emit_warnings); + assert!(sess.diagnostic().can_emit_warnings()); }); } diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index bd57cc41ef335..a1a63664a4be3 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -16,7 +16,7 @@ use Level::*; use emitter::{Emitter, EmitterWriter}; use registry::Registry; -use rustc_data_structures::sync::{self, Lrc, Lock, AtomicUsize, AtomicBool, SeqCst}; +use rustc_data_structures::sync::{self, Lrc, Lock}; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::stable_hasher::StableHasher; @@ -298,30 +298,34 @@ pub use diagnostic_builder::DiagnosticBuilder; /// Certain errors (fatal, bug, unimpl) may cause immediate exit, /// others log errors for later reporting. pub struct Handler { - pub flags: HandlerFlags, + flags: HandlerFlags, + inner: Lock, +} +struct HandlerInner { + flags: HandlerFlags, /// The number of errors that have been emitted, including duplicates. /// /// This is not necessarily the count that's reported to the user once /// compilation ends. - err_count: AtomicUsize, - deduplicated_err_count: AtomicUsize, - emitter: Lock>, - continue_after_error: AtomicBool, - delayed_span_bugs: Lock>, + err_count: usize, + deduplicated_err_count: usize, + emitter: Box, + continue_after_error: bool, + delayed_span_bugs: Vec, /// This set contains the `DiagnosticId` of all emitted diagnostics to avoid /// emitting the same diagnostic with extended help (`--teach`) twice, which /// would be uneccessary repetition. - taught_diagnostics: Lock>, + taught_diagnostics: FxHashSet, /// Used to suggest rustc --explain - emitted_diagnostic_codes: Lock>, + emitted_diagnostic_codes: FxHashSet, /// This set contains a hash of every diagnostic that has been emitted by /// this handler. These hashes is used to avoid emitting the same error /// twice. - emitted_diagnostics: Lock>, + emitted_diagnostics: FxHashSet, } fn default_track_diagnostic(_: &Diagnostic) {} @@ -329,7 +333,7 @@ fn default_track_diagnostic(_: &Diagnostic) {} thread_local!(pub static TRACK_DIAGNOSTICS: Cell = Cell::new(default_track_diagnostic)); -#[derive(Default)] +#[derive(Copy, Clone, Default)] pub struct HandlerFlags { /// If false, warning-level lints are suppressed. /// (rustc: see `--allow warnings` and `--cap-lints`) @@ -348,13 +352,13 @@ pub struct HandlerFlags { pub external_macro_backtrace: bool, } -impl Drop for Handler { +impl Drop for HandlerInner { fn drop(&mut self) { - if !self.has_errors() { - let mut bugs = self.delayed_span_bugs.borrow_mut(); + if self.err_count == 0 { + let bugs = std::mem::replace(&mut self.delayed_span_bugs, Vec::new()); let has_bugs = !bugs.is_empty(); - for bug in bugs.drain(..) { - DiagnosticBuilder::new_diagnostic(self, bug).emit(); + for bug in bugs { + self.emit_diagnostic(&bug); } if has_bugs { panic!("no errors encountered even though `delay_span_bug` issued"); @@ -405,19 +409,28 @@ impl Handler { { Handler { flags, - err_count: AtomicUsize::new(0), - deduplicated_err_count: AtomicUsize::new(0), - emitter: Lock::new(e), - continue_after_error: AtomicBool::new(true), - delayed_span_bugs: Lock::new(Vec::new()), - taught_diagnostics: Default::default(), - emitted_diagnostic_codes: Default::default(), - emitted_diagnostics: Default::default(), + inner: Lock::new(HandlerInner { + flags, + err_count: 0, + deduplicated_err_count: 0, + emitter: e, + continue_after_error: true, + delayed_span_bugs: Vec::new(), + taught_diagnostics: Default::default(), + emitted_diagnostic_codes: Default::default(), + emitted_diagnostics: Default::default(), + }), } } pub fn set_continue_after_error(&self, continue_after_error: bool) { - self.continue_after_error.store(continue_after_error, SeqCst); + self.inner.borrow_mut().continue_after_error = continue_after_error; + } + + // This is here to not allow mutation of flags; + // as of this writing it's only used in tests in librustc. + pub fn can_emit_warnings(&self) -> bool { + self.flags.can_emit_warnings } /// Resets the diagnostic error count as well as the cached emitted diagnostics. @@ -425,11 +438,13 @@ impl Handler { /// NOTE: *do not* call this function from rustc. It is only meant to be called from external /// tools that want to reuse a `Parser` cleaning the previously emitted diagnostics as well as /// the overall count of emitted error diagnostics. + // FIXME: this does not clear inner entirely pub fn reset_err_count(&self) { + let mut inner = self.inner.borrow_mut(); // actually frees the underlying memory (which `clear` would not do) - *self.emitted_diagnostics.borrow_mut() = Default::default(); - self.deduplicated_err_count.store(0, SeqCst); - self.err_count.store(0, SeqCst); + inner.emitted_diagnostics = Default::default(); + inner.deduplicated_err_count = 0; + inner.err_count = 0; } pub fn struct_dummy(&self) -> DiagnosticBuilder<'_> { @@ -520,24 +535,6 @@ impl Handler { DiagnosticBuilder::new(self, Level::Fatal, msg) } - fn panic_if_treat_err_as_bug(&self) { - if self.treat_err_as_bug() { - let s = match (self.err_count(), self.flags.treat_err_as_bug.unwrap_or(0)) { - (0, _) => return, - (1, 1) => "aborting due to `-Z treat-err-as-bug=1`".to_string(), - (1, _) => return, - (count, as_bug) => { - format!( - "aborting after {} errors due to `-Z treat-err-as-bug={}`", - count, - as_bug, - ) - } - }; - panic!(s); - } - } - pub fn span_fatal>(&self, sp: S, msg: &str) -> FatalError { self.emit_diagnostic(Diagnostic::new(Fatal, msg).set_span(sp)); self.abort_if_errors_and_should_abort(); @@ -577,24 +574,10 @@ impl Handler { self.abort_if_errors_and_should_abort(); } pub fn span_bug>(&self, sp: S, msg: &str) -> ! { - self.emit_diagnostic(Diagnostic::new(Bug, msg).set_span(sp)); - self.abort_if_errors_and_should_abort(); - panic!(ExplicitBug); + self.inner.borrow_mut().span_bug(sp, msg) } pub fn delay_span_bug>(&self, sp: S, msg: &str) { - if self.treat_err_as_bug() { - // FIXME: don't abort here if report_delayed_bugs is off - self.span_bug(sp, msg); - } - let mut diagnostic = Diagnostic::new(Level::Bug, msg); - diagnostic.set_span(sp.into()); - self.delay_as_bug(diagnostic); - } - fn delay_as_bug(&self, diagnostic: Diagnostic) { - if self.flags.report_delayed_bugs { - self.emit_diagnostic(&diagnostic); - } - self.delayed_span_bugs.borrow_mut().push(diagnostic); + self.inner.borrow_mut().delay_span_bug(sp, msg) } pub fn span_bug_no_panic>(&self, sp: S, msg: &str) { self.emit_diagnostic(Diagnostic::new(Bug, msg).set_span(sp)); @@ -613,46 +596,28 @@ impl Handler { db } pub fn failure(&self, msg: &str) { - DiagnosticBuilder::new(self, FailureNote, msg).emit() + self.inner.borrow_mut().failure(msg); } pub fn fatal(&self, msg: &str) -> FatalError { - if self.treat_err_as_bug() { - self.bug(msg); - } - DiagnosticBuilder::new(self, Fatal, msg).emit(); - FatalError + self.inner.borrow_mut().fatal(msg) } pub fn err(&self, msg: &str) { - if self.treat_err_as_bug() { - self.bug(msg); - } - let mut db = DiagnosticBuilder::new(self, Error, msg); - db.emit(); + self.inner.borrow_mut().err(msg); } pub fn warn(&self, msg: &str) { let mut db = DiagnosticBuilder::new(self, Warning, msg); db.emit(); } - fn treat_err_as_bug(&self) -> bool { - self.flags.treat_err_as_bug.map(|c| self.err_count() >= c).unwrap_or(false) - } pub fn note_without_error(&self, msg: &str) { let mut db = DiagnosticBuilder::new(self, Note, msg); db.emit(); } pub fn bug(&self, msg: &str) -> ! { - let mut db = DiagnosticBuilder::new(self, Bug, msg); - db.emit(); - panic!(ExplicitBug); - } - - fn bump_err_count(&self) { - self.err_count.fetch_add(1, SeqCst); - self.panic_if_treat_err_as_bug(); + self.inner.borrow_mut().bug(msg) } pub fn err_count(&self) -> usize { - self.err_count.load(SeqCst) + self.inner.borrow().err_count } pub fn has_errors(&self) -> bool { @@ -660,7 +625,99 @@ impl Handler { } pub fn print_error_count(&self, registry: &Registry) { - let s = match self.deduplicated_err_count.load(SeqCst) { + self.inner.borrow_mut().print_error_count(registry) + } + + pub fn abort_if_errors(&self) { + self.inner.borrow().abort_if_errors() + } + + pub fn abort_if_errors_and_should_abort(&self) { + self.inner.borrow().abort_if_errors_and_should_abort() + } + + pub fn must_teach(&self, code: &DiagnosticId) -> bool { + self.inner.borrow_mut().must_teach(code) + } + + pub fn force_print_diagnostic(&self, db: Diagnostic) { + self.inner.borrow_mut().force_print_diagnostic(db) + } + + pub fn emit_diagnostic(&self, diagnostic: &Diagnostic) { + self.inner.borrow_mut().emit_diagnostic(diagnostic) + } + + pub fn emit_artifact_notification(&self, path: &Path, artifact_type: &str) { + self.inner.borrow_mut().emit_artifact_notification(path, artifact_type) + } + + pub fn delay_as_bug(&self, diagnostic: Diagnostic) { + self.inner.borrow_mut().delay_as_bug(diagnostic) + } +} + +impl HandlerInner { + /// `true` if we haven't taught a diagnostic with this code already. + /// The caller must then teach the user about such a diagnostic. + /// + /// Used to suppress emitting the same error multiple times with extended explanation when + /// calling `-Zteach`. + fn must_teach(&mut self, code: &DiagnosticId) -> bool { + self.taught_diagnostics.insert(code.clone()) + } + + fn force_print_diagnostic(&mut self, db: Diagnostic) { + self.emitter.emit_diagnostic(&db); + } + + fn emit_diagnostic(&mut self, diagnostic: &Diagnostic) { + if diagnostic.cancelled() { + return; + } + + if diagnostic.level == Warning && !self.flags.can_emit_warnings { + return; + } + + TRACK_DIAGNOSTICS.with(|track_diagnostics| { + track_diagnostics.get()(diagnostic); + }); + + if let Some(ref code) = diagnostic.code { + self.emitted_diagnostic_codes.insert(code.clone()); + } + + let diagnostic_hash = { + use std::hash::Hash; + let mut hasher = StableHasher::new(); + diagnostic.hash(&mut hasher); + hasher.finish() + }; + + // Only emit the diagnostic if we haven't already emitted an equivalent + // one: + if self.emitted_diagnostics.insert(diagnostic_hash) { + self.emitter.emit_diagnostic(diagnostic); + if diagnostic.is_error() { + self.deduplicated_err_count += 1; + } + } + if diagnostic.is_error() { + self.bump_err_count(); + } + } + + fn emit_artifact_notification(&mut self, path: &Path, artifact_type: &str) { + self.emitter.emit_artifact_notification(path, artifact_type); + } + + fn treat_err_as_bug(&self) -> bool { + self.flags.treat_err_as_bug.map(|c| self.err_count >= c).unwrap_or(false) + } + + fn print_error_count(&mut self, registry: &Registry) { + let s = match self.deduplicated_err_count { 0 => return, 1 => "aborting due to previous error".to_string(), count => format!("aborting due to {} previous errors", count) @@ -671,12 +728,11 @@ impl Handler { let _ = self.fatal(&s); - let can_show_explain = self.emitter.borrow().should_show_explain(); - let are_there_diagnostics = !self.emitted_diagnostic_codes.borrow().is_empty(); + let can_show_explain = self.emitter.should_show_explain(); + let are_there_diagnostics = !self.emitted_diagnostic_codes.is_empty(); if can_show_explain && are_there_diagnostics { let mut error_codes = self .emitted_diagnostic_codes - .borrow() .iter() .filter_map(|x| match &x { DiagnosticId::Error(s) if registry.find_description(s).is_some() => { @@ -704,70 +760,86 @@ impl Handler { } } - pub fn abort_if_errors_and_should_abort(&self) { - if self.has_errors() && !self.continue_after_error.load(SeqCst) { + fn abort_if_errors_and_should_abort(&self) { + if self.err_count > 0 && !self.continue_after_error { FatalError.raise(); } } - pub fn abort_if_errors(&self) { - if self.has_errors() { + fn abort_if_errors(&self) { + if self.err_count > 0 { FatalError.raise(); } } - /// `true` if we haven't taught a diagnostic with this code already. - /// The caller must then teach the user about such a diagnostic. - /// - /// Used to suppress emitting the same error multiple times with extended explanation when - /// calling `-Zteach`. - pub fn must_teach(&self, code: &DiagnosticId) -> bool { - self.taught_diagnostics.borrow_mut().insert(code.clone()) + fn span_bug>(&mut self, sp: S, msg: &str) -> ! { + self.emit_diagnostic(Diagnostic::new(Bug, msg).set_span(sp)); + self.abort_if_errors_and_should_abort(); + panic!(ExplicitBug); } - pub fn force_print_diagnostic(&self, db: Diagnostic) { - self.emitter.borrow_mut().emit_diagnostic(&db); + fn delay_span_bug>(&mut self, sp: S, msg: &str) { + if self.treat_err_as_bug() { + // FIXME: don't abort here if report_delayed_bugs is off + self.span_bug(sp, msg); + } + let mut diagnostic = Diagnostic::new(Level::Bug, msg); + diagnostic.set_span(sp.into()); + self.delay_as_bug(diagnostic) } - pub fn emit_diagnostic(&self, diagnostic: &Diagnostic) { - if diagnostic.cancelled() { - return; - } + fn failure(&mut self, msg: &str) { + self.emit_diagnostic(&Diagnostic::new(FailureNote, msg)); + } - if diagnostic.level == Warning && !self.flags.can_emit_warnings { - return; + fn fatal(&mut self, msg: &str) -> FatalError { + if self.treat_err_as_bug() { + self.bug(msg); } + self.emit_diagnostic(&Diagnostic::new(Fatal, msg)); + FatalError + } - TRACK_DIAGNOSTICS.with(|track_diagnostics| { - track_diagnostics.get()(diagnostic); - }); - - if let Some(ref code) = diagnostic.code { - self.emitted_diagnostic_codes.borrow_mut().insert(code.clone()); + fn err(&mut self, msg: &str) { + if self.treat_err_as_bug() { + self.bug(msg); } + self.emit_diagnostic(&Diagnostic::new(Error, msg)); + } - let diagnostic_hash = { - use std::hash::Hash; - let mut hasher = StableHasher::new(); - diagnostic.hash(&mut hasher); - hasher.finish() - }; + fn bug(&mut self, msg: &str) -> ! { + self.emit_diagnostic(&Diagnostic::new(Bug, msg)); + panic!(ExplicitBug); + } - // Only emit the diagnostic if we haven't already emitted an equivalent - // one: - if self.emitted_diagnostics.borrow_mut().insert(diagnostic_hash) { - self.emitter.borrow_mut().emit_diagnostic(diagnostic); - if diagnostic.is_error() { - self.deduplicated_err_count.fetch_add(1, SeqCst); - } - } - if diagnostic.is_error() { - self.bump_err_count(); + fn delay_as_bug(&mut self, diagnostic: Diagnostic) { + if self.flags.report_delayed_bugs { + self.emit_diagnostic(&diagnostic); } + self.delayed_span_bugs.push(diagnostic); } - pub fn emit_artifact_notification(&self, path: &Path, artifact_type: &str) { - self.emitter.borrow_mut().emit_artifact_notification(path, artifact_type); + fn bump_err_count(&mut self) { + self.err_count += 1; + self.panic_if_treat_err_as_bug(); + } + + fn panic_if_treat_err_as_bug(&self) { + if self.treat_err_as_bug() { + let s = match (self.err_count, self.flags.treat_err_as_bug.unwrap_or(0)) { + (0, _) => return, + (1, 1) => "aborting due to `-Z treat-err-as-bug=1`".to_string(), + (1, _) => return, + (count, as_bug) => { + format!( + "aborting after {} errors due to `-Z treat-err-as-bug={}`", + count, + as_bug, + ) + } + }; + panic!(s); + } } } From d95a7768a1c5497c6ccb0c2ded30f5968552513c Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 18 Sep 2019 14:13:36 -0400 Subject: [PATCH 15/63] don't record all intermediate adjustment types That's way more than is needed, and winds up recording types that will never appear in MIR. --- .../check/generator_interior.rs | 33 +++++++++++++++---- src/test/ui/async-await/issues/issue-64477.rs | 20 +++++++++++ 2 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 src/test/ui/async-await/issues/issue-64477.rs diff --git a/src/librustc_typeck/check/generator_interior.rs b/src/librustc_typeck/check/generator_interior.rs index 5cee3d63ffc04..a7c307fdf894f 100644 --- a/src/librustc_typeck/check/generator_interior.rs +++ b/src/librustc_typeck/check/generator_interior.rs @@ -181,13 +181,34 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> { let scope = self.region_scope_tree.temporary_scope(expr.hir_id.local_id); - // Record the unadjusted type + // If there are adjustments, then record the final type -- + // this is the actual value that is being produced. + if let Some(adjusted_ty) = self.fcx.tables.borrow().expr_ty_adjusted_opt(expr) { + self.record(adjusted_ty, scope, Some(expr), expr.span); + } + + // Also record the unadjusted type (which is the only type if + // there are no adjustments). The reason for this is that the + // unadjusted value is sometimes a "temporary" that would wind + // up in a MIR temporary. + // + // As an example, consider an expression like `vec![].push()`. + // Here, the `vec![]` would wind up MIR stored into a + // temporary variable `t` which we can borrow to invoke + // `>::push(&mut t)`. + // + // Note that an expression can have many adjustments, and we + // are just ignoring those intermediate types. This is because + // those intermediate values are always linearly "consumed" by + // the other adjustments, and hence would never be directly + // captured in the MIR. + // + // (Note that this partly relies on the fact that the `Deref` + // traits always return references, which means their content + // can be reborrowed without needing to spill to a temporary. + // If this were not the case, then we could conceivably have + // to create intermediate temporaries.) let ty = self.fcx.tables.borrow().expr_ty(expr); self.record(ty, scope, Some(expr), expr.span); - - // Also include the adjusted types, since these can result in MIR locals - for adjustment in self.fcx.tables.borrow().expr_adjustments(expr) { - self.record(adjustment.target, scope, Some(expr), expr.span); - } } } diff --git a/src/test/ui/async-await/issues/issue-64477.rs b/src/test/ui/async-await/issues/issue-64477.rs new file mode 100644 index 0000000000000..5bd52d44a5827 --- /dev/null +++ b/src/test/ui/async-await/issues/issue-64477.rs @@ -0,0 +1,20 @@ +// Regression test for #64477. +// +// We were incorrectly claiming that the `f(x).await` future captured +// a value of type `T`, and hence that `T: Send` would have to hold. +// +// check-pass +// edition:2018 + +use std::future::Future; +use std::pin::Pin; + +fn f(_: &T) -> Pin + Send>> { + unimplemented!() +} + +pub fn g(x: &'static T) -> impl Future + Send { + async move { f(x).await } +} + +fn main() { } From 479ce39939014f0071f8600fa4ce150e33cb7d5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 25 Aug 2019 21:58:59 -0700 Subject: [PATCH 16/63] Add explanation to type mismatch involving type params and assoc types --- src/librustc/traits/mod.rs | 10 +- src/librustc/traits/util.rs | 27 +++--- src/librustc/ty/error.rs | 96 ++++++++++++++++++- ...ssociated-const-generic-obligations.stderr | 2 + .../associated-types-eq-3.stderr | 2 + .../associated-types-issue-20346.stderr | 2 + ...ated-types-multiple-types-one-trait.stderr | 4 + .../reordered-type-param.stderr | 2 + src/test/ui/hrtb/issue-62203-hrtb-ice.stderr | 2 + .../bound-normalization-fail.stderr | 4 + src/test/ui/impl-trait/equality2.stderr | 2 + .../impl-generic-mismatch-ab.stderr | 2 + .../universal-mismatched-type.stderr | 2 + .../universal-two-impl-traits.stderr | 2 + src/test/ui/issues/issue-13853.stderr | 2 + src/test/ui/issues/issue-20225.stderr | 6 ++ src/test/ui/issues/issue-24204.stderr | 1 + src/test/ui/issues/issue-2951.stderr | 2 + src/test/ui/issues/issue-32323.stderr | 2 + .../ui/mismatched_types/issue-35030.stderr | 2 + .../specialization-default-projection.stderr | 4 + .../specialization-default-types.stderr | 4 + .../struct-path-self-type-mismatch.stderr | 4 + .../enum-variant-generic-args.stderr | 12 +++ src/test/ui/type/type-parameter-names.stderr | 2 + .../type-params-in-different-spaces-1.stderr | 2 + .../type-params-in-different-spaces-3.stderr | 2 + 27 files changed, 181 insertions(+), 23 deletions(-) diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index d2683090add40..7154962b59295 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -655,11 +655,11 @@ pub struct VtableTraitAliasData<'tcx, N> { } /// Creates predicate obligations from the generic bounds. -pub fn predicates_for_generics<'tcx>(cause: ObligationCause<'tcx>, - param_env: ty::ParamEnv<'tcx>, - generic_bounds: &ty::InstantiatedPredicates<'tcx>) - -> PredicateObligations<'tcx> -{ +pub fn predicates_for_generics<'tcx>( + cause: ObligationCause<'tcx>, + param_env: ty::ParamEnv<'tcx>, + generic_bounds: &ty::InstantiatedPredicates<'tcx>, +) -> PredicateObligations<'tcx> { util::predicates_for_generics(cause, 0, param_env, generic_bounds) } diff --git a/src/librustc/traits/util.rs b/src/librustc/traits/util.rs index 3d36790c94b8c..3e5520dd46557 100644 --- a/src/librustc/traits/util.rs +++ b/src/librustc/traits/util.rs @@ -513,20 +513,19 @@ pub fn impl_trait_ref_and_oblig<'a, 'tcx>( } /// See [`super::obligations_for_generics`]. -pub fn predicates_for_generics<'tcx>(cause: ObligationCause<'tcx>, - recursion_depth: usize, - param_env: ty::ParamEnv<'tcx>, - generic_bounds: &ty::InstantiatedPredicates<'tcx>) - -> Vec> -{ - debug!("predicates_for_generics(generic_bounds={:?})", - generic_bounds); - - generic_bounds.predicates.iter().map(|predicate| { - Obligation { cause: cause.clone(), - recursion_depth, - param_env, - predicate: predicate.clone() } +pub fn predicates_for_generics<'tcx>( + cause: ObligationCause<'tcx>, + recursion_depth: usize, + param_env: ty::ParamEnv<'tcx>, + generic_bounds: &ty::InstantiatedPredicates<'tcx>, +) -> Vec> { + debug!("predicates_for_generics(generic_bounds={:?})", generic_bounds); + + generic_bounds.predicates.iter().map(|predicate| Obligation { + cause: cause.clone(), + recursion_depth, + param_env, + predicate: predicate.clone(), }).collect() } diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index 62910ec320494..993d627d6e176 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -275,10 +275,10 @@ impl<'tcx> TyCtxt<'tcx> { `.await`ing on both of them"); } } - if let (ty::Infer(ty::IntVar(_)), ty::Float(_)) = - (&values.found.sty, &values.expected.sty) // Issue #53280 - { - if let Ok(snippet) = self.sess.source_map().span_to_snippet(sp) { + match (&values.expected.sty, &values.found.sty) { + (ty::Float(_), ty::Infer(ty::IntVar(_))) => if let Ok( // Issue #53280 + snippet, + ) = self.sess.source_map().span_to_snippet(sp) { if snippet.chars().all(|c| c.is_digit(10) || c == '-' || c == '_') { db.span_suggestion( sp, @@ -287,8 +287,96 @@ impl<'tcx> TyCtxt<'tcx> { Applicability::MachineApplicable ); } + }, + (ty::Param(_), ty::Param(_)) => { + db.note("a type parameter was expected, but a different one was found; \ + you might be missing a type parameter or trait bound"); + db.note("for more information, visit \ + https://doc.rust-lang.org/book/ch10-02-traits.html\ + #traits-as-parameters"); + } + (ty::Projection(_), ty::Projection(_)) => { + db.note("an associated type was expected, but a different one was found"); + } + (ty::Param(_), ty::Projection(_)) | (ty::Projection(_), ty::Param(_)) => { + db.note("you might be missing a type parameter or trait bound"); + } + (ty::Param(_), _) | (_, ty::Param(_)) => { + db.help("type parameters must be constrained to match other types"); + if self.sess.teach(&db.get_code().unwrap()) { + db.help("given a type parameter `T` and a method `foo`: +``` +trait Trait { fn foo(&self) -> T; } +``` +the only ways to implement method `foo` are: +- constrain `T` with an explicit type: +``` +impl Trait for X { + fn foo(&self) -> String { String::new() } +} +``` +- add a trait bound to `T` and call a method on that trait that returns `Self`: +``` +impl Trait for X { + fn foo(&self) -> T { ::default() } +} +``` +- change `foo` to return an argument of type `T`: +``` +impl Trait for X { + fn foo(&self, x: T) -> T { x } +} +```"); + } + db.note("for more information, visit \ + https://doc.rust-lang.org/book/ch10-02-traits.html\ + #traits-as-parameters"); + } + (ty::Projection(_), _) => { + db.note(&format!( + "consider constraining the associated type `{}` to `{}` or calling a \ + method that returns `{}`", + values.expected, + values.found, + values.expected, + )); + if self.sess.teach(&db.get_code().unwrap()) { + db.help("given an associated type `T` and a method `foo`: +``` +trait Trait { + type T; + fn foo(&self) -> Self::T; +} +``` +the only way of implementing method `foo` is to constrain `T` with an explicit associated type: +``` +impl Trait for X { + type T = String; + fn foo(&self) -> Self::T { String::new() } +} +```"); + } + db.note("for more information, visit \ + https://doc.rust-lang.org/book/ch19-03-advanced-traits.html"); + } + (_, ty::Projection(_)) => { + db.note(&format!( + "consider constraining the associated type `{}` to `{}`", + values.found, + values.expected, + )); + db.note("for more information, visit \ + https://doc.rust-lang.org/book/ch19-03-advanced-traits.html"); } + _ => {} } + debug!( + "note_and_explain_type_err expected={:?} ({:?}) found={:?} ({:?})", + values.expected, + values.expected.sty, + values.found, + values.found.sty, + ); }, CyclicTy(ty) => { // Watch out for various cases of cyclic types and try to explain. diff --git a/src/test/ui/associated-const/associated-const-generic-obligations.stderr b/src/test/ui/associated-const/associated-const-generic-obligations.stderr index eeee26a75671f..ca6118cb3ba98 100644 --- a/src/test/ui/associated-const/associated-const-generic-obligations.stderr +++ b/src/test/ui/associated-const/associated-const-generic-obligations.stderr @@ -9,6 +9,8 @@ LL | const FROM: &'static str = "foo"; | = note: expected type `::Out` found type `&'static str` + = note: consider constraining the associated type `::Out` to `&'static str` or calling a method that returns `::Out` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error: aborting due to previous error diff --git a/src/test/ui/associated-types/associated-types-eq-3.stderr b/src/test/ui/associated-types/associated-types-eq-3.stderr index 0f8c5257d445f..c9d88b7af0753 100644 --- a/src/test/ui/associated-types/associated-types-eq-3.stderr +++ b/src/test/ui/associated-types/associated-types-eq-3.stderr @@ -6,6 +6,8 @@ LL | let _: Bar = x.boo(); | = note: expected type `Bar` found type `::A` + = note: consider constraining the associated type `::A` to `Bar` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error[E0271]: type mismatch resolving `::A == Bar` --> $DIR/associated-types-eq-3.rs:38:5 diff --git a/src/test/ui/associated-types/associated-types-issue-20346.stderr b/src/test/ui/associated-types/associated-types-issue-20346.stderr index 7d6c025d69d55..e037bd851ca21 100644 --- a/src/test/ui/associated-types/associated-types-issue-20346.stderr +++ b/src/test/ui/associated-types/associated-types-issue-20346.stderr @@ -9,6 +9,8 @@ LL | is_iterator_of::, _>(&adapter); | = note: expected type `T` found type `std::option::Option` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to previous error diff --git a/src/test/ui/associated-types/associated-types-multiple-types-one-trait.stderr b/src/test/ui/associated-types/associated-types-multiple-types-one-trait.stderr index 4a2a6d03c607f..d6328a64c7c74 100644 --- a/src/test/ui/associated-types/associated-types-multiple-types-one-trait.stderr +++ b/src/test/ui/associated-types/associated-types-multiple-types-one-trait.stderr @@ -9,6 +9,8 @@ LL | fn want_y>(t: &T) { } | = note: expected type `::Y` found type `i32` + = note: consider constraining the associated type `::Y` to `i32` or calling a method that returns `::Y` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error[E0271]: type mismatch resolving `::X == u32` --> $DIR/associated-types-multiple-types-one-trait.rs:18:5 @@ -21,6 +23,8 @@ LL | fn want_x>(t: &T) { } | = note: expected type `::X` found type `u32` + = note: consider constraining the associated type `::X` to `u32` or calling a method that returns `::X` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error: aborting due to 2 previous errors diff --git a/src/test/ui/compare-method/reordered-type-param.stderr b/src/test/ui/compare-method/reordered-type-param.stderr index a33908c01c842..8176e96d6de1f 100644 --- a/src/test/ui/compare-method/reordered-type-param.stderr +++ b/src/test/ui/compare-method/reordered-type-param.stderr @@ -9,6 +9,8 @@ LL | fn b(&self, _x: G) -> G { panic!() } | = note: expected type `fn(&E, F) -> F` found type `fn(&E, G) -> G` + = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to previous error diff --git a/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr b/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr index c2d0e0c2a26bc..fd6fce938b2c7 100644 --- a/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr +++ b/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr @@ -6,6 +6,8 @@ LL | let v = Unit2.m( | = note: expected type `Unit4` found type `<_ as Ty<'_>>::V` + = note: consider constraining the associated type `<_ as Ty<'_>>::V` to `Unit4` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error[E0271]: type mismatch resolving `<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39] as std::ops::FnOnce<((&u8,),)>>::Output == Unit3` --> $DIR/issue-62203-hrtb-ice.rs:38:19 diff --git a/src/test/ui/impl-trait/bound-normalization-fail.stderr b/src/test/ui/impl-trait/bound-normalization-fail.stderr index 2c4c61a0957f9..99c6a8cdd6daf 100644 --- a/src/test/ui/impl-trait/bound-normalization-fail.stderr +++ b/src/test/ui/impl-trait/bound-normalization-fail.stderr @@ -14,6 +14,8 @@ LL | fn foo_fail() -> impl FooLike { | = note: expected type `()` found type `::Assoc` + = note: consider constraining the associated type `::Assoc` to `()` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html = note: the return type of a function must have a statically known size error: `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope @@ -30,6 +32,8 @@ LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike { | = note: expected type `()` found type `>::Assoc` + = note: consider constraining the associated type `>::Assoc` to `()` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html = note: the return type of a function must have a statically known size error: aborting due to 3 previous errors diff --git a/src/test/ui/impl-trait/equality2.stderr b/src/test/ui/impl-trait/equality2.stderr index 3e6181adec026..e30e2626e9f34 100644 --- a/src/test/ui/impl-trait/equality2.stderr +++ b/src/test/ui/impl-trait/equality2.stderr @@ -15,6 +15,8 @@ LL | let _: i32 = Leak::leak(hide(0_i32)); | = note: expected type `i32` found type `::T` + = note: consider constraining the associated type `::T` to `i32` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error[E0308]: mismatched types --> $DIR/equality2.rs:38:10 diff --git a/src/test/ui/impl-trait/impl-generic-mismatch-ab.stderr b/src/test/ui/impl-trait/impl-generic-mismatch-ab.stderr index 357e6b026e2a3..e4d0a731ebfe5 100644 --- a/src/test/ui/impl-trait/impl-generic-mismatch-ab.stderr +++ b/src/test/ui/impl-trait/impl-generic-mismatch-ab.stderr @@ -9,6 +9,8 @@ LL | fn foo(&self, a: &impl Debug, b: &B) { } | = note: expected type `fn(&(), &B, &impl Debug)` found type `fn(&(), &impl Debug, &B)` + = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to previous error diff --git a/src/test/ui/impl-trait/universal-mismatched-type.stderr b/src/test/ui/impl-trait/universal-mismatched-type.stderr index d223b9672cfdc..d92c3f034e5a2 100644 --- a/src/test/ui/impl-trait/universal-mismatched-type.stderr +++ b/src/test/ui/impl-trait/universal-mismatched-type.stderr @@ -8,6 +8,8 @@ LL | x | = note: expected type `std::string::String` found type `impl Debug` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to previous error diff --git a/src/test/ui/impl-trait/universal-two-impl-traits.stderr b/src/test/ui/impl-trait/universal-two-impl-traits.stderr index 145d6a8431bf4..98a70f268cf72 100644 --- a/src/test/ui/impl-trait/universal-two-impl-traits.stderr +++ b/src/test/ui/impl-trait/universal-two-impl-traits.stderr @@ -6,6 +6,8 @@ LL | a = y; | = note: expected type `impl Debug` (type parameter) found type `impl Debug` (type parameter) + = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to previous error diff --git a/src/test/ui/issues/issue-13853.stderr b/src/test/ui/issues/issue-13853.stderr index c57ca3e25d99f..3f2d0aa87adc1 100644 --- a/src/test/ui/issues/issue-13853.stderr +++ b/src/test/ui/issues/issue-13853.stderr @@ -9,6 +9,8 @@ LL | self.iter() | = note: expected type `I` found type `std::slice::Iter<'_, N>` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error[E0599]: no method named `iter` found for type `&G` in the current scope --> $DIR/issue-13853.rs:27:23 diff --git a/src/test/ui/issues/issue-20225.stderr b/src/test/ui/issues/issue-20225.stderr index 5ab23cb55bcc4..4c464e6d4f685 100644 --- a/src/test/ui/issues/issue-20225.stderr +++ b/src/test/ui/issues/issue-20225.stderr @@ -6,6 +6,8 @@ LL | extern "rust-call" fn call(&self, (_,): (T,)) {} | = note: expected type `extern "rust-call" fn(&Foo, (&'a T,))` found type `extern "rust-call" fn(&Foo, (T,))` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error[E0053]: method `call_mut` has an incompatible type for trait --> $DIR/issue-20225.rs:12:3 @@ -15,6 +17,8 @@ LL | extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {} | = note: expected type `extern "rust-call" fn(&mut Foo, (&'a T,))` found type `extern "rust-call" fn(&mut Foo, (T,))` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error[E0053]: method `call_once` has an incompatible type for trait --> $DIR/issue-20225.rs:20:3 @@ -24,6 +28,8 @@ LL | extern "rust-call" fn call_once(self, (_,): (T,)) {} | = note: expected type `extern "rust-call" fn(Foo, (&'a T,))` found type `extern "rust-call" fn(Foo, (T,))` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to 3 previous errors diff --git a/src/test/ui/issues/issue-24204.stderr b/src/test/ui/issues/issue-24204.stderr index eb9aada389f8f..9658f6980be2f 100644 --- a/src/test/ui/issues/issue-24204.stderr +++ b/src/test/ui/issues/issue-24204.stderr @@ -9,6 +9,7 @@ LL | fn test>(b: i32) -> T where T::A: MultiDispatch { T::n | = note: expected type `<::A as MultiDispatch>::O` found type `T` + = note: you might be missing a type parameter or trait bound error: aborting due to previous error diff --git a/src/test/ui/issues/issue-2951.stderr b/src/test/ui/issues/issue-2951.stderr index 58e28c1a9dc83..a6ccc4835fa68 100644 --- a/src/test/ui/issues/issue-2951.stderr +++ b/src/test/ui/issues/issue-2951.stderr @@ -6,6 +6,8 @@ LL | xx = y; | = note: expected type `T` found type `U` + = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to previous error diff --git a/src/test/ui/issues/issue-32323.stderr b/src/test/ui/issues/issue-32323.stderr index 6256dc0c55022..9c11a02923c8c 100644 --- a/src/test/ui/issues/issue-32323.stderr +++ b/src/test/ui/issues/issue-32323.stderr @@ -8,6 +8,8 @@ LL | pub fn f<'a, T: Tr<'a>>() -> >::Out {} | = note: expected type `>::Out` found type `()` + = note: consider constraining the associated type `>::Out` to `()` or calling a method that returns `>::Out` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error: aborting due to previous error diff --git a/src/test/ui/mismatched_types/issue-35030.stderr b/src/test/ui/mismatched_types/issue-35030.stderr index f030670161343..4a9afb9d2494e 100644 --- a/src/test/ui/mismatched_types/issue-35030.stderr +++ b/src/test/ui/mismatched_types/issue-35030.stderr @@ -6,6 +6,8 @@ LL | Some(true) | = note: expected type `bool` (type parameter) found type `bool` (bool) + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to previous error diff --git a/src/test/ui/specialization/specialization-default-projection.stderr b/src/test/ui/specialization/specialization-default-projection.stderr index ab0bdc44cff1a..43cebd7f9c245 100644 --- a/src/test/ui/specialization/specialization-default-projection.stderr +++ b/src/test/ui/specialization/specialization-default-projection.stderr @@ -9,6 +9,8 @@ LL | () | = note: expected type `::Assoc` found type `()` + = note: consider constraining the associated type `::Assoc` to `()` or calling a method that returns `::Assoc` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error[E0308]: mismatched types --> $DIR/specialization-default-projection.rs:28:5 @@ -23,6 +25,8 @@ LL | generic::<()>() | = note: expected type `()` found type `<() as Foo>::Assoc` + = note: consider constraining the associated type `<() as Foo>::Assoc` to `()` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error: aborting due to 2 previous errors diff --git a/src/test/ui/specialization/specialization-default-types.stderr b/src/test/ui/specialization/specialization-default-types.stderr index 1192b0e5cfa53..932087421fbcb 100644 --- a/src/test/ui/specialization/specialization-default-types.stderr +++ b/src/test/ui/specialization/specialization-default-types.stderr @@ -8,6 +8,8 @@ LL | Box::new(self) | = note: expected type `::Output` found type `std::boxed::Box` + = note: consider constraining the associated type `::Output` to `std::boxed::Box` or calling a method that returns `::Output` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error[E0308]: mismatched types --> $DIR/specialization-default-types.rs:25:5 @@ -19,6 +21,8 @@ LL | Example::generate(t) | = note: expected type `std::boxed::Box` found type `::Output` + = note: consider constraining the associated type `::Output` to `std::boxed::Box` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error: aborting due to 2 previous errors diff --git a/src/test/ui/structs/struct-path-self-type-mismatch.stderr b/src/test/ui/structs/struct-path-self-type-mismatch.stderr index 72c6d7ae22b4b..b905cd1a294cc 100644 --- a/src/test/ui/structs/struct-path-self-type-mismatch.stderr +++ b/src/test/ui/structs/struct-path-self-type-mismatch.stderr @@ -12,6 +12,8 @@ LL | inner: u | = note: expected type `T` found type `U` + = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error[E0308]: mismatched types --> $DIR/struct-path-self-type-mismatch.rs:13:9 @@ -27,6 +29,8 @@ LL | | } | = note: expected type `Foo` found type `Foo` + = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to 3 previous errors diff --git a/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.stderr b/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.stderr index ee73622cb7bd1..a0a617fdbbc35 100644 --- a/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.stderr +++ b/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.stderr @@ -6,6 +6,8 @@ LL | Self::TSVariant(()); | = note: expected type `T` found type `()` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:15:27 @@ -27,6 +29,8 @@ LL | Self::<()>::TSVariant(()); | = note: expected type `T` found type `()` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:20:16 @@ -48,6 +52,8 @@ LL | Self::SVariant { v: () }; | = note: expected type `T` found type `()` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:28:26 @@ -63,6 +69,8 @@ LL | Self::SVariant::<()> { v: () }; | = note: expected type `T` found type `()` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:31:16 @@ -78,6 +86,8 @@ LL | Self::<()>::SVariant { v: () }; | = note: expected type `T` found type `()` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:34:16 @@ -99,6 +109,8 @@ LL | Self::<()>::SVariant::<()> { v: () }; | = note: expected type `T` found type `()` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:41:26 diff --git a/src/test/ui/type/type-parameter-names.stderr b/src/test/ui/type/type-parameter-names.stderr index 9acae5c376d5b..3397eec9e050b 100644 --- a/src/test/ui/type/type-parameter-names.stderr +++ b/src/test/ui/type/type-parameter-names.stderr @@ -8,6 +8,8 @@ LL | x | = note: expected type `Bar` found type `Foo` + = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to previous error diff --git a/src/test/ui/type/type-params-in-different-spaces-1.stderr b/src/test/ui/type/type-params-in-different-spaces-1.stderr index 0448a28ea8e27..a10bf4e0b7787 100644 --- a/src/test/ui/type/type-params-in-different-spaces-1.stderr +++ b/src/test/ui/type/type-params-in-different-spaces-1.stderr @@ -6,6 +6,8 @@ LL | *self + rhs | = note: expected type `Self` found type `T` + = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to previous error diff --git a/src/test/ui/type/type-params-in-different-spaces-3.stderr b/src/test/ui/type/type-params-in-different-spaces-3.stderr index e25f79947c732..9f0fa5a0ea1fe 100644 --- a/src/test/ui/type/type-params-in-different-spaces-3.stderr +++ b/src/test/ui/type/type-params-in-different-spaces-3.stderr @@ -8,6 +8,8 @@ LL | u | = note: expected type `Self` found type `X` + = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to previous error From 9a447a232e3d17d7dea7eeeda51cbc9a28d497dc Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 19 Sep 2019 10:07:50 -0400 Subject: [PATCH 17/63] replace boolean with lazy iteration Should probably check how this performs, but it's always nicer to track just a bit less mutable state. --- src/librustc_mir/build/scope.rs | 39 +++++++++++++++++---------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs index ee6d42de388d9..3c735c8cb09d7 100644 --- a/src/librustc_mir/build/scope.rs +++ b/src/librustc_mir/build/scope.rs @@ -104,19 +104,6 @@ struct Scope { /// the span of that region_scope region_scope_span: Span, - /// Whether there's anything to do for the cleanup path, that is, - /// when unwinding through this scope. This includes destructors, - /// but not StorageDead statements, which don't get emitted at all - /// for unwinding, for several reasons: - /// * clang doesn't emit llvm.lifetime.end for C++ unwinding - /// * LLVM's memory dependency analysis can't handle it atm - /// * polluting the cleanup MIR with StorageDead creates - /// landing pads even though there's no actual destructors - /// * freeing up stack space has no effect during unwinding - /// Note that for generators we do emit StorageDeads, for the - /// use of optimizations in the MIR generator transform. - needs_cleanup: bool, - /// set of places to drop when exiting this scope. This starts /// out empty but grows as variables are declared during the /// building process. This is a stack, so we always drop from the @@ -261,6 +248,25 @@ impl Scope { scope: self.source_scope } } + + + /// Whether there's anything to do for the cleanup path, that is, + /// when unwinding through this scope. This includes destructors, + /// but not StorageDead statements, which don't get emitted at all + /// for unwinding, for several reasons: + /// * clang doesn't emit llvm.lifetime.end for C++ unwinding + /// * LLVM's memory dependency analysis can't handle it atm + /// * polluting the cleanup MIR with StorageDead creates + /// landing pads even though there's no actual destructors + /// * freeing up stack space has no effect during unwinding + /// Note that for generators we do emit StorageDeads, for the + /// use of optimizations in the MIR generator transform. + fn needs_cleanup(&self) -> bool { + self.drops.iter().any(|drop| match drop.kind { + DropKind::Value => true, + DropKind::Storage => false, + }) + } } impl<'tcx> Scopes<'tcx> { @@ -274,7 +280,6 @@ impl<'tcx> Scopes<'tcx> { source_scope: vis_scope, region_scope: region_scope.0, region_scope_span: region_scope.1.span, - needs_cleanup: false, drops: vec![], cached_generator_drop: None, cached_exits: Default::default(), @@ -295,7 +300,7 @@ impl<'tcx> Scopes<'tcx> { fn may_panic(&self, scope_count: usize) -> bool { let len = self.len(); - self.scopes[(len - scope_count)..].iter().any(|s| s.needs_cleanup) + self.scopes[(len - scope_count)..].iter().any(|s| s.needs_cleanup()) } /// Finds the breakable scope for a given label. This is used for @@ -801,10 +806,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // cache of outer scope stays intact. scope.invalidate_cache(!needs_drop, self.is_generator, this_scope); if this_scope { - if let DropKind::Value = drop_kind { - scope.needs_cleanup = true; - } - let region_scope_span = region_scope.span(self.hir.tcx(), &self.hir.region_scope_tree); // Attribute scope exit drops to scope's closing brace. From e35698371d36da83d3aca8322ad812fa5512b90f Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 19 Sep 2019 10:30:46 -0400 Subject: [PATCH 18/63] make clear that `invalidate` just replaces with `default` --- src/librustc_mir/build/scope.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs index 3c735c8cb09d7..9c1acb3faae0f 100644 --- a/src/librustc_mir/build/scope.rs +++ b/src/librustc_mir/build/scope.rs @@ -189,8 +189,7 @@ pub enum BreakableTarget { impl CachedBlock { fn invalidate(&mut self) { - self.generator_drop = None; - self.unwind = None; + *self = CachedBlock::default(); } fn get(&self, generator_drop: bool) -> Option { From b2c51c24c96f8827eefc6f0de29636cc4cb6ff2c Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 19 Sep 2019 11:41:10 -0400 Subject: [PATCH 19/63] avoid generating drops for moved operands of calls Currently, after a CALL terminator is created in MIR, we insert DROP statements for all of its operands -- even though they were just moved shortly before! These spurious drops are later removed, but not before causing borrow check errors. This PR series modifies the drop code to track operands that were moved and avoid creating drops for them. Right now, I'm only using this mechanism for calls, but it seems likely it could be used in more places. --- src/librustc/mir/mod.rs | 9 ++ src/librustc_mir/build/expr/into.rs | 3 + src/librustc_mir/build/scope.rs | 93 ++++++++++++++++++- .../ui/async-await/issues/issue-64391-2.rs | 17 ++++ src/test/ui/async-await/issues/issue-64433.rs | 29 ++++++ 5 files changed, 147 insertions(+), 4 deletions(-) create mode 100644 src/test/ui/async-await/issues/issue-64391-2.rs create mode 100644 src/test/ui/async-await/issues/issue-64433.rs diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 0ebc70750a6bb..92efcf44dea36 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -1917,6 +1917,15 @@ impl<'tcx> Place<'tcx> { } } + /// If this place represents a local variable like `_X` with no + /// projections, return `Some(_X)`. + pub fn as_local(&self) -> Option { + match self { + Place { projection: box [], base: PlaceBase::Local(l) } => Some(*l), + _ => None, + } + } + pub fn as_ref(&self) -> PlaceRef<'_, 'tcx> { PlaceRef { base: &self.base, diff --git a/src/librustc_mir/build/expr/into.rs b/src/librustc_mir/build/expr/into.rs index 45f4a16853606..30d53502b11ff 100644 --- a/src/librustc_mir/build/expr/into.rs +++ b/src/librustc_mir/build/expr/into.rs @@ -244,6 +244,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let success = this.cfg.start_new_block(); let cleanup = this.diverge_cleanup(); + + this.record_operands_moved(&args); + this.cfg.terminate( block, source_info, diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs index 9c1acb3faae0f..13d94262b6c53 100644 --- a/src/librustc_mir/build/scope.rs +++ b/src/librustc_mir/build/scope.rs @@ -110,6 +110,8 @@ struct Scope { /// end of the vector (top of the stack) first. drops: Vec, + moved_locals: Vec, + /// The cache for drop chain on “normal” exit into a particular BasicBlock. cached_exits: FxHashMap<(BasicBlock, region::Scope), BasicBlock>, @@ -159,7 +161,7 @@ struct CachedBlock { generator_drop: Option, } -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq)] pub(crate) enum DropKind { Value, Storage, @@ -280,6 +282,7 @@ impl<'tcx> Scopes<'tcx> { region_scope: region_scope.0, region_scope_span: region_scope.1.span, drops: vec![], + moved_locals: vec![], cached_generator_drop: None, cached_exits: Default::default(), cached_unwind: CachedBlock::default(), @@ -484,7 +487,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { block, unwind_to, self.arg_count, - false, + false, // not generator + false, // not unwind path )); block.unit() @@ -576,7 +580,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { block, unwind_to, self.arg_count, - false, + false, // not generator + false, // not unwind path )); scope = next_scope; @@ -626,7 +631,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { block, unwind_to, self.arg_count, - true, + true, // is generator + true, // is cached path )); } @@ -822,6 +828,75 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { span_bug!(span, "region scope {:?} not in scope to drop {:?}", region_scope, local); } + /// Indicates that the "local operand" stored in `local` is + /// *moved* at some point during execution (see `local_scope` for + /// more information about what a "local operand" is -- in short, + /// it's an intermediate operand created as part of preparing some + /// MIR instruction). We use this information to suppress + /// redundant drops on the non-unwind paths. This results in less + /// MIR, but also avoids spurious borrow check errors + /// (c.f. #64391). + /// + /// Example: when compiling the call to `foo` here: + /// + /// ```rust + /// foo(bar(), ...) + /// ``` + /// + /// we would evaluate `bar()` to an operand `_X`. We would also + /// schedule `_X` to be dropped when the expression scope for + /// `foo(bar())` is exited. This is relevant, for example, if the + /// later arguments should unwind (it would ensure that `_X` gets + /// dropped). However, if no unwind occurs, then `_X` will be + /// unconditionally consumed by the `call`: + /// + /// ``` + /// bb { + /// ... + /// _R = CALL(foo, _X, ...) + /// } + /// ``` + /// + /// However, `_X` is still registered to be dropped, and so if we + /// do nothing else, we would generate a `DROP(_X)` that occurs + /// after the call. This will later be optimized out by the + /// drop-elaboation code, but in the meantime it can lead to + /// spurious borrow-check errors -- the problem, ironically, is + /// not the `DROP(_X)` itself, but the (spurious) unwind pathways + /// that it creates. See #64391 for an example. + pub fn record_operands_moved( + &mut self, + operands: &[Operand<'tcx>], + ) { + let scope = match self.local_scope() { + None => { + // if there is no local scope, operands won't be dropped anyway + return; + } + + Some(local_scope) => { + self.scopes.iter_mut().find(|scope| scope.region_scope == local_scope) + .unwrap_or_else(|| bug!("scope {:?} not found in scope list!", local_scope)) + } + }; + + // look for moves of a local variable, like `MOVE(_X)` + let locals_moved = operands.iter().flat_map(|operand| match operand { + Operand::Copy(_) | Operand::Constant(_) => None, + Operand::Move(place) => place.as_local(), + }); + + for local in locals_moved { + // check if we have a Drop for this operand and -- if so + // -- add it to the list of moved operands. Note that this + // local might not have been an operand created for this + // call, it could come from other places too. + if scope.drops.iter().any(|drop| drop.local == local && drop.kind == DropKind::Value) { + scope.moved_locals.push(local); + } + } + } + // Other // ===== /// Branch based on a boolean condition. @@ -1020,6 +1095,7 @@ fn build_scope_drops<'tcx>( last_unwind_to: BasicBlock, arg_count: usize, generator_drop: bool, + is_cached_path: bool, ) -> BlockAnd<()> { debug!("build_scope_drops({:?} -> {:?})", block, scope); @@ -1046,6 +1122,15 @@ fn build_scope_drops<'tcx>( let drop_data = &scope.drops[drop_idx]; let source_info = scope.source_info(drop_data.span); let local = drop_data.local; + + // If the operand has been moved, and we are not on an unwind + // path, then don't generate the drop. (We only take this into + // account for non-unwind paths so as not to disturb the + // caching mechanism.) + if !is_cached_path && scope.moved_locals.iter().any(|&o| o == local) { + continue; + } + match drop_data.kind { DropKind::Value => { let unwind_to = get_unwind_to(scope, is_generator, drop_idx, generator_drop) diff --git a/src/test/ui/async-await/issues/issue-64391-2.rs b/src/test/ui/async-await/issues/issue-64391-2.rs new file mode 100644 index 0000000000000..528704c0e45c3 --- /dev/null +++ b/src/test/ui/async-await/issues/issue-64391-2.rs @@ -0,0 +1,17 @@ +// Regression test for #64391 +// +// As described on the issue, the (spurious) `DROP` inserted for the +// `"".to_string()` value was causing a (spurious) unwind path that +// led us to believe that the future might be dropped after `config` +// had been dropped. This cannot, in fact, happen. + +async fn connect() { + let config = 666; + connect2(&config, "".to_string()).await +} + +async fn connect2(_config: &u32, _tls: String) { + unimplemented!() +} + +fn main() { } diff --git a/src/test/ui/async-await/issues/issue-64433.rs b/src/test/ui/async-await/issues/issue-64433.rs new file mode 100644 index 0000000000000..ca819e78fb8cb --- /dev/null +++ b/src/test/ui/async-await/issues/issue-64433.rs @@ -0,0 +1,29 @@ +// Regression test for issue #64433. +// +// See issue-64391-2.rs for more details, as that was fixed by the +// same PR. +// +// check-pass + +#[derive(Debug)] +struct A<'a> { + inner: Vec<&'a str>, +} + +struct B {} + +impl B { + async fn something_with_a(&mut self, a: A<'_>) -> Result<(), String> { + println!("{:?}", a); + Ok(()) + } +} + +async fn can_error(some_string: &str) -> Result<(), String> { + let a = A { inner: vec![some_string, "foo"] }; + let mut b = B {}; + Ok(b.something_with_a(a).await.map(|_| ())?) +} + +fn main() { +} From 8112f71fc91bc7618d91bb3180fe80b8fafe1069 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 19 Sep 2019 09:24:42 -0700 Subject: [PATCH 20/63] rustbuild: Turn down compression on exe installers The Windows dist builders are the slowest builders right now, and the distribution phase of them is enormously slow clocking in at around 20 minutes to build all the related installers. This commit starts to optimize these by turning down the compression level in the `exe` installers. These aren't super heavily used so there's no great need for them to be so ultra-compressed, so let's dial back the compression parameters to get closer to the rest of our xz archives. This brings the installer in line with the gz tarball installer locally, and also brings the compression settings on par with the rest of our xz installers. --- src/etc/installer/exe/rust.iss | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/etc/installer/exe/rust.iss b/src/etc/installer/exe/rust.iss index c22d60b6c5df1..70648beac38b0 100644 --- a/src/etc/installer/exe/rust.iss +++ b/src/etc/installer/exe/rust.iss @@ -25,9 +25,9 @@ SourceDir=.\ OutputBaseFilename={#CFG_PACKAGE_NAME}-{#CFG_BUILD} DefaultDirName={sd}\Rust -Compression=lzma2/ultra -InternalCompressLevel=ultra -SolidCompression=true +Compression=lzma2/normal +InternalCompressLevel=normal +SolidCompression=no ChangesEnvironment=true ChangesAssociations=no From 1ab5593f951c07a6f0ed05fbbfe8f262863158a0 Mon Sep 17 00:00:00 2001 From: gaolei Date: Thu, 19 Sep 2019 15:13:40 +0800 Subject: [PATCH 21/63] factor out pluralisation remains after #64280 --- src/librustc/lint/builtin.rs | 4 ++-- src/librustc/middle/resolve_lifetime.rs | 4 ++-- src/librustc/traits/error_reporting.rs | 4 ++-- src/librustc/ty/error.rs | 2 +- src/librustc_lint/unused.rs | 22 ++++++++++++++------- src/librustc_resolve/check_unused.rs | 4 +++- src/librustc_resolve/resolve_imports.rs | 4 ++-- src/librustc_typeck/astconv.rs | 2 +- src/librustc_typeck/check/expr.rs | 4 ++-- src/librustc_typeck/check/method/suggest.rs | 4 ++-- src/librustc_typeck/check/mod.rs | 4 ++-- src/librustc_typeck/check/pat.rs | 14 ++++++------- src/libsyntax/ext/tt/transcribe.rs | 5 +++-- src/libsyntax/parse/diagnostics.rs | 8 ++++---- src/libsyntax/parse/parser/path.rs | 7 +++---- src/libsyntax/parse/parser/ty.rs | 6 +++--- src/libsyntax_ext/format.rs | 3 ++- 17 files changed, 56 insertions(+), 45 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index dd290572d7bb7..5906a6388a8bd 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -7,7 +7,7 @@ use crate::lint::{LintPass, LateLintPass, LintArray}; use crate::middle::stability; use crate::session::Session; -use errors::{Applicability, DiagnosticBuilder}; +use errors::{Applicability, DiagnosticBuilder, pluralise}; use syntax::ast; use syntax::source_map::Span; use syntax::symbol::Symbol; @@ -524,7 +524,7 @@ pub(crate) fn add_elided_lifetime_in_path_suggestion( }; db.span_suggestion( replace_span, - &format!("indicate the anonymous lifetime{}", if n >= 2 { "s" } else { "" }), + &format!("indicate the anonymous lifetime{}", pluralise!(n)), suggestion, Applicability::MachineApplicable ); diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 8836a632a7ca8..d833a34385b2d 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -17,7 +17,7 @@ use crate::ty::{self, DefIdTree, GenericParamDefKind, TyCtxt}; use crate::rustc::lint; use crate::session::Session; use crate::util::nodemap::{DefIdMap, FxHashMap, FxHashSet, HirIdMap, HirIdSet}; -use errors::{Applicability, DiagnosticBuilder}; +use errors::{Applicability, DiagnosticBuilder, pluralise}; use rustc_macros::HashStable; use std::borrow::Cow; use std::cell::Cell; @@ -3047,7 +3047,7 @@ pub fn report_missing_lifetime_specifiers( span, E0106, "missing lifetime specifier{}", - if count > 1 { "s" } else { "" } + pluralise!(count) ) } diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 03cc00d87e3cd..0b06ec0703811 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -33,7 +33,7 @@ use crate::ty::subst::Subst; use crate::ty::SubtypePredicate; use crate::util::nodemap::{FxHashMap, FxHashSet}; -use errors::{Applicability, DiagnosticBuilder}; +use errors::{Applicability, DiagnosticBuilder, pluralise}; use std::fmt; use syntax::ast; use syntax::symbol::{sym, kw}; @@ -1186,7 +1186,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { _ => format!("{} {}argument{}", arg_length, if distinct && arg_length > 1 { "distinct " } else { "" }, - if arg_length == 1 { "" } else { "s" }), + pluralise!(arg_length)) } }; diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index 62910ec320494..5409cbc4129f0 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -196,7 +196,7 @@ impl<'tcx> ty::TyS<'tcx> { let n = tcx.lift_to_global(&n).unwrap(); match n.try_eval_usize(tcx, ty::ParamEnv::empty()) { Some(n) => { - format!("array of {} element{}", n, if n != 1 { "s" } else { "" }).into() + format!("array of {} element{}", n, pluralise!(n)).into() } None => "array".into(), } diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index c3975098351af..2d4af2f606a2c 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -9,7 +9,7 @@ use lint::{LintPass, EarlyLintPass, LateLintPass}; use syntax::ast; use syntax::attr; -use syntax::errors::Applicability; +use syntax::errors::{Applicability, pluralise}; use syntax::feature_gate::{AttributeType, BuiltinAttribute, BUILTIN_ATTRIBUTE_MAP}; use syntax::print::pprust; use syntax::symbol::{kw, sym}; @@ -48,7 +48,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { } let ty = cx.tables.expr_ty(&expr); - let type_permits_lack_of_use = check_must_use_ty(cx, ty, &expr, s.span, "", "", false); + let type_permits_lack_of_use = check_must_use_ty(cx, ty, &expr, s.span, "", "", 1); let mut fn_warned = false; let mut op_warned = false; @@ -135,7 +135,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { span: Span, descr_pre: &str, descr_post: &str, - plural: bool, + plural_len: usize, ) -> bool { if ty.is_unit() || cx.tcx.is_ty_uninhabited_from( cx.tcx.hir().get_module_parent(expr.hir_id), ty) @@ -143,13 +143,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { return true; } - let plural_suffix = if plural { "s" } else { "" }; + let plural_suffix = pluralise!(plural_len); match ty.sty { ty::Adt(..) if ty.is_box() => { let boxed_ty = ty.boxed_ty(); let descr_pre = &format!("{}boxed ", descr_pre); - check_must_use_ty(cx, boxed_ty, expr, span, descr_pre, descr_post, plural) + check_must_use_ty(cx, boxed_ty, expr, span, descr_pre, descr_post, plural_len) } ty::Adt(def, _) => { check_must_use_def(cx, def.did, span, descr_pre, descr_post) @@ -202,7 +202,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { for (i, ty) in tys.iter().map(|k| k.expect_ty()).enumerate() { let descr_post = &format!(" in tuple element {}", i); let span = *spans.get(i).unwrap_or(&span); - if check_must_use_ty(cx, ty, expr, span, descr_pre, descr_post, plural) { + if check_must_use_ty( + cx, + ty, + expr, + span, + descr_pre, + descr_post, + plural_len + ) { has_emitted = true; } } @@ -216,7 +224,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { descr_pre, plural_suffix, ); - check_must_use_ty(cx, ty, expr, span, descr_pre, descr_post, true) + check_must_use_ty(cx, ty, expr, span, descr_pre, descr_post, n as usize + 1) } // Otherwise, we don't lint, to avoid false positives. _ => false, diff --git a/src/librustc_resolve/check_unused.rs b/src/librustc_resolve/check_unused.rs index 96d44b4b4c0dc..0d85be83e12e0 100644 --- a/src/librustc_resolve/check_unused.rs +++ b/src/librustc_resolve/check_unused.rs @@ -26,6 +26,8 @@ use crate::Resolver; use crate::resolve_imports::ImportDirectiveSubclass; +use errors::pluralise; + use rustc::util::nodemap::NodeMap; use rustc::{lint, ty}; use rustc_data_structures::fx::FxHashSet; @@ -295,7 +297,7 @@ impl Resolver<'_> { }).collect::>(); span_snippets.sort(); let msg = format!("unused import{}{}", - if len > 1 { "s" } else { "" }, + pluralise!(len), if !span_snippets.is_empty() { format!(": {}", span_snippets.join(", ")) } else { diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index e77e8290f1faa..360343169bc3d 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -11,7 +11,7 @@ use crate::{Resolver, ResolutionError, Segment, ModuleKind}; use crate::{names_to_string, module_to_string}; use crate::diagnostics::Suggestion; -use errors::Applicability; +use errors::{Applicability, pluralise}; use rustc_data_structures::ptr_key::PtrKey; use rustc::ty; @@ -728,7 +728,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> { let msg = format!( "unresolved import{} {}", - if paths.len() > 1 { "s" } else { "" }, + pluralise!(paths.len()), paths.join(", "), ); diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 09e6b76900396..718d12484f741 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1346,7 +1346,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { span, E0191, "the value of the associated type{} {} must be specified", - if associated_types.len() == 1 { "" } else { "s" }, + pluralise!(associated_types.len()), names, ); let (suggest, potential_assoc_types_spans) = diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs index 56bd903040ab4..ef3f40dfdd987 100644 --- a/src/librustc_typeck/check/expr.rs +++ b/src/librustc_typeck/check/expr.rs @@ -17,7 +17,7 @@ use crate::util::common::ErrorReported; use crate::util::nodemap::FxHashMap; use crate::astconv::AstConv as _; -use errors::{Applicability, DiagnosticBuilder}; +use errors::{Applicability, DiagnosticBuilder, pluralise}; use syntax::ast; use syntax::symbol::{Symbol, kw, sym}; use syntax::source_map::Span; @@ -1178,7 +1178,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { struct_span_err!(tcx.sess, span, E0063, "missing field{} {}{} in initializer of `{}`", - if remaining_fields.len() == 1 { "" } else { "s" }, + pluralise!(remaining_fields.len()), remaining_fields_names, truncated_fields_error, adt_ty) diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 3e45b1e98d4ec..74e4f28255b16 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -5,7 +5,7 @@ use crate::check::FnCtxt; use crate::middle::lang_items::FnOnceTraitLangItem; use crate::namespace::Namespace; use crate::util::nodemap::FxHashSet; -use errors::{Applicability, DiagnosticBuilder}; +use errors::{Applicability, DiagnosticBuilder, pluralise}; use rustc::hir::{self, ExprKind, Node, QPath}; use rustc::hir::def::{Res, DefKind}; use rustc::hir::def_id::{CRATE_DEF_INDEX, LOCAL_CRATE, DefId}; @@ -560,7 +560,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let help = format!("{an}other candidate{s} {were} found in the following \ trait{s}, perhaps add a `use` for {one_of_them}:", an = if candidates.len() == 1 {"an" } else { "" }, - s = if candidates.len() == 1 { "" } else { "s" }, + s = pluralise!(candidates.len()), were = if candidates.len() == 1 { "was" } else { "were" }, one_of_them = if candidates.len() == 1 { "it" diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 1197160fa9501..bd6586aa0777e 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -88,7 +88,7 @@ pub mod intrinsic; mod op; use crate::astconv::{AstConv, PathSeg}; -use errors::{Applicability, DiagnosticBuilder, DiagnosticId}; +use errors::{Applicability, DiagnosticBuilder, DiagnosticId, pluralise}; use rustc::hir::{self, ExprKind, GenericArg, ItemKind, Node, PatKind, QPath}; use rustc::hir::def::{CtorOf, Res, DefKind}; use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; @@ -4843,5 +4843,5 @@ fn fatally_break_rust(sess: &Session) { } fn potentially_plural_count(count: usize, word: &str) -> String { - format!("{} {}{}", count, word, if count == 1 { "" } else { "s" }) + format!("{} {}{}", count, word, pluralise!(count)) } diff --git a/src/librustc_typeck/check/pat.rs b/src/librustc_typeck/check/pat.rs index 8502b89de1469..d93a4052cd393 100644 --- a/src/librustc_typeck/check/pat.rs +++ b/src/librustc_typeck/check/pat.rs @@ -1,6 +1,6 @@ use crate::check::FnCtxt; use crate::util::nodemap::FxHashMap; -use errors::{Applicability, DiagnosticBuilder}; +use errors::{Applicability, DiagnosticBuilder, pluralise}; use rustc::hir::{self, PatKind, Pat, HirId}; use rustc::hir::def::{Res, DefKind, CtorKind}; use rustc::hir::pat_util::EnumerateAndAdjustIterator; @@ -684,8 +684,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } fn e0023(&self, pat_span: Span, res: Res, subpats: &'tcx [P], fields: &[ty::FieldDef]) { - let subpats_ending = if subpats.len() == 1 { "" } else { "s" }; - let fields_ending = if fields.len() == 1 { "" } else { "s" }; + let subpats_ending = pluralise!(subpats.len()); + let fields_ending = pluralise!(fields.len()); let res_span = self.tcx.def_span(res.def_id()); struct_span_err!( self.tcx.sess, @@ -1103,10 +1103,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { E0527, "pattern requires {} element{} but array has {}", min_len, - if min_len != 1 { "s" } else { "" }, + pluralise!(min_len), size, ) - .span_label(span, format!("expected {} element{}", size, if size != 1 { "s" } else { "" })) + .span_label(span, format!("expected {} element{}", size, pluralise!(size))) .emit(); } @@ -1117,14 +1117,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { E0528, "pattern requires at least {} element{} but array has {}", min_len, - if min_len != 1 { "s" } else { "" }, + pluralise!(min_len), size, ).span_label( span, format!( "pattern cannot match array of {} element{}", size, - if size != 1 { "s" } else { "" }, + pluralise!(size), ), ).emit(); } diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 23735727fe8cf..f9c07e3a2e4ff 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -8,6 +8,7 @@ use crate::tokenstream::{DelimSpan, TokenStream, TokenTree, TreeAndJoint}; use smallvec::{smallvec, SmallVec}; +use errors::pluralise; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::Lrc; use syntax_pos::hygiene::{ExpnId, Transparency}; @@ -348,10 +349,10 @@ impl LockstepIterSize { "meta-variable `{}` repeats {} time{}, but `{}` repeats {} time{}", l_id, l_len, - if l_len != 1 { "s" } else { "" }, + pluralise!(l_len), r_id, r_len, - if r_len != 1 { "s" } else { "" }, + pluralise!(r_len), ); LockstepIterSize::Contradiction(msg) } diff --git a/src/libsyntax/parse/diagnostics.rs b/src/libsyntax/parse/diagnostics.rs index b74f2492c351f..2d7f4f71ca4ee 100644 --- a/src/libsyntax/parse/diagnostics.rs +++ b/src/libsyntax/parse/diagnostics.rs @@ -11,7 +11,7 @@ use crate::ptr::P; use crate::symbol::{kw, sym}; use crate::ThinVec; use crate::util::parser::AssocOp; -use errors::{Applicability, DiagnosticBuilder, DiagnosticId}; +use errors::{Applicability, DiagnosticBuilder, DiagnosticId, pluralise}; use rustc_data_structures::fx::FxHashSet; use syntax_pos::{Span, DUMMY_SP, MultiSpan, SpanSnippetError}; use log::{debug, trace}; @@ -532,15 +532,15 @@ impl<'a> Parser<'a> { self.eat_to_tokens(&[&end]); let span = lo.until(self.token.span); - let plural = number_of_gt > 1 || number_of_shr >= 1; + let total_num_of_gt = number_of_gt + number_of_shr * 2; self.diagnostic() .struct_span_err( span, - &format!("unmatched angle bracket{}", if plural { "s" } else { "" }), + &format!("unmatched angle bracket{}", pluralise!(total_num_of_gt)), ) .span_suggestion( span, - &format!("remove extra angle bracket{}", if plural { "s" } else { "" }), + &format!("remove extra angle bracket{}", pluralise!(total_num_of_gt)), String::new(), Applicability::MachineApplicable, ) diff --git a/src/libsyntax/parse/parser/path.rs b/src/libsyntax/parse/parser/path.rs index d4b13cc2e0121..dcd3c64801742 100644 --- a/src/libsyntax/parse/parser/path.rs +++ b/src/libsyntax/parse/parser/path.rs @@ -9,7 +9,7 @@ use crate::symbol::kw; use std::mem; use log::debug; -use errors::{Applicability}; +use errors::{Applicability, pluralise}; /// Specifies how to parse a path. #[derive(Copy, Clone, PartialEq)] @@ -347,20 +347,19 @@ impl<'a> Parser<'a> { let span = lo.with_hi( lo.lo() + BytePos(snapshot.unmatched_angle_bracket_count) ); - let plural = snapshot.unmatched_angle_bracket_count > 1; self.diagnostic() .struct_span_err( span, &format!( "unmatched angle bracket{}", - if plural { "s" } else { "" } + pluralise!(snapshot.unmatched_angle_bracket_count) ), ) .span_suggestion( span, &format!( "remove extra angle bracket{}", - if plural { "s" } else { "" } + pluralise!(snapshot.unmatched_angle_bracket_count) ), String::new(), Applicability::MachineApplicable, diff --git a/src/libsyntax/parse/parser/ty.rs b/src/libsyntax/parse/parser/ty.rs index 465e31ac57e64..5697edd8e4867 100644 --- a/src/libsyntax/parse/parser/ty.rs +++ b/src/libsyntax/parse/parser/ty.rs @@ -11,7 +11,7 @@ use crate::symbol::{kw}; use rustc_target::spec::abi::Abi; -use errors::{Applicability}; +use errors::{Applicability, pluralise}; /// Returns `true` if `IDENT t` can start a type -- `IDENT::a::b`, `IDENT`, /// `IDENT<::AssocTy>`. @@ -397,7 +397,7 @@ impl<'a> Parser<'a> { } if !negative_bounds.is_empty() || was_negative { - let plural = negative_bounds.len() > 1; + let negative_bounds_len = negative_bounds.len(); let last_span = negative_bounds.last().map(|sp| *sp); let mut err = self.struct_span_err( negative_bounds, @@ -420,7 +420,7 @@ impl<'a> Parser<'a> { } err.span_suggestion_hidden( bound_list, - &format!("remove the trait bound{}", if plural { "s" } else { "" }), + &format!("remove the trait bound{}", pluralise!(negative_bounds_len)), new_bound_list, Applicability::MachineApplicable, ); diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 46c7cbb83de90..26455df17b896 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -5,6 +5,7 @@ use fmt_macros as parse; use errors::DiagnosticBuilder; use errors::Applicability; +use errors::pluralise; use syntax::ast; use syntax::ext::base::{self, *}; @@ -299,7 +300,7 @@ impl<'a, 'b> Context<'a, 'b> { &format!( "{} positional argument{} in format string, but {}", count, - if count != 1 { "s" } else { "" }, + pluralise!(count), self.describe_num_args(), ), ); From fde8cfe130db3826b88247318551d34d2bb63276 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 19 Sep 2019 09:24:42 -0700 Subject: [PATCH 22/63] rustbuild: Turn down compression on msi installers This is the same as #64615 except applied to our MSI installers. The same fix is applied effectively bringing these installers in line with the gz tarball installers, which are about 3x faster to produce locally and likely much faster to produce on CI. --- src/etc/installer/msi/rust.wxs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/etc/installer/msi/rust.wxs b/src/etc/installer/msi/rust.wxs index a471ccc6f5b48..a2e378f7b1db4 100644 --- a/src/etc/installer/msi/rust.wxs +++ b/src/etc/installer/msi/rust.wxs @@ -152,7 +152,7 @@ - + From 265566334549bbe38e775af092f9b991e91076e1 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 19 Sep 2019 13:15:54 -0400 Subject: [PATCH 23/63] fix tests for 2018 --- src/test/ui/async-await/issues/issue-64391-2.rs | 3 +++ src/test/ui/async-await/issues/issue-64433.rs | 1 + 2 files changed, 4 insertions(+) diff --git a/src/test/ui/async-await/issues/issue-64391-2.rs b/src/test/ui/async-await/issues/issue-64391-2.rs index 528704c0e45c3..eef2c1fb20ab4 100644 --- a/src/test/ui/async-await/issues/issue-64391-2.rs +++ b/src/test/ui/async-await/issues/issue-64391-2.rs @@ -4,6 +4,9 @@ // `"".to_string()` value was causing a (spurious) unwind path that // led us to believe that the future might be dropped after `config` // had been dropped. This cannot, in fact, happen. +// +// check-pass +// edition:2018 async fn connect() { let config = 666; diff --git a/src/test/ui/async-await/issues/issue-64433.rs b/src/test/ui/async-await/issues/issue-64433.rs index ca819e78fb8cb..802e09c8a1f00 100644 --- a/src/test/ui/async-await/issues/issue-64433.rs +++ b/src/test/ui/async-await/issues/issue-64433.rs @@ -4,6 +4,7 @@ // same PR. // // check-pass +// edition:2018 #[derive(Debug)] struct A<'a> { From c78a00991b57bdeec0f55452d14b9e4a0ccc97c4 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 19 Sep 2019 13:42:46 -0400 Subject: [PATCH 24/63] whoops, only trigger this path for avoiding DROP, not StorageDead --- src/librustc_mir/build/scope.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs index 13d94262b6c53..a26ec72584bda 100644 --- a/src/librustc_mir/build/scope.rs +++ b/src/librustc_mir/build/scope.rs @@ -1123,16 +1123,16 @@ fn build_scope_drops<'tcx>( let source_info = scope.source_info(drop_data.span); let local = drop_data.local; - // If the operand has been moved, and we are not on an unwind - // path, then don't generate the drop. (We only take this into - // account for non-unwind paths so as not to disturb the - // caching mechanism.) - if !is_cached_path && scope.moved_locals.iter().any(|&o| o == local) { - continue; - } - match drop_data.kind { DropKind::Value => { + // If the operand has been moved, and we are not on an unwind + // path, then don't generate the drop. (We only take this into + // account for non-unwind paths so as not to disturb the + // caching mechanism.) + if !is_cached_path && scope.moved_locals.iter().any(|&o| o == local) { + continue; + } + let unwind_to = get_unwind_to(scope, is_generator, drop_idx, generator_drop) .unwrap_or(last_unwind_to); From 255dd3ff42aecdc36da800e5bbfe0c09e83fa066 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 19 Sep 2019 11:22:55 -0700 Subject: [PATCH 25/63] rustbuild: Improve output of `dist` step * Pass `/Q` to `iscc` on Windows to supress the thousands of lines of output about compressing documentation. * Print out what's happening before long steps * Use `timeit` to print out timing information for long-running installer assemblies. --- src/bootstrap/dist.rs | 66 ++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 19 deletions(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 076bcd878df71..50b20763c43d2 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -18,7 +18,7 @@ use build_helper::{output, t}; use crate::{Compiler, Mode, LLVM_TOOLS}; use crate::channel; -use crate::util::{is_dylib, exe}; +use crate::util::{is_dylib, exe, timeit}; use crate::builder::{Builder, RunConfig, ShouldRun, Step}; use crate::compile; use crate::tool::{self, Tool}; @@ -91,14 +91,15 @@ impl Step for Docs { let name = pkgname(builder, "rust-docs"); - builder.info(&format!("Dist docs ({})", host)); if !builder.config.docs { - builder.info("\tskipping - docs disabled"); return distdir(builder).join(format!("{}-{}.tar.gz", name, host)); } builder.default_doc(None); + builder.info(&format!("Dist docs ({})", host)); + let _time = timeit(builder); + let image = tmpdir(builder).join(format!("{}-{}-image", name, host)); let _ = fs::remove_dir_all(&image); @@ -151,9 +152,7 @@ impl Step for RustcDocs { let name = pkgname(builder, "rustc-docs"); - builder.info(&format!("Dist compiler docs ({})", host)); if !builder.config.compiler_docs { - builder.info("\tskipping - compiler docs disabled"); return distdir(builder).join(format!("{}-{}.tar.gz", name, host)); } @@ -179,6 +178,9 @@ impl Step for RustcDocs { .arg("--component-name=rustc-docs") .arg("--legacy-manifest-dirs=rustlib,cargo") .arg("--bulk-dirs=share/doc/rust/html"); + + builder.info(&format!("Dist compiler docs ({})", host)); + let _time = timeit(builder); builder.run(&mut cmd); builder.remove_dir(&image); @@ -350,6 +352,7 @@ impl Step for Mingw { } builder.info(&format!("Dist mingw ({})", host)); + let _time = timeit(builder); let name = pkgname(builder, "rust-mingw"); let image = tmpdir(builder).join(format!("{}-{}-image", name, host)); let _ = fs::remove_dir_all(&image); @@ -403,7 +406,6 @@ impl Step for Rustc { let compiler = self.compiler; let host = self.compiler.host; - builder.info(&format!("Dist rustc stage{} ({})", compiler.stage, host)); let name = pkgname(builder, "rustc"); let image = tmpdir(builder).join(format!("{}-{}-image", name, host)); let _ = fs::remove_dir_all(&image); @@ -460,6 +462,9 @@ impl Step for Rustc { .arg(format!("--package-name={}-{}", name, host)) .arg("--component-name=rustc") .arg("--legacy-manifest-dirs=rustlib,cargo"); + + builder.info(&format!("Dist rustc stage{} ({})", compiler.stage, host)); + let _time = timeit(builder); builder.run(&mut cmd); builder.remove_dir(&image); builder.remove_dir(&overlay); @@ -662,8 +667,6 @@ impl Step for Std { let target = self.target; let name = pkgname(builder, "rust-std"); - builder.info(&format!("Dist std stage{} ({} -> {})", - compiler.stage, &compiler.host, target)); // The only true set of target libraries came from the build triple, so // let's reduce redundant work by only producing archives from that host. @@ -714,6 +717,10 @@ impl Step for Std { .arg(format!("--package-name={}-{}", name, target)) .arg(format!("--component-name=rust-std-{}", target)) .arg("--legacy-manifest-dirs=rustlib,cargo"); + + builder.info(&format!("Dist std stage{} ({} -> {})", + compiler.stage, &compiler.host, target)); + let _time = timeit(builder); builder.run(&mut cmd); builder.remove_dir(&image); distdir(builder).join(format!("{}-{}.tar.gz", name, target)) @@ -754,11 +761,9 @@ impl Step for Analysis { let compiler = self.compiler; let target = self.target; assert!(builder.config.extended); - builder.info("Dist analysis"); let name = pkgname(builder, "rust-analysis"); if &compiler.host != builder.config.build { - builder.info("\tskipping, not a build host"); return distdir(builder).join(format!("{}-{}.tar.gz", name, target)); } @@ -786,6 +791,9 @@ impl Step for Analysis { .arg(format!("--package-name={}-{}", name, target)) .arg(format!("--component-name=rust-analysis-{}", target)) .arg("--legacy-manifest-dirs=rustlib,cargo"); + + builder.info("Dist analysis"); + let _time = timeit(builder); builder.run(&mut cmd); builder.remove_dir(&image); distdir(builder).join(format!("{}-{}.tar.gz", name, target)) @@ -874,8 +882,6 @@ impl Step for Src { /// Creates the `rust-src` installer component fn run(self, builder: &Builder<'_>) -> PathBuf { - builder.info("Dist src"); - let name = pkgname(builder, "rust-src"); let image = tmpdir(builder).join(format!("{}-image", name)); let _ = fs::remove_dir_all(&image); @@ -930,6 +936,9 @@ impl Step for Src { .arg(format!("--package-name={}", name)) .arg("--component-name=rust-src") .arg("--legacy-manifest-dirs=rustlib,cargo"); + + builder.info("Dist src"); + let _time = timeit(builder); builder.run(&mut cmd); builder.remove_dir(&image); @@ -957,8 +966,6 @@ impl Step for PlainSourceTarball { /// Creates the plain source tarball fn run(self, builder: &Builder<'_>) -> PathBuf { - builder.info("Create plain source tarball"); - // Make sure that the root folder of tarball has the correct name let plain_name = format!("{}-src", pkgname(builder, "rustc")); let plain_dst_src = tmpdir(builder).join(&plain_name); @@ -1020,6 +1027,9 @@ impl Step for PlainSourceTarball { .arg("--output").arg(&tarball) .arg("--work-dir=.") .current_dir(tmpdir(builder)); + + builder.info("Create plain source tarball"); + let _time = timeit(builder); builder.run(&mut cmd); distdir(builder).join(&format!("{}.tar.gz", plain_name)) } @@ -1073,7 +1083,6 @@ impl Step for Cargo { let compiler = self.compiler; let target = self.target; - builder.info(&format!("Dist cargo stage{} ({})", compiler.stage, target)); let src = builder.src.join("src/tools/cargo"); let etc = src.join("src/etc"); let release_num = builder.release_num("cargo"); @@ -1126,6 +1135,9 @@ impl Step for Cargo { .arg(format!("--package-name={}-{}", name, target)) .arg("--component-name=cargo") .arg("--legacy-manifest-dirs=rustlib,cargo"); + + builder.info(&format!("Dist cargo stage{} ({})", compiler.stage, target)); + let _time = timeit(builder); builder.run(&mut cmd); distdir(builder).join(format!("{}-{}.tar.gz", name, target)) } @@ -1161,7 +1173,6 @@ impl Step for Rls { let target = self.target; assert!(builder.config.extended); - builder.info(&format!("Dist RLS stage{} ({})", compiler.stage, target)); let src = builder.src.join("src/tools/rls"); let release_num = builder.release_num("rls"); let name = pkgname(builder, "rls"); @@ -1210,6 +1221,8 @@ impl Step for Rls { .arg("--legacy-manifest-dirs=rustlib,cargo") .arg("--component-name=rls-preview"); + builder.info(&format!("Dist RLS stage{} ({})", compiler.stage, target)); + let _time = timeit(builder); builder.run(&mut cmd); Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target))) } @@ -1245,7 +1258,6 @@ impl Step for Clippy { let target = self.target; assert!(builder.config.extended); - builder.info(&format!("Dist clippy stage{} ({})", compiler.stage, target)); let src = builder.src.join("src/tools/clippy"); let release_num = builder.release_num("clippy"); let name = pkgname(builder, "clippy"); @@ -1299,6 +1311,8 @@ impl Step for Clippy { .arg("--legacy-manifest-dirs=rustlib,cargo") .arg("--component-name=clippy-preview"); + builder.info(&format!("Dist clippy stage{} ({})", compiler.stage, target)); + let _time = timeit(builder); builder.run(&mut cmd); Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target))) } @@ -1334,7 +1348,6 @@ impl Step for Miri { let target = self.target; assert!(builder.config.extended); - builder.info(&format!("Dist miri stage{} ({})", compiler.stage, target)); let src = builder.src.join("src/tools/miri"); let release_num = builder.release_num("miri"); let name = pkgname(builder, "miri"); @@ -1389,6 +1402,8 @@ impl Step for Miri { .arg("--legacy-manifest-dirs=rustlib,cargo") .arg("--component-name=miri-preview"); + builder.info(&format!("Dist miri stage{} ({})", compiler.stage, target)); + let _time = timeit(builder); builder.run(&mut cmd); Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target))) } @@ -1423,7 +1438,6 @@ impl Step for Rustfmt { let compiler = self.compiler; let target = self.target; - builder.info(&format!("Dist Rustfmt stage{} ({})", compiler.stage, target)); let src = builder.src.join("src/tools/rustfmt"); let release_num = builder.release_num("rustfmt"); let name = pkgname(builder, "rustfmt"); @@ -1476,6 +1490,8 @@ impl Step for Rustfmt { .arg("--legacy-manifest-dirs=rustlib,cargo") .arg("--component-name=rustfmt-preview"); + builder.info(&format!("Dist Rustfmt stage{} ({})", compiler.stage, target)); + let _time = timeit(builder); builder.run(&mut cmd); Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target))) } @@ -1576,6 +1592,7 @@ impl Step for Extended { input_tarballs.push(tarball); } + builder.info("building combined installer"); let mut cmd = rust_installer(builder); cmd.arg("combine") .arg("--product-name=Rust") @@ -1587,7 +1604,9 @@ impl Step for Extended { .arg("--legacy-manifest-dirs=rustlib,cargo") .arg("--input-tarballs").arg(input_tarballs) .arg("--non-installed-overlay").arg(&overlay); + let time = timeit(&builder); builder.run(&mut cmd); + drop(time); let mut license = String::new(); license += &builder.read(&builder.src.join("COPYRIGHT")); @@ -1643,6 +1662,7 @@ impl Step for Extended { }; if target.contains("apple-darwin") { + builder.info("building pkg installer"); let pkg = tmp.join("pkg"); let _ = fs::remove_dir_all(&pkg); @@ -1692,6 +1712,7 @@ impl Step for Extended { pkgname(builder, "rust"), target))) .arg("--package-path").arg(&pkg); + let _time = timeit(builder); builder.run(&mut cmd); } @@ -1742,14 +1763,18 @@ impl Step for Extended { builder.create(&exe.join("LICENSE.txt"), &license); // Generate exe installer + builder.info("building `exe` installer with `iscc`"); let mut cmd = Command::new("iscc"); cmd.arg("rust.iss") + .arg("/Q") .current_dir(&exe); if target.contains("windows-gnu") { cmd.arg("/dMINGW"); } add_env(builder, &mut cmd, target); + let time = timeit(builder); builder.run(&mut cmd); + drop(time); builder.install(&exe.join(format!("{}-{}.exe", pkgname(builder, "rust"), target)), &distdir(builder), 0o755); @@ -1914,6 +1939,7 @@ impl Step for Extended { builder.install(&etc.join("gfx/banner.bmp"), &exe, 0o644); builder.install(&etc.join("gfx/dialogbg.bmp"), &exe, 0o644); + builder.info(&format!("building `msi` installer with {:?}", light)); let filename = format!("{}-{}.msi", pkgname(builder, "rust"), target); let mut cmd = Command::new(&light); cmd.arg("-nologo") @@ -1946,6 +1972,7 @@ impl Step for Extended { // ICE57 wrongly complains about the shortcuts cmd.arg("-sice:ICE57"); + let _time = timeit(builder); builder.run(&mut cmd); if !builder.config.dry_run { @@ -2114,6 +2141,7 @@ impl Step for LlvmTools { } builder.info(&format!("Dist LlvmTools ({})", target)); + let _time = timeit(builder); let src = builder.src.join("src/llvm-project/llvm"); let name = pkgname(builder, "llvm-tools"); From 1962d75c10363e1754df5526ed8fa01d22e42f24 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 19 Sep 2019 14:30:05 -0400 Subject: [PATCH 26/63] fix mir-opt tests --- src/test/mir-opt/box_expr.rs | 15 +++-------- .../mir-opt/generator-storage-dead-unwind.rs | 26 +++++++++---------- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/test/mir-opt/box_expr.rs b/src/test/mir-opt/box_expr.rs index d9fa3d3d4736d..8dc6b73edf6d4 100644 --- a/src/test/mir-opt/box_expr.rs +++ b/src/test/mir-opt/box_expr.rs @@ -57,25 +57,18 @@ impl Drop for S { // } // // bb5: { -// drop(_4) -> [return: bb8, unwind: bb6]; +// StorageDead(_4); +// StorageDead(_3); +// _0 = (); +// drop(_1) -> bb8; // } -// // bb6 (cleanup): { // drop(_1) -> bb1; // } -// // bb7 (cleanup): { // drop(_4) -> bb6; // } -// // bb8: { -// StorageDead(_4); -// StorageDead(_3); -// _0 = (); -// drop(_1) -> bb9; -// } -// -// bb9: { // StorageDead(_1); // return; // } diff --git a/src/test/mir-opt/generator-storage-dead-unwind.rs b/src/test/mir-opt/generator-storage-dead-unwind.rs index bcdb937542716..109304d6d22cc 100644 --- a/src/test/mir-opt/generator-storage-dead-unwind.rs +++ b/src/test/mir-opt/generator-storage-dead-unwind.rs @@ -57,7 +57,7 @@ fn main() { // StorageLive(_6); // StorageLive(_7); // _7 = move _2; -// _6 = const take::(move _7) -> [return: bb9, unwind: bb8]; +// _6 = const take::(move _7) -> [return: bb7, unwind: bb9]; // } // bb3 (cleanup): { // StorageDead(_2); @@ -75,17 +75,7 @@ fn main() { // bb6: { // generator_drop; // } -// bb7 (cleanup): { -// StorageDead(_3); -// StorageDead(_2); -// drop(_1) -> bb1; -// } -// bb8 (cleanup): { -// StorageDead(_7); -// StorageDead(_6); -// goto -> bb7; -// } -// bb9: { +// bb7: { // StorageDead(_7); // StorageDead(_6); // StorageLive(_8); @@ -93,6 +83,16 @@ fn main() { // _9 = move _3; // _8 = const take::(move _9) -> [return: bb10, unwind: bb11]; // } +// bb8 (cleanup): { +// StorageDead(_3); +// StorageDead(_2); +// drop(_1) -> bb1; +// } +// bb9 (cleanup): { +// StorageDead(_7); +// StorageDead(_6); +// goto -> bb8; +// } // bb10: { // StorageDead(_9); // StorageDead(_8); @@ -104,7 +104,7 @@ fn main() { // bb11 (cleanup): { // StorageDead(_9); // StorageDead(_8); -// goto -> bb7; +// goto -> bb8; // } // bb12: { // return; From 77fd0a76491afb4c93359f6ceb33a9f79c4f4228 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 19 Sep 2019 16:12:48 -0400 Subject: [PATCH 27/63] add a mir-opt test that we don't add the spurious drop --- .../mir-opt/no-spurious-drop-after-call.rs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/test/mir-opt/no-spurious-drop-after-call.rs diff --git a/src/test/mir-opt/no-spurious-drop-after-call.rs b/src/test/mir-opt/no-spurious-drop-after-call.rs new file mode 100644 index 0000000000000..782bc31186ca5 --- /dev/null +++ b/src/test/mir-opt/no-spurious-drop-after-call.rs @@ -0,0 +1,24 @@ +// ignore-wasm32-bare compiled with panic=abort by default + +// Test that after the call to `std::mem::drop` we do not generate a +// MIR drop of the argument. (We used to have a `DROP(_2)` in the code +// below, as part of bb3.) + +fn main() { + std::mem::drop("".to_string()); +} + +// END RUST SOURCE +// START rustc.main.ElaborateDrops.before.mir +// bb2: { +// StorageDead(_3); +// _1 = const std::mem::drop::(move _2) -> [return: bb3, unwind: bb4]; +// } +// bb3: { +// StorageDead(_2); +// StorageDead(_4); +// StorageDead(_1); +// _0 = (); +// return; +// } +// END rustc.main.ElaborateDrops.before.mir From 3db2c13d893865e8e6929d5259bbac7d89a7ba06 Mon Sep 17 00:00:00 2001 From: Erin Power Date: Thu, 19 Sep 2019 21:53:40 +0200 Subject: [PATCH 28/63] Add Compatibility Notes to RELEASES.md for 1.38.0 --- RELEASES.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index d634feba33ac5..ecf49278f4b52 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -68,6 +68,13 @@ Misc - [`rustc` will now warn about some incorrect uses of `mem::{uninitialized, zeroed}` that are known to cause undefined behaviour.][63346] +Compatibility Notes +------------------- +- Unfortunately the [`x86_64-unknown-uefi` platform can not be built][62785] + with rustc 1.39.0. +- The [`armv7-unknown-linux-gnueabihf` platform is also known to have + issues][62896] for certain crates such as libc. + [60260]: https://github.com/rust-lang/rust/pull/60260/ [61457]: https://github.com/rust-lang/rust/pull/61457/ [61491]: https://github.com/rust-lang/rust/pull/61491/ @@ -79,7 +86,9 @@ Misc [62735]: https://github.com/rust-lang/rust/pull/62735/ [62766]: https://github.com/rust-lang/rust/pull/62766/ [62784]: https://github.com/rust-lang/rust/pull/62784/ +[62785]: https://github.com/rust-lang/rust/issues/62785/ [62814]: https://github.com/rust-lang/rust/pull/62814/ +[62896]: https://github.com/rust-lang/rust/issues/62896/ [63000]: https://github.com/rust-lang/rust/pull/63000/ [63056]: https://github.com/rust-lang/rust/pull/63056/ [63107]: https://github.com/rust-lang/rust/pull/63107/ From c3140bae633b265657c0094f6df6edf630d1d917 Mon Sep 17 00:00:00 2001 From: guanqun Date: Sat, 21 Sep 2019 00:22:43 +0800 Subject: [PATCH 29/63] remove the extra comma after the match arm This would follow the same coding style as all the other match arms in this file. --- src/librustc_resolve/late/diagnostics.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_resolve/late/diagnostics.rs b/src/librustc_resolve/late/diagnostics.rs index 0c86d8494fde8..df8bd3fa75e14 100644 --- a/src/librustc_resolve/late/diagnostics.rs +++ b/src/librustc_resolve/late/diagnostics.rs @@ -424,7 +424,7 @@ impl<'a> LateResolutionVisitor<'a, '_> { } else { err.note("did you mean to use one of the enum's variants?"); } - }, + } (Res::Def(DefKind::Struct, def_id), _) if ns == ValueNS => { if let Some((ctor_def, ctor_vis)) = self.r.struct_constructors.get(&def_id).cloned() { From 633ad73ef17c02e1893becbd030e2d188851042c Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 20 Sep 2019 09:36:03 -0700 Subject: [PATCH 30/63] Update to LLVM 9.0.0 --- .gitmodules | 2 +- src/llvm-project | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index f64e21c5af0e4..3ff5af78097fa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -43,7 +43,7 @@ [submodule "src/llvm-project"] path = src/llvm-project url = https://github.com/rust-lang/llvm-project.git - branch = rustc/9.0-2019-07-12 + branch = rustc/9.0-2019-09-19 [submodule "src/doc/embedded-book"] path = src/doc/embedded-book url = https://github.com/rust-embedded/book.git diff --git a/src/llvm-project b/src/llvm-project index 71fe7ec06b85f..8adf9bdccfefb 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 71fe7ec06b85f612fc0e4eb4134c7a7d0f23fac5 +Subproject commit 8adf9bdccfefb8d03f0e8db3b012fb41da1580a4 From 9cf9030e1cc4c6231419f5e9f7a5bd42eb1f55c1 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Fri, 20 Sep 2019 18:39:13 +0200 Subject: [PATCH 31/63] Allow using fn pointers in const fn behind const_fn_ptr gate --- src/librustc_mir/transform/qualify_consts.rs | 20 ++++++++++--- src/libsyntax/feature_gate/active.rs | 3 ++ src/libsyntax_pos/symbol.rs | 1 + src/test/ui/consts/const-eval/const_fn_ptr.rs | 21 ++++++++++++++ .../ui/consts/const-eval/const_fn_ptr_fail.rs | 15 ++++++++++ .../const-eval/const_fn_ptr_fail.stderr | 20 +++++++++++++ .../consts/const-eval/const_fn_ptr_fail2.rs | 21 ++++++++++++++ .../const-eval/const_fn_ptr_fail2.stderr | 28 +++++++++++++++++++ .../const-eval/feature-gate-const_fn_ptr.rs | 11 ++++++++ .../feature-gate-const_fn_ptr.stderr | 12 ++++++++ 10 files changed, 148 insertions(+), 4 deletions(-) create mode 100644 src/test/ui/consts/const-eval/const_fn_ptr.rs create mode 100644 src/test/ui/consts/const-eval/const_fn_ptr_fail.rs create mode 100644 src/test/ui/consts/const-eval/const_fn_ptr_fail.stderr create mode 100644 src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs create mode 100644 src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr create mode 100644 src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.rs create mode 100644 src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.stderr diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 7cc1e634cf812..3842942d97fbb 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -1407,11 +1407,23 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { } } ty::FnPtr(_) => { + let unleash_miri = self + .tcx + .sess + .opts + .debugging_opts + .unleash_the_miri_inside_of_you; + let const_fn_ptr = self.tcx.features().const_fn_ptr; if self.mode.requires_const_checking() { - let mut err = self.tcx.sess.struct_span_err( - self.span, - &format!("function pointers are not allowed in const fn")); - err.emit(); + if !(unleash_miri || const_fn_ptr) { + emit_feature_err( + &self.tcx.sess.parse_sess, + sym::const_fn_ptr, + self.span, + GateIssue::Language, + "function pointers in const fn are unstable", + ); + } } } _ => { diff --git a/src/libsyntax/feature_gate/active.rs b/src/libsyntax/feature_gate/active.rs index dd78777b56986..d1a17dc14bdf7 100644 --- a/src/libsyntax/feature_gate/active.rs +++ b/src/libsyntax/feature_gate/active.rs @@ -405,6 +405,9 @@ declare_features! ( /// Allows macro invocations in `extern {}` blocks. (active, macros_in_extern, "1.27.0", Some(49476), None), + /// Allows calling function pointers inside `const` functions. + (active, const_fn_ptr, "1.27.0", Some(51909), None), + /// Allows accessing fields of unions inside `const` functions. (active, const_fn_union, "1.27.0", Some(51909), None), diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 597ae83572cee..e6be8a2cb874a 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -198,6 +198,7 @@ symbols! { const_compare_raw_pointers, const_constructor, const_fn, + const_fn_ptr, const_fn_union, const_generics, const_indexing, diff --git a/src/test/ui/consts/const-eval/const_fn_ptr.rs b/src/test/ui/consts/const-eval/const_fn_ptr.rs new file mode 100644 index 0000000000000..1acb3d8ad1065 --- /dev/null +++ b/src/test/ui/consts/const-eval/const_fn_ptr.rs @@ -0,0 +1,21 @@ +// run-pass +#![feature(const_fn)] +#![feature(const_fn_ptr)] + +const fn double(x: usize) -> usize { x * 2 } +const X: fn(usize) -> usize = double; + +const fn bar(x: usize) -> usize { + X(x) +} + +const fn foo(x: fn(usize) -> usize, y: usize) -> usize { + x(y) +} + +fn main() { + const Y: usize = bar(2); + assert_eq!(Y, 4); + const Z: usize = foo(double, 2); + assert_eq!(Z, 4); +} diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail.rs b/src/test/ui/consts/const-eval/const_fn_ptr_fail.rs new file mode 100644 index 0000000000000..e8041e56c38fb --- /dev/null +++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail.rs @@ -0,0 +1,15 @@ +// run-pass + +// FIXME: this should not pass + +#![feature(const_fn)] +#![feature(const_fn_ptr)] + +fn double(x: usize) -> usize { x * 2 } +const X: fn(usize) -> usize = double; + +const fn bar(x: usize) -> usize { + X(x) +} + +fn main() {} diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail.stderr b/src/test/ui/consts/const-eval/const_fn_ptr_fail.stderr new file mode 100644 index 0000000000000..b7f3a74cc44c0 --- /dev/null +++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail.stderr @@ -0,0 +1,20 @@ +warning: function is never used: `double` + --> $DIR/const_fn_ptr_fail.rs:8:1 + | +LL | fn double(x: usize) -> usize { x * 2 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(dead_code)]` on by default + +warning: constant item is never used: `X` + --> $DIR/const_fn_ptr_fail.rs:9:1 + | +LL | const X: fn(usize) -> usize = double; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: function is never used: `bar` + --> $DIR/const_fn_ptr_fail.rs:11:1 + | +LL | const fn bar(x: usize) -> usize { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs new file mode 100644 index 0000000000000..66e01cae31452 --- /dev/null +++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs @@ -0,0 +1,21 @@ +#![feature(const_fn)] +#![feature(const_fn_ptr)] + +fn double(x: usize) -> usize { x * 2 } +const X: fn(usize) -> usize = double; + +const fn bar(x: fn(usize) -> usize, y: usize) -> usize { + x(y) +} + +const Y: usize = bar(X, 2); +//~^ ERROR any use of this value will cause an error + +const Z: usize = bar(double, 2); +//~^ ERROR any use of this value will cause an error + + +fn main() { + assert_eq!(Y, 4); + assert_eq!(Z, 4); +} diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr new file mode 100644 index 0000000000000..020889c2ca1a0 --- /dev/null +++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr @@ -0,0 +1,28 @@ +error: any use of this value will cause an error + --> $DIR/const_fn_ptr_fail2.rs:8:5 + | +LL | x(y) + | ^^^^ + | | + | calling non-const function `double` + | inside call to `bar` at $DIR/const_fn_ptr_fail2.rs:11:18 +... +LL | const Y: usize = bar(X, 2); + | --------------------------- + | + = note: `#[deny(const_err)]` on by default + +error: any use of this value will cause an error + --> $DIR/const_fn_ptr_fail2.rs:8:5 + | +LL | x(y) + | ^^^^ + | | + | calling non-const function `double` + | inside call to `bar` at $DIR/const_fn_ptr_fail2.rs:14:18 +... +LL | const Z: usize = bar(double, 2); + | -------------------------------- + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.rs b/src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.rs new file mode 100644 index 0000000000000..ea1ca05c31b8f --- /dev/null +++ b/src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.rs @@ -0,0 +1,11 @@ +#![feature(const_fn)] + +fn main() {} + +const fn foo() {} +const X: fn() = foo; + +const fn bar() { + X() + //~^ ERROR function pointers in const fn are unstable +} diff --git a/src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.stderr b/src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.stderr new file mode 100644 index 0000000000000..fe5956d06f2a0 --- /dev/null +++ b/src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.stderr @@ -0,0 +1,12 @@ +error[E0658]: function pointers in const fn are unstable + --> $DIR/feature-gate-const_fn_ptr.rs:9:5 + | +LL | X() + | ^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/51909 + = help: add `#![feature(const_fn_ptr)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. From 9f374da46781cfe2d297636fe97b2fd9647cb1d9 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 20 Sep 2019 15:39:34 -0700 Subject: [PATCH 32/63] Exempt extern "Rust" from improper_ctypes It should be fine for Rust ABIs to involve any Rust type. --- src/liballoc/alloc.rs | 2 +- src/libcore/panicking.rs | 2 +- src/librustc_lint/types.rs | 4 +++- src/test/ui/issues/issue-64593.rs | 12 ++++++++++++ 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 src/test/ui/issues/issue-64593.rs diff --git a/src/liballoc/alloc.rs b/src/liballoc/alloc.rs index dc7fd1adc2958..a39fcd5ad4c58 100644 --- a/src/liballoc/alloc.rs +++ b/src/liballoc/alloc.rs @@ -240,7 +240,7 @@ pub(crate) unsafe fn box_free(ptr: Unique) { #[stable(feature = "global_alloc", since = "1.28.0")] #[rustc_allocator_nounwind] pub fn handle_alloc_error(layout: Layout) -> ! { - #[allow(improper_ctypes)] + #[cfg_attr(bootstrap, allow(improper_ctypes))] extern "Rust" { #[lang = "oom"] fn oom_impl(layout: Layout) -> !; diff --git a/src/libcore/panicking.rs b/src/libcore/panicking.rs index 15b7d69c58d24..3d2bc24bf24a5 100644 --- a/src/libcore/panicking.rs +++ b/src/libcore/panicking.rs @@ -71,7 +71,7 @@ pub fn panic_fmt(fmt: fmt::Arguments<'_>, file_line_col: &(&'static str, u32, u3 } // NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call - #[allow(improper_ctypes)] // PanicInfo contains a trait object which is not FFI safe + #[cfg_attr(boostrap_stdarch_ignore_this, allow(improper_ctypes))] extern "Rust" { #[lang = "panic_impl"] fn panic_impl(pi: &PanicInfo<'_>) -> !; diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 3b8c06ba154c6..40261f6d13739 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -975,7 +975,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes { fn check_foreign_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::ForeignItem) { let mut vis = ImproperCTypesVisitor { cx }; let abi = cx.tcx.hir().get_foreign_abi(it.hir_id); - if abi != Abi::RustIntrinsic && abi != Abi::PlatformIntrinsic { + if let Abi::Rust | Abi::RustCall | Abi::RustIntrinsic | Abi::PlatformIntrinsic = abi { + // Don't worry about types in internal ABIs. + } else { match it.node { hir::ForeignItemKind::Fn(ref decl, _, _) => { vis.check_foreign_fn(it.hir_id, decl); diff --git a/src/test/ui/issues/issue-64593.rs b/src/test/ui/issues/issue-64593.rs new file mode 100644 index 0000000000000..9e787f638a998 --- /dev/null +++ b/src/test/ui/issues/issue-64593.rs @@ -0,0 +1,12 @@ +// check-pass +#![deny(improper_ctypes)] + +pub struct Error(std::num::NonZeroU32); + +extern "Rust" { + fn foo(dest: &mut [u8]) -> Result<(), Error>; +} + +fn main() { + let _ = unsafe { foo(&mut []) }; +} From c3f72d1c098a61f26271021460b5ae420ff28ae8 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 20 Sep 2019 16:06:32 -0700 Subject: [PATCH 33/63] Fix the span used to suggest avoiding for-loop moves It was using the snippet from the "use" span, which often renders the same, but with closures that snippet is on the start of the closure where the value is captured. We should be using the snippet from the span where it was moved into the `for` loop, which is `move_span`. --- .../borrow_check/conflict_errors.rs | 3 ++- src/test/ui/issues/issue-64559.rs | 6 ++++++ src/test/ui/issues/issue-64559.stderr | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/issues/issue-64559.rs create mode 100644 src/test/ui/issues/issue-64559.stderr diff --git a/src/librustc_mir/borrow_check/conflict_errors.rs b/src/librustc_mir/borrow_check/conflict_errors.rs index 81359c6a46e99..599a0ad0d0c52 100644 --- a/src/librustc_mir/borrow_check/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/conflict_errors.rs @@ -180,7 +180,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { ); } if Some(DesugaringKind::ForLoop) == move_span.desugaring_kind() { - if let Ok(snippet) = self.infcx.tcx.sess.source_map().span_to_snippet(span) { + let sess = self.infcx.tcx.sess; + if let Ok(snippet) = sess.source_map().span_to_snippet(move_span) { err.span_suggestion( move_span, "consider borrowing to avoid moving into the for loop", diff --git a/src/test/ui/issues/issue-64559.rs b/src/test/ui/issues/issue-64559.rs new file mode 100644 index 0000000000000..71e054b5d9876 --- /dev/null +++ b/src/test/ui/issues/issue-64559.rs @@ -0,0 +1,6 @@ +fn main() { + let orig = vec![true]; + for _val in orig {} + let _closure = || orig; + //~^ ERROR use of moved value: `orig` +} diff --git a/src/test/ui/issues/issue-64559.stderr b/src/test/ui/issues/issue-64559.stderr new file mode 100644 index 0000000000000..3c685dc8d089a --- /dev/null +++ b/src/test/ui/issues/issue-64559.stderr @@ -0,0 +1,18 @@ +error[E0382]: use of moved value: `orig` + --> $DIR/issue-64559.rs:4:20 + | +LL | let orig = vec![true]; + | ---- move occurs because `orig` has type `std::vec::Vec`, which does not implement the `Copy` trait +LL | for _val in orig {} + | ---- + | | + | value moved here + | help: consider borrowing to avoid moving into the for loop: `&orig` +LL | let _closure = || orig; + | ^^ ---- use occurs due to use in closure + | | + | value used here after move + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. From d4344969731e55bd0acaee4ad6962a85c8e0f27a Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Sat, 21 Sep 2019 16:09:38 +0200 Subject: [PATCH 34/63] remove feature --- src/librustc_mir/transform/qualify_consts.rs | 17 +- src/libsyntax/feature_gate/active.rs | 3 - src/libsyntax_pos/symbol.rs | 1 - src/test/ui/consts/const-eval/const_fn_ptr.rs | 24 ++- .../ui/consts/const-eval/const_fn_ptr.stderr | 152 ++++++++++++++++++ .../ui/consts/const-eval/const_fn_ptr_fail.rs | 8 +- .../const-eval/const_fn_ptr_fail.stderr | 20 --- .../consts/const-eval/const_fn_ptr_fail2.rs | 19 ++- .../const-eval/const_fn_ptr_fail2.stderr | 93 ++++++++--- .../const-eval/feature-gate-const_fn_ptr.rs | 11 -- .../feature-gate-const_fn_ptr.stderr | 12 -- 11 files changed, 261 insertions(+), 99 deletions(-) create mode 100644 src/test/ui/consts/const-eval/const_fn_ptr.stderr delete mode 100644 src/test/ui/consts/const-eval/const_fn_ptr_fail.stderr delete mode 100644 src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.rs delete mode 100644 src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.stderr diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 3842942d97fbb..60b88277715bc 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -1413,17 +1413,12 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { .opts .debugging_opts .unleash_the_miri_inside_of_you; - let const_fn_ptr = self.tcx.features().const_fn_ptr; - if self.mode.requires_const_checking() { - if !(unleash_miri || const_fn_ptr) { - emit_feature_err( - &self.tcx.sess.parse_sess, - sym::const_fn_ptr, - self.span, - GateIssue::Language, - "function pointers in const fn are unstable", - ); - } + if self.mode.requires_const_checking() && !unleash_miri { + let mut err = self.tcx.sess.struct_span_err( + self.span, + "function pointers in `const fn` are unstable", + ); + err.emit(); } } _ => { diff --git a/src/libsyntax/feature_gate/active.rs b/src/libsyntax/feature_gate/active.rs index d1a17dc14bdf7..dd78777b56986 100644 --- a/src/libsyntax/feature_gate/active.rs +++ b/src/libsyntax/feature_gate/active.rs @@ -405,9 +405,6 @@ declare_features! ( /// Allows macro invocations in `extern {}` blocks. (active, macros_in_extern, "1.27.0", Some(49476), None), - /// Allows calling function pointers inside `const` functions. - (active, const_fn_ptr, "1.27.0", Some(51909), None), - /// Allows accessing fields of unions inside `const` functions. (active, const_fn_union, "1.27.0", Some(51909), None), diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index e6be8a2cb874a..597ae83572cee 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -198,7 +198,6 @@ symbols! { const_compare_raw_pointers, const_constructor, const_fn, - const_fn_ptr, const_fn_union, const_generics, const_indexing, diff --git a/src/test/ui/consts/const-eval/const_fn_ptr.rs b/src/test/ui/consts/const-eval/const_fn_ptr.rs index 1acb3d8ad1065..498f801db81b8 100644 --- a/src/test/ui/consts/const-eval/const_fn_ptr.rs +++ b/src/test/ui/consts/const-eval/const_fn_ptr.rs @@ -1,21 +1,37 @@ // run-pass +// compile-flags: -Zunleash-the-miri-inside-of-you #![feature(const_fn)] -#![feature(const_fn_ptr)] -const fn double(x: usize) -> usize { x * 2 } +fn double(x: usize) -> usize { x * 2 } +const fn double_const(x: usize) -> usize { x * 2 } + const X: fn(usize) -> usize = double; +const X_const: fn(usize) -> usize = double_const; const fn bar(x: usize) -> usize { X(x) } +const fn bar_const(x: usize) -> usize { + X_const(x) +} + const fn foo(x: fn(usize) -> usize, y: usize) -> usize { x(y) } fn main() { - const Y: usize = bar(2); + const Y: usize = bar_const(2); assert_eq!(Y, 4); - const Z: usize = foo(double, 2); + let y = bar_const(2); + assert_eq!(y, 4); + let y = bar(2); + assert_eq!(y, 4); + + const Z: usize = foo(double_const, 2); assert_eq!(Z, 4); + let z = foo(double_const, 2); + assert_eq!(z, 4); + let z = foo(double, 2); + assert_eq!(z, 4); } diff --git a/src/test/ui/consts/const-eval/const_fn_ptr.stderr b/src/test/ui/consts/const-eval/const_fn_ptr.stderr new file mode 100644 index 0000000000000..41452ee59eb94 --- /dev/null +++ b/src/test/ui/consts/const-eval/const_fn_ptr.stderr @@ -0,0 +1,152 @@ +warning: skipping const checks + --> $DIR/const_fn_ptr.rs:25:5 + | +LL | assert_eq!(Y, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_fn_ptr.rs:25:5 + | +LL | assert_eq!(Y, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_fn_ptr.rs:25:5 + | +LL | assert_eq!(Y, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_fn_ptr.rs:27:5 + | +LL | assert_eq!(y, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_fn_ptr.rs:27:5 + | +LL | assert_eq!(y, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_fn_ptr.rs:27:5 + | +LL | assert_eq!(y, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_fn_ptr.rs:29:5 + | +LL | assert_eq!(y, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_fn_ptr.rs:29:5 + | +LL | assert_eq!(y, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_fn_ptr.rs:29:5 + | +LL | assert_eq!(y, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_fn_ptr.rs:32:5 + | +LL | assert_eq!(Z, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_fn_ptr.rs:32:5 + | +LL | assert_eq!(Z, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_fn_ptr.rs:32:5 + | +LL | assert_eq!(Z, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_fn_ptr.rs:34:5 + | +LL | assert_eq!(z, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_fn_ptr.rs:34:5 + | +LL | assert_eq!(z, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_fn_ptr.rs:34:5 + | +LL | assert_eq!(z, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_fn_ptr.rs:36:5 + | +LL | assert_eq!(z, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_fn_ptr.rs:36:5 + | +LL | assert_eq!(z, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_fn_ptr.rs:36:5 + | +LL | assert_eq!(z, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: constant `X_const` should have an upper case name + --> $DIR/const_fn_ptr.rs:9:7 + | +LL | const X_const: fn(usize) -> usize = double_const; + | ^^^^^^^ help: convert the identifier to upper case: `X_CONST` + | + = note: `#[warn(non_upper_case_globals)]` on by default + diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail.rs b/src/test/ui/consts/const-eval/const_fn_ptr_fail.rs index e8041e56c38fb..14bd6558e7f89 100644 --- a/src/test/ui/consts/const-eval/const_fn_ptr_fail.rs +++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail.rs @@ -1,15 +1,13 @@ // run-pass - -// FIXME: this should not pass - +// compile-flags: -Zunleash-the-miri-inside-of-you #![feature(const_fn)] -#![feature(const_fn_ptr)] +#![allow(unused)] fn double(x: usize) -> usize { x * 2 } const X: fn(usize) -> usize = double; const fn bar(x: usize) -> usize { - X(x) + X(x) // FIXME: this should error someday } fn main() {} diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail.stderr b/src/test/ui/consts/const-eval/const_fn_ptr_fail.stderr deleted file mode 100644 index b7f3a74cc44c0..0000000000000 --- a/src/test/ui/consts/const-eval/const_fn_ptr_fail.stderr +++ /dev/null @@ -1,20 +0,0 @@ -warning: function is never used: `double` - --> $DIR/const_fn_ptr_fail.rs:8:1 - | -LL | fn double(x: usize) -> usize { x * 2 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(dead_code)]` on by default - -warning: constant item is never used: `X` - --> $DIR/const_fn_ptr_fail.rs:9:1 - | -LL | const X: fn(usize) -> usize = double; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: function is never used: `bar` - --> $DIR/const_fn_ptr_fail.rs:11:1 - | -LL | const fn bar(x: usize) -> usize { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs index 66e01cae31452..74c60f9a2a58d 100644 --- a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs +++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs @@ -1,5 +1,6 @@ +// compile-flags: -Zunleash-the-miri-inside-of-you #![feature(const_fn)] -#![feature(const_fn_ptr)] +#![allow(const_err)] fn double(x: usize) -> usize { x * 2 } const X: fn(usize) -> usize = double; @@ -8,14 +9,18 @@ const fn bar(x: fn(usize) -> usize, y: usize) -> usize { x(y) } -const Y: usize = bar(X, 2); -//~^ ERROR any use of this value will cause an error - -const Z: usize = bar(double, 2); -//~^ ERROR any use of this value will cause an error - +const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday +const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday fn main() { assert_eq!(Y, 4); + //~^ ERROR evaluation of constant expression failed + //~^^ WARN skipping const checks + //~^^^ WARN skipping const checks + //~^^^^ WARN skipping const checks assert_eq!(Z, 4); + //~^ ERROR evaluation of constant expression failed + //~^^ WARN skipping const checks + //~^^^ WARN skipping const checks + //~^^^^ WARN skipping const checks } diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr index 020889c2ca1a0..611cc5313c057 100644 --- a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr +++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr @@ -1,28 +1,71 @@ -error: any use of this value will cause an error - --> $DIR/const_fn_ptr_fail2.rs:8:5 - | -LL | x(y) - | ^^^^ - | | - | calling non-const function `double` - | inside call to `bar` at $DIR/const_fn_ptr_fail2.rs:11:18 -... -LL | const Y: usize = bar(X, 2); - | --------------------------- - | - = note: `#[deny(const_err)]` on by default - -error: any use of this value will cause an error - --> $DIR/const_fn_ptr_fail2.rs:8:5 - | -LL | x(y) - | ^^^^ - | | - | calling non-const function `double` - | inside call to `bar` at $DIR/const_fn_ptr_fail2.rs:14:18 -... -LL | const Z: usize = bar(double, 2); - | -------------------------------- +warning: skipping const checks + --> $DIR/const_fn_ptr_fail2.rs:16:5 + | +LL | assert_eq!(Y, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_fn_ptr_fail2.rs:16:5 + | +LL | assert_eq!(Y, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_fn_ptr_fail2.rs:16:5 + | +LL | assert_eq!(Y, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_fn_ptr_fail2.rs:21:5 + | +LL | assert_eq!(Z, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_fn_ptr_fail2.rs:21:5 + | +LL | assert_eq!(Z, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_fn_ptr_fail2.rs:21:5 + | +LL | assert_eq!(Z, 4); + | ^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error[E0080]: evaluation of constant expression failed + --> $DIR/const_fn_ptr_fail2.rs:16:5 + | +LL | assert_eq!(Y, 4); + | ^^^^^^^^^^^-^^^^^ + | | + | referenced constant has errors + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error[E0080]: evaluation of constant expression failed + --> $DIR/const_fn_ptr_fail2.rs:21:5 + | +LL | assert_eq!(Z, 4); + | ^^^^^^^^^^^-^^^^^ + | | + | referenced constant has errors + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.rs b/src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.rs deleted file mode 100644 index ea1ca05c31b8f..0000000000000 --- a/src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![feature(const_fn)] - -fn main() {} - -const fn foo() {} -const X: fn() = foo; - -const fn bar() { - X() - //~^ ERROR function pointers in const fn are unstable -} diff --git a/src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.stderr b/src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.stderr deleted file mode 100644 index fe5956d06f2a0..0000000000000 --- a/src/test/ui/consts/const-eval/feature-gate-const_fn_ptr.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: function pointers in const fn are unstable - --> $DIR/feature-gate-const_fn_ptr.rs:9:5 - | -LL | X() - | ^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/51909 - = help: add `#![feature(const_fn_ptr)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. From 9d4053f6921f3259076e2d88f983f9666a78ef4b Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Sat, 21 Sep 2019 17:24:42 +0200 Subject: [PATCH 35/63] revert error message changes --- src/librustc_mir/transform/qualify_consts.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 60b88277715bc..795721f3b3f28 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -1416,7 +1416,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { if self.mode.requires_const_checking() && !unleash_miri { let mut err = self.tcx.sess.struct_span_err( self.span, - "function pointers in `const fn` are unstable", + "function pointers are not allowed in const fn" ); err.emit(); } From e001c5f9d894a66722db061ecbbd224973dc0fb8 Mon Sep 17 00:00:00 2001 From: Guanqun Lu Date: Sat, 21 Sep 2019 23:36:12 +0800 Subject: [PATCH 36/63] unify errors for tuple/struct variants fix #63983 --- src/librustc_resolve/late/diagnostics.rs | 6 ++++++ src/test/ui/empty/empty-struct-tuple-pat.stderr | 7 ++++--- src/test/ui/issues/issue-32004.stderr | 5 +++-- src/test/ui/issues/issue-63983.rs | 15 +++++++++++++++ src/test/ui/issues/issue-63983.stderr | 15 +++++++++++++++ 5 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 src/test/ui/issues/issue-63983.rs create mode 100644 src/test/ui/issues/issue-63983.stderr diff --git a/src/librustc_resolve/late/diagnostics.rs b/src/librustc_resolve/late/diagnostics.rs index 0c86d8494fde8..1d4fa77adcc1c 100644 --- a/src/librustc_resolve/late/diagnostics.rs +++ b/src/librustc_resolve/late/diagnostics.rs @@ -445,6 +445,12 @@ impl<'a> LateResolutionVisitor<'a, '_> { (Res::Def(DefKind::Ctor(_, CtorKind::Fictive), _), _) if ns == ValueNS => { bad_struct_syntax_suggestion(); } + (Res::Def(DefKind::Ctor(_, CtorKind::Fn), _), _) if ns == ValueNS => { + err.span_label( + span, + format!("did you mean `{} ( /* fields */ )`?", path_str), + ); + } (Res::SelfTy(..), _) if ns == ValueNS => { err.span_label(span, fallback_label); err.note("can't use `Self` as a constructor, you must use the implemented struct"); diff --git a/src/test/ui/empty/empty-struct-tuple-pat.stderr b/src/test/ui/empty/empty-struct-tuple-pat.stderr index 777b9d4a4acd0..6c15e7bf282ce 100644 --- a/src/test/ui/empty/empty-struct-tuple-pat.stderr +++ b/src/test/ui/empty/empty-struct-tuple-pat.stderr @@ -20,15 +20,16 @@ error[E0532]: expected unit struct/variant or constant, found tuple variant `E:: --> $DIR/empty-struct-tuple-pat.rs:29:9 | LL | E::Empty4 => () - | ^^^^^^^^^ not a unit struct/variant or constant + | ^^^^^^^^^ did you mean `E::Empty4 ( /* fields */ )`? error[E0532]: expected unit struct/variant or constant, found tuple variant `XE::XEmpty5` --> $DIR/empty-struct-tuple-pat.rs:33:9 | LL | XE::XEmpty5 => (), | ^^^^------- - | | - | help: a unit variant with a similar name exists: `XEmpty4` + | | | + | | help: a unit variant with a similar name exists: `XEmpty4` + | did you mean `XE::XEmpty5 ( /* fields */ )`? error: aborting due to 4 previous errors diff --git a/src/test/ui/issues/issue-32004.stderr b/src/test/ui/issues/issue-32004.stderr index f8c418b25a0e4..b56fa949acb7e 100644 --- a/src/test/ui/issues/issue-32004.stderr +++ b/src/test/ui/issues/issue-32004.stderr @@ -3,8 +3,9 @@ error[E0532]: expected unit struct/variant or constant, found tuple variant `Foo | LL | Foo::Bar => {} | ^^^^^--- - | | - | help: a unit variant with a similar name exists: `Baz` + | | | + | | help: a unit variant with a similar name exists: `Baz` + | did you mean `Foo::Bar ( /* fields */ )`? error[E0532]: expected tuple struct/variant, found unit struct `S` --> $DIR/issue-32004.rs:16:9 diff --git a/src/test/ui/issues/issue-63983.rs b/src/test/ui/issues/issue-63983.rs new file mode 100644 index 0000000000000..c1c79091fc802 --- /dev/null +++ b/src/test/ui/issues/issue-63983.rs @@ -0,0 +1,15 @@ +enum MyEnum { + Tuple(i32), + Struct{ s: i32 }, +} + +fn foo(en: MyEnum) { + match en { + MyEnum::Tuple => "", + //~^ ERROR expected unit struct/variant or constant, found tuple variant `MyEnum::Tuple` + MyEnum::Struct => "", + //~^ ERROR expected unit struct/variant or constant, found struct variant `MyEnum::Struct` + }; +} + +fn main() {} diff --git a/src/test/ui/issues/issue-63983.stderr b/src/test/ui/issues/issue-63983.stderr new file mode 100644 index 0000000000000..67acd1d57c27a --- /dev/null +++ b/src/test/ui/issues/issue-63983.stderr @@ -0,0 +1,15 @@ +error[E0532]: expected unit struct/variant or constant, found tuple variant `MyEnum::Tuple` + --> $DIR/issue-63983.rs:8:9 + | +LL | MyEnum::Tuple => "", + | ^^^^^^^^^^^^^ did you mean `MyEnum::Tuple ( /* fields */ )`? + +error[E0532]: expected unit struct/variant or constant, found struct variant `MyEnum::Struct` + --> $DIR/issue-63983.rs:10:9 + | +LL | MyEnum::Struct => "", + | ^^^^^^^^^^^^^^ did you mean `MyEnum::Struct { /* fields */ }`? + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0532`. From a2a57bc6cf383fc113335148296c7965bb29e9a2 Mon Sep 17 00:00:00 2001 From: Sam Radhakrishan Date: Thu, 19 Sep 2019 22:12:05 +0530 Subject: [PATCH 37/63] Fixes #63962. Hint about missing tuple parentheses in patterns --- src/librustc_typeck/check/pat.rs | 41 +++++++++++++++++++++++----- src/test/ui/error-codes/E0023.rs | 2 ++ src/test/ui/error-codes/E0023.stderr | 21 +++++++++++--- 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/src/librustc_typeck/check/pat.rs b/src/librustc_typeck/check/pat.rs index d93a4052cd393..d687a5084e231 100644 --- a/src/librustc_typeck/check/pat.rs +++ b/src/librustc_typeck/check/pat.rs @@ -676,18 +676,35 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } else { // Pattern has wrong number of fields. - self.e0023(pat.span, res, &subpats, &variant.fields); + self.e0023(pat.span, res, &subpats, &variant.fields, expected); on_error(); return tcx.types.err; } pat_ty } - fn e0023(&self, pat_span: Span, res: Res, subpats: &'tcx [P], fields: &[ty::FieldDef]) { + fn e0023( + &self, + pat_span: Span, + res: Res, + subpats: &'tcx [P], + fields: &[ty::FieldDef], + expected: Ty<'tcx> + ) { let subpats_ending = pluralise!(subpats.len()); let fields_ending = pluralise!(fields.len()); + let missing_parenthesis = match expected.sty { + ty::Adt(_, substs) if fields.len() == 1 => { + let field_ty = fields[0].ty(self.tcx, substs); + match field_ty.sty { + ty::Tuple(_) => field_ty.tuple_fields().count() == subpats.len(), + _ => false, + } + } + _ => false, + }; let res_span = self.tcx.def_span(res.def_id()); - struct_span_err!( + let mut err = struct_span_err!( self.tcx.sess, pat_span, E0023, @@ -697,15 +714,25 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { res.descr(), fields.len(), fields_ending, - ) - .span_label(pat_span, format!( + ); + err.span_label(pat_span, format!( "expected {} field{}, found {}", fields.len(), fields_ending, subpats.len(), )) - .span_label(res_span, format!("{} defined here", res.descr())) - .emit(); + .span_label(res_span, format!("{} defined here", res.descr())); + + if missing_parenthesis { + err.multipart_suggestion( + "missing parenthesis", + vec![(subpats[0].span.shrink_to_lo(), "(".to_string()), + (subpats[subpats.len()-1].span.shrink_to_hi(), ")".to_string())], + Applicability::MachineApplicable, + ); + } + + err.emit(); } fn check_pat_tuple( diff --git a/src/test/ui/error-codes/E0023.rs b/src/test/ui/error-codes/E0023.rs index 2a97e9048a490..dc421e060e86f 100644 --- a/src/test/ui/error-codes/E0023.rs +++ b/src/test/ui/error-codes/E0023.rs @@ -1,6 +1,7 @@ enum Fruit { Apple(String, String), Pear(u32), + Orange((String, String)), } @@ -10,5 +11,6 @@ fn main() { Fruit::Apple(a) => {}, //~ ERROR E0023 Fruit::Apple(a, b, c) => {}, //~ ERROR E0023 Fruit::Pear(1, 2) => {}, //~ ERROR E0023 + Fruit::Orange(a, b) => {}, //~ ERROR E0023 } } diff --git a/src/test/ui/error-codes/E0023.stderr b/src/test/ui/error-codes/E0023.stderr index d04e494c2585c..8ae7d01ed5f7e 100644 --- a/src/test/ui/error-codes/E0023.stderr +++ b/src/test/ui/error-codes/E0023.stderr @@ -1,5 +1,5 @@ error[E0023]: this pattern has 1 field, but the corresponding tuple variant has 2 fields - --> $DIR/E0023.rs:10:9 + --> $DIR/E0023.rs:11:9 | LL | Apple(String, String), | --------------------- tuple variant defined here @@ -8,7 +8,7 @@ LL | Fruit::Apple(a) => {}, | ^^^^^^^^^^^^^^^ expected 2 fields, found 1 error[E0023]: this pattern has 3 fields, but the corresponding tuple variant has 2 fields - --> $DIR/E0023.rs:11:9 + --> $DIR/E0023.rs:12:9 | LL | Apple(String, String), | --------------------- tuple variant defined here @@ -17,7 +17,7 @@ LL | Fruit::Apple(a, b, c) => {}, | ^^^^^^^^^^^^^^^^^^^^^ expected 2 fields, found 3 error[E0023]: this pattern has 2 fields, but the corresponding tuple variant has 1 field - --> $DIR/E0023.rs:12:9 + --> $DIR/E0023.rs:13:9 | LL | Pear(u32), | --------- tuple variant defined here @@ -25,6 +25,19 @@ LL | Pear(u32), LL | Fruit::Pear(1, 2) => {}, | ^^^^^^^^^^^^^^^^^ expected 1 field, found 2 -error: aborting due to 3 previous errors +error[E0023]: this pattern has 2 fields, but the corresponding tuple variant has 1 field + --> $DIR/E0023.rs:14:9 + | +LL | Orange((String, String)), + | ------------------------ tuple variant defined here +... +LL | Fruit::Orange(a, b) => {}, + | ^^^^^^^^^^^^^^^^^^^ expected 1 field, found 2 +help: missing parenthesis + | +LL | Fruit::Orange((a, b)) => {}, + | ^ ^ + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0023`. From 53a6a2f3226652e212bba6fcf37166a2fe3ecfca Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 21 Sep 2019 21:33:37 +0300 Subject: [PATCH 38/63] fully remove AstBuilder The mentioned Cargo test is fixed in https://github.com/rust-lang/cargo/pull/7210 --- src/libsyntax/ext/build.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index f1d0e0b68f735..60560ae96deb5 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -9,9 +9,6 @@ use crate::ThinVec; use rustc_target::spec::abi::Abi; use syntax_pos::{Pos, Span}; -// Left so that Cargo tests don't break, this can be removed once those no longer use it -pub trait AstBuilder {} - impl<'a> ExtCtxt<'a> { pub fn path(&self, span: Span, strs: Vec ) -> ast::Path { self.path_all(span, false, strs, vec![], vec![]) From 67d88f607ed831cf692387703c34441019b8db96 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 21 Sep 2019 15:01:10 -0400 Subject: [PATCH 39/63] Remove constraints argument from path_all It was never used --- src/libsyntax/ext/build.rs | 11 +++++------ src/libsyntax_ext/deriving/clone.rs | 2 +- src/libsyntax_ext/deriving/cmp/eq.rs | 2 +- src/libsyntax_ext/deriving/generic/mod.rs | 2 +- src/libsyntax_ext/deriving/generic/ty.rs | 8 ++++---- src/libsyntax_ext/env.rs | 2 +- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index f1d0e0b68f735..84a27fcb7dd94 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -14,20 +14,19 @@ pub trait AstBuilder {} impl<'a> ExtCtxt<'a> { pub fn path(&self, span: Span, strs: Vec ) -> ast::Path { - self.path_all(span, false, strs, vec![], vec![]) + self.path_all(span, false, strs, vec![]) } pub fn path_ident(&self, span: Span, id: ast::Ident) -> ast::Path { self.path(span, vec![id]) } pub fn path_global(&self, span: Span, strs: Vec ) -> ast::Path { - self.path_all(span, true, strs, vec![], vec![]) + self.path_all(span, true, strs, vec![]) } pub fn path_all(&self, span: Span, global: bool, mut idents: Vec , - args: Vec, - constraints: Vec ) + args: Vec) -> ast::Path { assert!(!idents.is_empty()); let add_root = global && !idents[0].is_path_segment_keyword(); @@ -39,8 +38,8 @@ impl<'a> ExtCtxt<'a> { segments.extend(idents.into_iter().map(|ident| { ast::PathSegment::from_ident(ident.with_span_pos(span)) })); - let args = if !args.is_empty() || !constraints.is_empty() { - ast::AngleBracketedArgs { args, constraints, span }.into() + let args = if !args.is_empty() { + ast::AngleBracketedArgs { args, constraints: Vec::new(), span }.into() } else { None }; diff --git a/src/libsyntax_ext/deriving/clone.rs b/src/libsyntax_ext/deriving/clone.rs index 4dd0ecfebefd4..9a4c540dc6f1f 100644 --- a/src/libsyntax_ext/deriving/clone.rs +++ b/src/libsyntax_ext/deriving/clone.rs @@ -115,7 +115,7 @@ fn cs_clone_shallow(name: &str, let span = cx.with_def_site_ctxt(span); let assert_path = cx.path_all(span, true, cx.std_path(&[sym::clone, Symbol::intern(helper_name)]), - vec![GenericArg::Type(ty)], vec![]); + vec![GenericArg::Type(ty)]); stmts.push(cx.stmt_let_type_only(span, cx.ty_path(assert_path))); } fn process_variant(cx: &mut ExtCtxt<'_>, stmts: &mut Vec, variant: &VariantData) { diff --git a/src/libsyntax_ext/deriving/cmp/eq.rs b/src/libsyntax_ext/deriving/cmp/eq.rs index 32ab47969ada4..471c92dd99949 100644 --- a/src/libsyntax_ext/deriving/cmp/eq.rs +++ b/src/libsyntax_ext/deriving/cmp/eq.rs @@ -56,7 +56,7 @@ fn cs_total_eq_assert(cx: &mut ExtCtxt<'_>, let span = cx.with_def_site_ctxt(span); let assert_path = cx.path_all(span, true, cx.std_path(&[sym::cmp, Symbol::intern(helper_name)]), - vec![GenericArg::Type(ty)], vec![]); + vec![GenericArg::Type(ty)]); stmts.push(cx.stmt_let_type_only(span, cx.ty_path(assert_path))); } fn process_variant(cx: &mut ExtCtxt<'_>, diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index aceee62e89b0c..5c332eccb62cc 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -664,7 +664,7 @@ impl<'a> TraitDef<'a> { }).collect(); // Create the type of `self`. - let path = cx.path_all(self.span, false, vec![type_ident], self_params, vec![]); + let path = cx.path_all(self.span, false, vec![type_ident], self_params); let self_type = cx.ty_path(path); let attr = cx.attribute(cx.meta_word(self.span, sym::automatically_derived)); diff --git a/src/libsyntax_ext/deriving/generic/ty.rs b/src/libsyntax_ext/deriving/generic/ty.rs index b341a07675206..6ae02a5cab199 100644 --- a/src/libsyntax_ext/deriving/generic/ty.rs +++ b/src/libsyntax_ext/deriving/generic/ty.rs @@ -82,12 +82,12 @@ impl<'a> Path<'a> { .collect(); match self.kind { - PathKind::Global => cx.path_all(span, true, idents, params, Vec::new()), - PathKind::Local => cx.path_all(span, false, idents, params, Vec::new()), + PathKind::Global => cx.path_all(span, true, idents, params), + PathKind::Local => cx.path_all(span, false, idents, params), PathKind::Std => { let def_site = cx.with_def_site_ctxt(DUMMY_SP); idents.insert(0, Ident::new(kw::DollarCrate, def_site)); - cx.path_all(span, false, idents, params, Vec::new()) + cx.path_all(span, false, idents, params) } } @@ -183,7 +183,7 @@ impl<'a> Ty<'a> { } }).collect(); - cx.path_all(span, false, vec![self_ty], params, vec![]) + cx.path_all(span, false, vec![self_ty], params) } Literal(ref p) => p.to_path(cx, span, self_ty, generics), Ptr(..) => cx.span_bug(span, "pointer in a path in generic `derive`"), diff --git a/src/libsyntax_ext/env.rs b/src/libsyntax_ext/env.rs index 70e1fbe6af78a..02757bf6b1689 100644 --- a/src/libsyntax_ext/env.rs +++ b/src/libsyntax_ext/env.rs @@ -32,7 +32,7 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt<'_>, Ident::new(sym::str, sp)), Some(lt), ast::Mutability::Immutable))], - vec![])) + )) } Ok(s) => { cx.expr_call_global(sp, From ea70fb75672645640303b29e3b4cb41ee7690f53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 21 Sep 2019 12:33:02 -0700 Subject: [PATCH 40/63] Do not trigger unreachable lint in async body and Use span labels --- src/librustc_typeck/check/mod.rs | 9 ++-- src/test/ui/dead-code-ret.stderr | 9 ++-- src/test/ui/if-ret.stderr | 9 ++-- src/test/ui/issues/issue-2150.stderr | 9 ++-- src/test/ui/issues/issue-7246.stderr | 9 ++-- .../ui/lint/lint-attr-non-item-node.stderr | 9 ++-- src/test/ui/lint/unreachable-async-fn.rs | 9 ++++ src/test/ui/liveness/liveness-unused.stderr | 9 ++-- .../match-no-arms-unreachable-after.stderr | 9 ++-- src/test/ui/never-assign-dead-code.stderr | 19 +++------ src/test/ui/reachable/expr_add.stderr | 10 ++--- src/test/ui/reachable/expr_again.stderr | 9 ++-- src/test/ui/reachable/expr_array.stderr | 20 ++++----- src/test/ui/reachable/expr_assign.stderr | 30 +++++--------- src/test/ui/reachable/expr_block.stderr | 18 +++----- src/test/ui/reachable/expr_box.stderr | 10 ++--- src/test/ui/reachable/expr_call.stderr | 19 +++------ src/test/ui/reachable/expr_cast.stderr | 10 ++--- src/test/ui/reachable/expr_if.stderr | 21 ++++------ src/test/ui/reachable/expr_loop.stderr | 27 ++++-------- src/test/ui/reachable/expr_match.stderr | 18 +++----- src/test/ui/reachable/expr_method.stderr | 19 +++------ src/test/ui/reachable/expr_repeat.stderr | 10 ++--- src/test/ui/reachable/expr_return.stderr | 10 ++--- .../ui/reachable/expr_return_in_macro.stderr | 13 ++---- src/test/ui/reachable/expr_struct.stderr | 41 +++++++------------ src/test/ui/reachable/expr_tup.stderr | 20 ++++----- src/test/ui/reachable/expr_type.stderr | 10 ++--- src/test/ui/reachable/expr_unary.stderr | 10 ++--- src/test/ui/reachable/expr_while.stderr | 23 ++++------- .../protect-precedences.stderr | 9 ++-- .../ui/unreachable/unreachable-code.stderr | 10 ++--- .../ui/unreachable/unreachable-in-call.stderr | 18 +++----- .../unreachable-try-pattern.stderr | 10 ++--- .../unwarned-match-on-never.stderr | 30 +++++--------- 35 files changed, 191 insertions(+), 334 deletions(-) create mode 100644 src/test/ui/lint/unreachable-async-fn.rs diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 0eeeee01c82f1..5d8d5880c0fca 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -2340,16 +2340,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // If span arose from a desugaring of `if` or `while`, then it is the condition itself, // which diverges, that we are about to lint on. This gives suboptimal diagnostics. // Instead, stop here so that the `if`- or `while`-expression's block is linted instead. - if !span.is_desugaring(DesugaringKind::CondTemporary) { + if !span.is_desugaring(DesugaringKind::CondTemporary) && + !span.is_desugaring(DesugaringKind::Async) + { self.diverges.set(Diverges::WarnedAlways); debug!("warn_if_unreachable: id={:?} span={:?} kind={}", id, span, kind); let msg = format!("unreachable {}", kind); self.tcx().struct_span_lint_hir(lint::builtin::UNREACHABLE_CODE, id, span, &msg) - .span_note( + .span_label(span, &msg) + .span_label( orig_span, - custom_note.unwrap_or("any code following this expression is unreachable") + custom_note.unwrap_or("any code following this expression is unreachable"), ) .emit(); } diff --git a/src/test/ui/dead-code-ret.stderr b/src/test/ui/dead-code-ret.stderr index 0ce31ea40ddbb..83841131599b2 100644 --- a/src/test/ui/dead-code-ret.stderr +++ b/src/test/ui/dead-code-ret.stderr @@ -1,19 +1,16 @@ error: unreachable statement --> $DIR/dead-code-ret.rs:7:5 | +LL | return; + | ------ any code following this expression is unreachable LL | println!("Paul is dead"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^ unreachable statement | note: lint level defined here --> $DIR/dead-code-ret.rs:3:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/dead-code-ret.rs:6:5 - | -LL | return; - | ^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/if-ret.stderr b/src/test/ui/if-ret.stderr index 2df8f22944ee8..58cc707605423 100644 --- a/src/test/ui/if-ret.stderr +++ b/src/test/ui/if-ret.stderr @@ -2,12 +2,9 @@ warning: unreachable block in `if` expression --> $DIR/if-ret.rs:6:24 | LL | fn foo() { if (return) { } } - | ^^^ + | -------- ^^^ unreachable block in `if` expression + | | + | any code following this expression is unreachable | = note: `#[warn(unreachable_code)]` on by default -note: any code following this expression is unreachable - --> $DIR/if-ret.rs:6:15 - | -LL | fn foo() { if (return) { } } - | ^^^^^^^^ diff --git a/src/test/ui/issues/issue-2150.stderr b/src/test/ui/issues/issue-2150.stderr index 623f098d0b337..6e102ecb62fff 100644 --- a/src/test/ui/issues/issue-2150.stderr +++ b/src/test/ui/issues/issue-2150.stderr @@ -1,19 +1,16 @@ error: unreachable statement --> $DIR/issue-2150.rs:8:5 | +LL | panic!(); + | --------- any code following this expression is unreachable LL | for x in &v { i += 1; } - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ unreachable statement | note: lint level defined here --> $DIR/issue-2150.rs:1:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/issue-2150.rs:7:5 - | -LL | panic!(); - | ^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/issues/issue-7246.stderr b/src/test/ui/issues/issue-7246.stderr index d1b23672dc7f4..a11ce1654cad8 100644 --- a/src/test/ui/issues/issue-7246.stderr +++ b/src/test/ui/issues/issue-7246.stderr @@ -1,19 +1,16 @@ error: unreachable statement --> $DIR/issue-7246.rs:7:5 | +LL | return; + | ------ any code following this expression is unreachable LL | if *ptr::null() {}; - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ unreachable statement | note: lint level defined here --> $DIR/issue-7246.rs:1:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/issue-7246.rs:6:5 - | -LL | return; - | ^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/lint/lint-attr-non-item-node.stderr b/src/test/ui/lint/lint-attr-non-item-node.stderr index e6c76c24c9110..0d428c256e7bc 100644 --- a/src/test/ui/lint/lint-attr-non-item-node.stderr +++ b/src/test/ui/lint/lint-attr-non-item-node.stderr @@ -1,19 +1,16 @@ error: unreachable statement --> $DIR/lint-attr-non-item-node.rs:7:9 | +LL | break; + | ----- any code following this expression is unreachable LL | "unreachable"; - | ^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^ unreachable statement | note: lint level defined here --> $DIR/lint-attr-non-item-node.rs:4:12 | LL | #[deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/lint-attr-non-item-node.rs:6:9 - | -LL | break; - | ^^^^^ error: aborting due to previous error diff --git a/src/test/ui/lint/unreachable-async-fn.rs b/src/test/ui/lint/unreachable-async-fn.rs new file mode 100644 index 0000000000000..6e09c3136b5a0 --- /dev/null +++ b/src/test/ui/lint/unreachable-async-fn.rs @@ -0,0 +1,9 @@ +// run-pass +// edition:2018 +#[allow(dead_code)] + +async fn foo () { // unreachable lint doesn't trigger + unimplemented!() +} + +fn main() {} diff --git a/src/test/ui/liveness/liveness-unused.stderr b/src/test/ui/liveness/liveness-unused.stderr index 84e9b5bab99ff..6ea20081e5018 100644 --- a/src/test/ui/liveness/liveness-unused.stderr +++ b/src/test/ui/liveness/liveness-unused.stderr @@ -1,8 +1,10 @@ warning: unreachable statement --> $DIR/liveness-unused.rs:92:9 | +LL | continue; + | -------- any code following this expression is unreachable LL | drop(*x as i32); - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ unreachable statement | note: lint level defined here --> $DIR/liveness-unused.rs:1:9 @@ -10,11 +12,6 @@ note: lint level defined here LL | #![warn(unused)] | ^^^^^^ = note: `#[warn(unreachable_code)]` implied by `#[warn(unused)]` -note: any code following this expression is unreachable - --> $DIR/liveness-unused.rs:91:9 - | -LL | continue; - | ^^^^^^^^ error: unused variable: `x` --> $DIR/liveness-unused.rs:8:7 diff --git a/src/test/ui/match/match-no-arms-unreachable-after.stderr b/src/test/ui/match/match-no-arms-unreachable-after.stderr index 6c46b2473cce6..66e5c91ad2054 100644 --- a/src/test/ui/match/match-no-arms-unreachable-after.stderr +++ b/src/test/ui/match/match-no-arms-unreachable-after.stderr @@ -1,19 +1,16 @@ error: unreachable statement --> $DIR/match-no-arms-unreachable-after.rs:8:5 | +LL | match v { } + | ----------- any code following this expression is unreachable LL | let x = 2; - | ^^^^^^^^^^ + | ^^^^^^^^^^ unreachable statement | note: lint level defined here --> $DIR/match-no-arms-unreachable-after.rs:2:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/match-no-arms-unreachable-after.rs:7:5 - | -LL | match v { } - | ^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/never-assign-dead-code.stderr b/src/test/ui/never-assign-dead-code.stderr index 436c703e4b6b9..b887d580e68a9 100644 --- a/src/test/ui/never-assign-dead-code.stderr +++ b/src/test/ui/never-assign-dead-code.stderr @@ -1,8 +1,10 @@ warning: unreachable statement --> $DIR/never-assign-dead-code.rs:10:5 | +LL | let x: ! = panic!("aah"); + | ------------- any code following this expression is unreachable LL | drop(x); - | ^^^^^^^^ + | ^^^^^^^^ unreachable statement | note: lint level defined here --> $DIR/never-assign-dead-code.rs:5:9 @@ -10,24 +12,15 @@ note: lint level defined here LL | #![warn(unused)] | ^^^^^^ = note: `#[warn(unreachable_code)]` implied by `#[warn(unused)]` -note: any code following this expression is unreachable - --> $DIR/never-assign-dead-code.rs:9:16 - | -LL | let x: ! = panic!("aah"); - | ^^^^^^^^^^^^^ = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) warning: unreachable call --> $DIR/never-assign-dead-code.rs:10:5 | LL | drop(x); - | ^^^^ - | -note: any code following this expression is unreachable - --> $DIR/never-assign-dead-code.rs:10:10 - | -LL | drop(x); - | ^ + | ^^^^ - any code following this expression is unreachable + | | + | unreachable call warning: unused variable: `x` --> $DIR/never-assign-dead-code.rs:9:9 diff --git a/src/test/ui/reachable/expr_add.stderr b/src/test/ui/reachable/expr_add.stderr index 47b4e467abecb..880dea1cc3516 100644 --- a/src/test/ui/reachable/expr_add.stderr +++ b/src/test/ui/reachable/expr_add.stderr @@ -2,18 +2,16 @@ error: unreachable expression --> $DIR/expr_add.rs:17:13 | LL | let x = Foo + return; - | ^^^^^^^^^^^^ + | ^^^^^^------ + | | | + | | any code following this expression is unreachable + | unreachable expression | note: lint level defined here --> $DIR/expr_add.rs:3:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/expr_add.rs:17:19 - | -LL | let x = Foo + return; - | ^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/reachable/expr_again.stderr b/src/test/ui/reachable/expr_again.stderr index 8e246d940fd8d..95006884242f9 100644 --- a/src/test/ui/reachable/expr_again.stderr +++ b/src/test/ui/reachable/expr_again.stderr @@ -1,19 +1,16 @@ error: unreachable statement --> $DIR/expr_again.rs:8:9 | +LL | continue; + | -------- any code following this expression is unreachable LL | println!("hi"); - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ unreachable statement | note: lint level defined here --> $DIR/expr_again.rs:3:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/expr_again.rs:7:9 - | -LL | continue; - | ^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/reachable/expr_array.stderr b/src/test/ui/reachable/expr_array.stderr index 419a332e632f3..b3138d3c33fc0 100644 --- a/src/test/ui/reachable/expr_array.stderr +++ b/src/test/ui/reachable/expr_array.stderr @@ -2,30 +2,24 @@ error: unreachable expression --> $DIR/expr_array.rs:9:34 | LL | let x: [usize; 2] = [return, 22]; - | ^^ + | ------ ^^ unreachable expression + | | + | any code following this expression is unreachable | note: lint level defined here --> $DIR/expr_array.rs:4:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/expr_array.rs:9:26 - | -LL | let x: [usize; 2] = [return, 22]; - | ^^^^^^ error: unreachable expression --> $DIR/expr_array.rs:14:25 | LL | let x: [usize; 2] = [22, return]; - | ^^^^^^^^^^^^ - | -note: any code following this expression is unreachable - --> $DIR/expr_array.rs:14:30 - | -LL | let x: [usize; 2] = [22, return]; - | ^^^^^^ + | ^^^^^------^ + | | | + | | any code following this expression is unreachable + | unreachable expression error: aborting due to 2 previous errors diff --git a/src/test/ui/reachable/expr_assign.stderr b/src/test/ui/reachable/expr_assign.stderr index 7388fb4a6b9b2..3004da0406328 100644 --- a/src/test/ui/reachable/expr_assign.stderr +++ b/src/test/ui/reachable/expr_assign.stderr @@ -2,42 +2,32 @@ error: unreachable expression --> $DIR/expr_assign.rs:10:5 | LL | x = return; - | ^^^^^^^^^^ + | ^^^^------ + | | | + | | any code following this expression is unreachable + | unreachable expression | note: lint level defined here --> $DIR/expr_assign.rs:5:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/expr_assign.rs:10:9 - | -LL | x = return; - | ^^^^^^ error: unreachable expression --> $DIR/expr_assign.rs:20:14 | LL | *p = return; - | ^^^^^^ - | -note: any code following this expression is unreachable - --> $DIR/expr_assign.rs:20:9 - | -LL | *p = return; - | ^^ + | -- ^^^^^^ unreachable expression + | | + | any code following this expression is unreachable error: unreachable expression --> $DIR/expr_assign.rs:26:15 | LL | *{return; &mut i} = 22; - | ^^^^^^ - | -note: any code following this expression is unreachable - --> $DIR/expr_assign.rs:26:7 - | -LL | *{return; &mut i} = 22; - | ^^^^^^ + | ------ ^^^^^^ unreachable expression + | | + | any code following this expression is unreachable error: aborting due to 3 previous errors diff --git a/src/test/ui/reachable/expr_block.stderr b/src/test/ui/reachable/expr_block.stderr index 03a6139d688bb..44baddd1e5503 100644 --- a/src/test/ui/reachable/expr_block.stderr +++ b/src/test/ui/reachable/expr_block.stderr @@ -1,31 +1,25 @@ error: unreachable expression --> $DIR/expr_block.rs:10:9 | +LL | return; + | ------ any code following this expression is unreachable LL | 22 - | ^^ + | ^^ unreachable expression | note: lint level defined here --> $DIR/expr_block.rs:4:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/expr_block.rs:9:9 - | -LL | return; - | ^^^^^^ error: unreachable statement --> $DIR/expr_block.rs:25:9 | +LL | return; + | ------ any code following this expression is unreachable LL | println!("foo"); - | ^^^^^^^^^^^^^^^^ - | -note: any code following this expression is unreachable - --> $DIR/expr_block.rs:24:9 + | ^^^^^^^^^^^^^^^^ unreachable statement | -LL | return; - | ^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/src/test/ui/reachable/expr_box.stderr b/src/test/ui/reachable/expr_box.stderr index d0f666d2be44b..b01a13e9df29a 100644 --- a/src/test/ui/reachable/expr_box.stderr +++ b/src/test/ui/reachable/expr_box.stderr @@ -2,18 +2,16 @@ error: unreachable expression --> $DIR/expr_box.rs:6:13 | LL | let x = box return; - | ^^^^^^^^^^ + | ^^^^------ + | | | + | | any code following this expression is unreachable + | unreachable expression | note: lint level defined here --> $DIR/expr_box.rs:3:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/expr_box.rs:6:17 - | -LL | let x = box return; - | ^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/reachable/expr_call.stderr b/src/test/ui/reachable/expr_call.stderr index 3fcea90e7cd87..ae8b4dd87b5b9 100644 --- a/src/test/ui/reachable/expr_call.stderr +++ b/src/test/ui/reachable/expr_call.stderr @@ -2,30 +2,23 @@ error: unreachable expression --> $DIR/expr_call.rs:13:17 | LL | foo(return, 22); - | ^^ + | ------ ^^ unreachable expression + | | + | any code following this expression is unreachable | note: lint level defined here --> $DIR/expr_call.rs:5:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/expr_call.rs:13:9 - | -LL | foo(return, 22); - | ^^^^^^ error: unreachable call --> $DIR/expr_call.rs:18:5 | LL | bar(return); - | ^^^ - | -note: any code following this expression is unreachable - --> $DIR/expr_call.rs:18:9 - | -LL | bar(return); - | ^^^^^^ + | ^^^ ------ any code following this expression is unreachable + | | + | unreachable call error: aborting due to 2 previous errors diff --git a/src/test/ui/reachable/expr_cast.stderr b/src/test/ui/reachable/expr_cast.stderr index d3ce0ca079f90..81813d1d71c3f 100644 --- a/src/test/ui/reachable/expr_cast.stderr +++ b/src/test/ui/reachable/expr_cast.stderr @@ -2,18 +2,16 @@ error: unreachable expression --> $DIR/expr_cast.rs:9:13 | LL | let x = {return} as !; - | ^^^^^^^^^^^^^ + | ^------^^^^^^ + | || + | |any code following this expression is unreachable + | unreachable expression | note: lint level defined here --> $DIR/expr_cast.rs:4:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/expr_cast.rs:9:14 - | -LL | let x = {return} as !; - | ^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/reachable/expr_if.stderr b/src/test/ui/reachable/expr_if.stderr index 03284576086a7..ccd45ccec62c7 100644 --- a/src/test/ui/reachable/expr_if.stderr +++ b/src/test/ui/reachable/expr_if.stderr @@ -2,33 +2,28 @@ error: unreachable block in `if` expression --> $DIR/expr_if.rs:7:17 | LL | if {return} { - | _________________^ + | _________------__^ + | | | + | | any code following this expression is unreachable LL | | println!("Hello, world!"); LL | | } - | |_____^ + | |_____^ unreachable block in `if` expression | note: lint level defined here --> $DIR/expr_if.rs:4:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/expr_if.rs:7:9 - | -LL | if {return} { - | ^^^^^^ error: unreachable statement --> $DIR/expr_if.rs:27:5 | +LL | return; + | ------ any code following this expression is unreachable +... LL | println!("But I am."); - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ unreachable statement | -note: any code following this expression is unreachable - --> $DIR/expr_if.rs:21:9 - | -LL | return; - | ^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/src/test/ui/reachable/expr_loop.stderr b/src/test/ui/reachable/expr_loop.stderr index a4cf8cfcfd9e6..5f279c9630d30 100644 --- a/src/test/ui/reachable/expr_loop.stderr +++ b/src/test/ui/reachable/expr_loop.stderr @@ -1,45 +1,36 @@ error: unreachable statement --> $DIR/expr_loop.rs:8:5 | +LL | loop { return; } + | ------ any code following this expression is unreachable LL | println!("I am dead."); - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ unreachable statement | note: lint level defined here --> $DIR/expr_loop.rs:4:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/expr_loop.rs:7:12 - | -LL | loop { return; } - | ^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: unreachable statement --> $DIR/expr_loop.rs:21:5 | +LL | loop { return; } + | ------ any code following this expression is unreachable LL | println!("I am dead."); - | ^^^^^^^^^^^^^^^^^^^^^^^ - | -note: any code following this expression is unreachable - --> $DIR/expr_loop.rs:20:12 + | ^^^^^^^^^^^^^^^^^^^^^^^ unreachable statement | -LL | loop { return; } - | ^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: unreachable statement --> $DIR/expr_loop.rs:32:5 | +LL | loop { 'middle: loop { loop { break 'middle; } } } + | -------------------------------------------------- any code following this expression is unreachable LL | println!("I am dead."); - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ unreachable statement | -note: any code following this expression is unreachable - --> $DIR/expr_loop.rs:31:5 - | -LL | loop { 'middle: loop { loop { break 'middle; } } } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/src/test/ui/reachable/expr_match.stderr b/src/test/ui/reachable/expr_match.stderr index f587e524d350d..d39acdc290926 100644 --- a/src/test/ui/reachable/expr_match.stderr +++ b/src/test/ui/reachable/expr_match.stderr @@ -1,32 +1,26 @@ error: unreachable statement --> $DIR/expr_match.rs:8:5 | +LL | match () { () => return } + | ------------------------- any code following this `match` expression is unreachable, as all arms diverge LL | println!("I am dead"); - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ unreachable statement | note: lint level defined here --> $DIR/expr_match.rs:4:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this `match` expression is unreachable, as all arms diverge - --> $DIR/expr_match.rs:7:5 - | -LL | match () { () => return } - | ^^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: unreachable statement --> $DIR/expr_match.rs:19:5 | +LL | match () { () if false => return, () => return } + | ------------------------------------------------ any code following this `match` expression is unreachable, as all arms diverge LL | println!("I am dead"); - | ^^^^^^^^^^^^^^^^^^^^^^ - | -note: any code following this `match` expression is unreachable, as all arms diverge - --> $DIR/expr_match.rs:18:5 + | ^^^^^^^^^^^^^^^^^^^^^^ unreachable statement | -LL | match () { () if false => return, () => return } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/src/test/ui/reachable/expr_method.stderr b/src/test/ui/reachable/expr_method.stderr index 7ad279c9f487a..82a0745f0629f 100644 --- a/src/test/ui/reachable/expr_method.stderr +++ b/src/test/ui/reachable/expr_method.stderr @@ -2,30 +2,23 @@ error: unreachable expression --> $DIR/expr_method.rs:16:21 | LL | Foo.foo(return, 22); - | ^^ + | ------ ^^ unreachable expression + | | + | any code following this expression is unreachable | note: lint level defined here --> $DIR/expr_method.rs:5:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/expr_method.rs:16:13 - | -LL | Foo.foo(return, 22); - | ^^^^^^ error: unreachable call --> $DIR/expr_method.rs:21:9 | LL | Foo.bar(return); - | ^^^ - | -note: any code following this expression is unreachable - --> $DIR/expr_method.rs:21:13 - | -LL | Foo.bar(return); - | ^^^^^^ + | ^^^ ------ any code following this expression is unreachable + | | + | unreachable call error: aborting due to 2 previous errors diff --git a/src/test/ui/reachable/expr_repeat.stderr b/src/test/ui/reachable/expr_repeat.stderr index 3ff6be76daea5..34129936fd762 100644 --- a/src/test/ui/reachable/expr_repeat.stderr +++ b/src/test/ui/reachable/expr_repeat.stderr @@ -2,18 +2,16 @@ error: unreachable expression --> $DIR/expr_repeat.rs:9:25 | LL | let x: [usize; 2] = [return; 2]; - | ^^^^^^^^^^^ + | ^------^^^^ + | || + | |any code following this expression is unreachable + | unreachable expression | note: lint level defined here --> $DIR/expr_repeat.rs:4:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/expr_repeat.rs:9:26 - | -LL | let x: [usize; 2] = [return; 2]; - | ^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/reachable/expr_return.stderr b/src/test/ui/reachable/expr_return.stderr index 31f7ebe7618ea..c0a94746d08eb 100644 --- a/src/test/ui/reachable/expr_return.stderr +++ b/src/test/ui/reachable/expr_return.stderr @@ -2,18 +2,16 @@ error: unreachable expression --> $DIR/expr_return.rs:10:22 | LL | let x = {return {return {return;}}}; - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^------^^ + | | | + | | any code following this expression is unreachable + | unreachable expression | note: lint level defined here --> $DIR/expr_return.rs:4:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/expr_return.rs:10:30 - | -LL | let x = {return {return {return;}}}; - | ^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/reachable/expr_return_in_macro.stderr b/src/test/ui/reachable/expr_return_in_macro.stderr index ff3abb5551f92..2bc6a763cfaea 100644 --- a/src/test/ui/reachable/expr_return_in_macro.stderr +++ b/src/test/ui/reachable/expr_return_in_macro.stderr @@ -1,22 +1,17 @@ error: unreachable expression --> $DIR/expr_return_in_macro.rs:13:5 | +LL | return () + | --------- any code following this expression is unreachable +... LL | return early_return!(); - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ unreachable expression | note: lint level defined here --> $DIR/expr_return_in_macro.rs:4:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/expr_return_in_macro.rs:8:9 - | -LL | return () - | ^^^^^^^^^ -... -LL | return early_return!(); - | --------------- in this macro invocation error: aborting due to previous error diff --git a/src/test/ui/reachable/expr_struct.stderr b/src/test/ui/reachable/expr_struct.stderr index d08bcc4f0d1ae..b3ca06eada3d5 100644 --- a/src/test/ui/reachable/expr_struct.stderr +++ b/src/test/ui/reachable/expr_struct.stderr @@ -2,54 +2,41 @@ error: unreachable expression --> $DIR/expr_struct.rs:14:13 | LL | let x = Foo { a: 22, b: 33, ..return }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^------^^ + | | | + | | any code following this expression is unreachable + | unreachable expression | note: lint level defined here --> $DIR/expr_struct.rs:4:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/expr_struct.rs:14:35 - | -LL | let x = Foo { a: 22, b: 33, ..return }; - | ^^^^^^ error: unreachable expression --> $DIR/expr_struct.rs:19:33 | LL | let x = Foo { a: return, b: 33, ..return }; - | ^^ - | -note: any code following this expression is unreachable - --> $DIR/expr_struct.rs:19:22 - | -LL | let x = Foo { a: return, b: 33, ..return }; - | ^^^^^^ + | ------ ^^ unreachable expression + | | + | any code following this expression is unreachable error: unreachable expression --> $DIR/expr_struct.rs:24:39 | LL | let x = Foo { a: 22, b: return, ..return }; - | ^^^^^^ - | -note: any code following this expression is unreachable - --> $DIR/expr_struct.rs:24:29 - | -LL | let x = Foo { a: 22, b: return, ..return }; - | ^^^^^^ + | ------ ^^^^^^ unreachable expression + | | + | any code following this expression is unreachable error: unreachable expression --> $DIR/expr_struct.rs:29:13 | LL | let x = Foo { a: 22, b: return }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: any code following this expression is unreachable - --> $DIR/expr_struct.rs:29:29 - | -LL | let x = Foo { a: 22, b: return }; - | ^^^^^^ + | ^^^^^^^^^^^^^^^^------^^ + | | | + | | any code following this expression is unreachable + | unreachable expression error: aborting due to 4 previous errors diff --git a/src/test/ui/reachable/expr_tup.stderr b/src/test/ui/reachable/expr_tup.stderr index 788499533db33..aaaf6462da895 100644 --- a/src/test/ui/reachable/expr_tup.stderr +++ b/src/test/ui/reachable/expr_tup.stderr @@ -2,30 +2,24 @@ error: unreachable expression --> $DIR/expr_tup.rs:9:38 | LL | let x: (usize, usize) = (return, 2); - | ^ + | ------ ^ unreachable expression + | | + | any code following this expression is unreachable | note: lint level defined here --> $DIR/expr_tup.rs:4:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/expr_tup.rs:9:30 - | -LL | let x: (usize, usize) = (return, 2); - | ^^^^^^ error: unreachable expression --> $DIR/expr_tup.rs:14:29 | LL | let x: (usize, usize) = (2, return); - | ^^^^^^^^^^^ - | -note: any code following this expression is unreachable - --> $DIR/expr_tup.rs:14:33 - | -LL | let x: (usize, usize) = (2, return); - | ^^^^^^ + | ^^^^------^ + | | | + | | any code following this expression is unreachable + | unreachable expression error: aborting due to 2 previous errors diff --git a/src/test/ui/reachable/expr_type.stderr b/src/test/ui/reachable/expr_type.stderr index 15eb735da75d8..cb6e8d7039f2c 100644 --- a/src/test/ui/reachable/expr_type.stderr +++ b/src/test/ui/reachable/expr_type.stderr @@ -2,18 +2,16 @@ error: unreachable expression --> $DIR/expr_type.rs:9:13 | LL | let x = {return}: !; - | ^^^^^^^^^^^ + | ^------^^^^ + | || + | |any code following this expression is unreachable + | unreachable expression | note: lint level defined here --> $DIR/expr_type.rs:4:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/expr_type.rs:9:14 - | -LL | let x = {return}: !; - | ^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/reachable/expr_unary.stderr b/src/test/ui/reachable/expr_unary.stderr index 7f86519616639..f5c3564217bba 100644 --- a/src/test/ui/reachable/expr_unary.stderr +++ b/src/test/ui/reachable/expr_unary.stderr @@ -8,18 +8,16 @@ error: unreachable expression --> $DIR/expr_unary.rs:8:16 | LL | let x: ! = ! { return; }; - | ^^^^^^^^^^^^^ + | ^^^^------^^^ + | | | + | | any code following this expression is unreachable + | unreachable expression | note: lint level defined here --> $DIR/expr_unary.rs:5:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/expr_unary.rs:8:20 - | -LL | let x: ! = ! { return; }; - | ^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/reachable/expr_while.stderr b/src/test/ui/reachable/expr_while.stderr index b6d6d11ac691e..edb1dd2b9bc70 100644 --- a/src/test/ui/reachable/expr_while.stderr +++ b/src/test/ui/reachable/expr_while.stderr @@ -2,38 +2,31 @@ error: unreachable block in `while` expression --> $DIR/expr_while.rs:7:20 | LL | while {return} { - | ____________________^ + | ____________------__^ + | | | + | | any code following this expression is unreachable LL | | LL | | println!("Hello, world!"); LL | | } - | |_____^ + | |_____^ unreachable block in `while` expression | note: lint level defined here --> $DIR/expr_while.rs:4:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/expr_while.rs:7:12 - | -LL | while {return} { - | ^^^^^^ error: unreachable block in `while` expression --> $DIR/expr_while.rs:22:20 | LL | while {return} { - | ____________________^ + | ____________------__^ + | | | + | | any code following this expression is unreachable LL | | LL | | println!("I am dead."); LL | | } - | |_____^ - | -note: any code following this expression is unreachable - --> $DIR/expr_while.rs:22:12 - | -LL | while {return} { - | ^^^^^^ + | |_____^ unreachable block in `while` expression error: aborting due to 2 previous errors diff --git a/src/test/ui/rfc-2497-if-let-chains/protect-precedences.stderr b/src/test/ui/rfc-2497-if-let-chains/protect-precedences.stderr index ca98a3947146e..cf8f0e98305ea 100644 --- a/src/test/ui/rfc-2497-if-let-chains/protect-precedences.stderr +++ b/src/test/ui/rfc-2497-if-let-chains/protect-precedences.stderr @@ -2,12 +2,9 @@ warning: unreachable block in `if` expression --> $DIR/protect-precedences.rs:13:41 | LL | if let _ = return true && false {}; - | ^^ + | -------------------- ^^ unreachable block in `if` expression + | | + | any code following this expression is unreachable | = note: `#[warn(unreachable_code)]` on by default -note: any code following this expression is unreachable - --> $DIR/protect-precedences.rs:13:20 - | -LL | if let _ = return true && false {}; - | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/unreachable/unreachable-code.stderr b/src/test/ui/unreachable/unreachable-code.stderr index 226f088c63a5e..184440db5df48 100644 --- a/src/test/ui/unreachable/unreachable-code.stderr +++ b/src/test/ui/unreachable/unreachable-code.stderr @@ -1,19 +1,17 @@ error: unreachable statement --> $DIR/unreachable-code.rs:7:3 | +LL | loop{} + | ------ any code following this expression is unreachable +LL | LL | let a = 3; - | ^^^^^^^^^^ + | ^^^^^^^^^^ unreachable statement | note: lint level defined here --> $DIR/unreachable-code.rs:1:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/unreachable-code.rs:5:3 - | -LL | loop{} - | ^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/unreachable/unreachable-in-call.stderr b/src/test/ui/unreachable/unreachable-in-call.stderr index 928f5634a1248..1d081d1c76228 100644 --- a/src/test/ui/unreachable/unreachable-in-call.stderr +++ b/src/test/ui/unreachable/unreachable-in-call.stderr @@ -1,31 +1,25 @@ error: unreachable expression --> $DIR/unreachable-in-call.rs:14:10 | +LL | call(diverge(), + | --------- any code following this expression is unreachable LL | get_u8()); - | ^^^^^^^^ + | ^^^^^^^^ unreachable expression | note: lint level defined here --> $DIR/unreachable-in-call.rs:2:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/unreachable-in-call.rs:13:10 - | -LL | call(diverge(), - | ^^^^^^^^^ error: unreachable call --> $DIR/unreachable-in-call.rs:17:5 | LL | call( - | ^^^^ - | -note: any code following this expression is unreachable - --> $DIR/unreachable-in-call.rs:19:9 - | + | ^^^^ unreachable call +LL | get_u8(), LL | diverge()); - | ^^^^^^^^^ + | --------- any code following this expression is unreachable error: aborting due to 2 previous errors diff --git a/src/test/ui/unreachable/unreachable-try-pattern.stderr b/src/test/ui/unreachable/unreachable-try-pattern.stderr index 889df790124da..707038442a2b6 100644 --- a/src/test/ui/unreachable/unreachable-try-pattern.stderr +++ b/src/test/ui/unreachable/unreachable-try-pattern.stderr @@ -2,18 +2,16 @@ warning: unreachable expression --> $DIR/unreachable-try-pattern.rs:19:36 | LL | let y = (match x { Ok(n) => Ok(n as u32), Err(e) => Err(e) })?; - | ^^^^^^^^ + | -^^^^^^^ + | | + | unreachable expression + | any code following this expression is unreachable | note: lint level defined here --> $DIR/unreachable-try-pattern.rs:3:9 | LL | #![warn(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/unreachable-try-pattern.rs:19:36 - | -LL | let y = (match x { Ok(n) => Ok(n as u32), Err(e) => Err(e) })?; - | ^ warning: unreachable pattern --> $DIR/unreachable-try-pattern.rs:19:24 diff --git a/src/test/ui/unreachable/unwarned-match-on-never.stderr b/src/test/ui/unreachable/unwarned-match-on-never.stderr index 9ce6e3df8046e..6b2fb4a33c1e8 100644 --- a/src/test/ui/unreachable/unwarned-match-on-never.stderr +++ b/src/test/ui/unreachable/unwarned-match-on-never.stderr @@ -2,44 +2,34 @@ error: unreachable expression --> $DIR/unwarned-match-on-never.rs:10:5 | LL | match x {} - | ^^^^^^^^^^ + | - any code following this expression is unreachable +LL | // But matches in unreachable code are warned. +LL | match x {} + | ^^^^^^^^^^ unreachable expression | note: lint level defined here --> $DIR/unwarned-match-on-never.rs:1:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -note: any code following this expression is unreachable - --> $DIR/unwarned-match-on-never.rs:8:11 - | -LL | match x {} - | ^ error: unreachable arm --> $DIR/unwarned-match-on-never.rs:15:15 | -LL | () => () - | ^^ - | -note: any code following this expression is unreachable - --> $DIR/unwarned-match-on-never.rs:14:11 - | LL | match (return) { - | ^^^^^^^^ + | -------- any code following this expression is unreachable +LL | () => () + | ^^ unreachable arm error: unreachable expression --> $DIR/unwarned-match-on-never.rs:21:5 | +LL | return; + | ------ any code following this expression is unreachable LL | / match () { LL | | () => (), LL | | } - | |_____^ - | -note: any code following this expression is unreachable - --> $DIR/unwarned-match-on-never.rs:20:5 - | -LL | return; - | ^^^^^^ + | |_____^ unreachable expression error: aborting due to 3 previous errors From 2aa9d29c6a054d0aca249eb2f9a002acea4ba175 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 21 Sep 2019 15:07:28 -0400 Subject: [PATCH 41/63] Remove unused code --- src/libsyntax/ext/build.rs | 294 +------------------------------------ 1 file changed, 3 insertions(+), 291 deletions(-) diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 84a27fcb7dd94..70f915bf8c4db 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -1,12 +1,11 @@ -use crate::ast::{self, Ident, Generics, Expr, BlockCheckMode, UnOp, PatKind}; +use crate::ast::{self, Ident, Expr, BlockCheckMode, UnOp, PatKind}; use crate::attr; -use crate::source_map::{dummy_spanned, respan, Spanned}; +use crate::source_map::{respan, Spanned}; use crate::ext::base::ExtCtxt; use crate::ptr::P; use crate::symbol::{kw, sym, Symbol}; use crate::ThinVec; -use rustc_target::spec::abi::Abi; use syntax_pos::{Pos, Span}; // Left so that Cargo tests don't break, this can be removed once those no longer use it @@ -51,42 +50,6 @@ impl<'a> ExtCtxt<'a> { ast::Path { span, segments } } - /// Constructs a qualified path. - /// - /// Constructs a path like `::ident`. - pub fn qpath(&self, - self_type: P, - trait_path: ast::Path, - ident: ast::Ident) - -> (ast::QSelf, ast::Path) { - self.qpath_all(self_type, trait_path, ident, vec![], vec![]) - } - - /// Constructs a qualified path. - /// - /// Constructs a path like `::ident<'a, T, A = Bar>`. - pub fn qpath_all(&self, - self_type: P, - trait_path: ast::Path, - ident: ast::Ident, - args: Vec, - constraints: Vec) - -> (ast::QSelf, ast::Path) { - let mut path = trait_path; - let args = if !args.is_empty() || !constraints.is_empty() { - ast::AngleBracketedArgs { args, constraints, span: ident.span }.into() - } else { - None - }; - path.segments.push(ast::PathSegment { ident, id: ast::DUMMY_NODE_ID, args }); - - (ast::QSelf { - ty: self_type, - path_span: path.span, - position: path.segments.len() - 1 - }, path) - } - pub fn ty_mt(&self, ty: P, mutbl: ast::Mutability) -> ast::MutTy { ast::MutTy { ty, @@ -219,14 +182,6 @@ impl<'a> ExtCtxt<'a> { } } - pub fn stmt_semi(&self, expr: P) -> ast::Stmt { - ast::Stmt { - id: ast::DUMMY_NODE_ID, - span: expr.span, - node: ast::StmtKind::Semi(expr), - } - } - pub fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, ex: P) -> ast::Stmt { let pat = if mutbl { @@ -250,34 +205,6 @@ impl<'a> ExtCtxt<'a> { } } - pub fn stmt_let_typed(&self, - sp: Span, - mutbl: bool, - ident: ast::Ident, - typ: P, - ex: P) - -> ast::Stmt { - let pat = if mutbl { - let binding_mode = ast::BindingMode::ByValue(ast::Mutability::Mutable); - self.pat_ident_binding_mode(sp, ident, binding_mode) - } else { - self.pat_ident(sp, ident) - }; - let local = P(ast::Local { - pat, - ty: Some(typ), - init: Some(ex), - id: ast::DUMMY_NODE_ID, - span: sp, - attrs: ThinVec::new(), - }); - ast::Stmt { - id: ast::DUMMY_NODE_ID, - node: ast::StmtKind::Local(local), - span: sp, - } - } - // Generates `let _: Type;`, which is usually used for type assertions. pub fn stmt_let_type_only(&self, span: Span, ty: P) -> ast::Stmt { let local = P(ast::Local { @@ -332,11 +259,6 @@ impl<'a> ExtCtxt<'a> { self.expr(path.span, ast::ExprKind::Path(None, path)) } - /// Constructs a `QPath` expression. - pub fn expr_qpath(&self, span: Span, qself: ast::QSelf, path: ast::Path) -> P { - self.expr(span, ast::ExprKind::Path(Some(qself), path)) - } - pub fn expr_ident(&self, span: Span, id: ast::Ident) -> P { self.expr_path(self.path_ident(span, id)) } @@ -350,27 +272,12 @@ impl<'a> ExtCtxt<'a> { } pub fn expr_deref(&self, sp: Span, e: P) -> P { - self.expr_unary(sp, UnOp::Deref, e) - } - pub fn expr_unary(&self, sp: Span, op: ast::UnOp, e: P) -> P { - self.expr(sp, ast::ExprKind::Unary(op, e)) + self.expr(sp, ast::ExprKind::Unary(UnOp::Deref, e)) } - pub fn expr_field_access( - &self, sp: Span, expr: P, ident: ast::Ident, - ) -> P { - self.expr(sp, ast::ExprKind::Field(expr, ident.with_span_pos(sp))) - } - pub fn expr_tup_field_access(&self, sp: Span, expr: P, idx: usize) -> P { - let ident = Ident::new(sym::integer(idx), sp); - self.expr(sp, ast::ExprKind::Field(expr, ident)) - } pub fn expr_addr_of(&self, sp: Span, e: P) -> P { self.expr(sp, ast::ExprKind::AddrOf(ast::Mutability::Immutable, e)) } - pub fn expr_mut_addr_of(&self, sp: Span, e: P) -> P { - self.expr(sp, ast::ExprKind::AddrOf(ast::Mutability::Mutable, e)) - } pub fn expr_call( &self, span: Span, expr: P, args: Vec>, @@ -426,28 +333,10 @@ impl<'a> ExtCtxt<'a> { self.expr_lit(span, ast::LitKind::Int(i as u128, ast::LitIntType::Unsigned(ast::UintTy::Usize))) } - pub fn expr_isize(&self, sp: Span, i: isize) -> P { - if i < 0 { - let i = (-i) as u128; - let lit_ty = ast::LitIntType::Signed(ast::IntTy::Isize); - let lit = self.expr_lit(sp, ast::LitKind::Int(i, lit_ty)); - self.expr_unary(sp, ast::UnOp::Neg, lit) - } else { - self.expr_lit(sp, ast::LitKind::Int(i as u128, - ast::LitIntType::Signed(ast::IntTy::Isize))) - } - } pub fn expr_u32(&self, sp: Span, u: u32) -> P { self.expr_lit(sp, ast::LitKind::Int(u as u128, ast::LitIntType::Unsigned(ast::UintTy::U32))) } - pub fn expr_u16(&self, sp: Span, u: u16) -> P { - self.expr_lit(sp, ast::LitKind::Int(u as u128, - ast::LitIntType::Unsigned(ast::UintTy::U16))) - } - pub fn expr_u8(&self, sp: Span, u: u8) -> P { - self.expr_lit(sp, ast::LitKind::Int(u as u128, ast::LitIntType::Unsigned(ast::UintTy::U8))) - } pub fn expr_bool(&self, sp: Span, value: bool) -> P { self.expr_lit(sp, ast::LitKind::Bool(value)) } @@ -455,10 +344,6 @@ impl<'a> ExtCtxt<'a> { pub fn expr_vec(&self, sp: Span, exprs: Vec>) -> P { self.expr(sp, ast::ExprKind::Array(exprs)) } - pub fn expr_vec_ng(&self, sp: Span) -> P { - self.expr_call_global(sp, self.std_path(&[sym::vec, sym::Vec, sym::new]), - Vec::new()) - } pub fn expr_vec_slice(&self, sp: Span, exprs: Vec>) -> P { self.expr_addr_of(sp, self.expr_vec(sp, exprs)) } @@ -475,16 +360,6 @@ impl<'a> ExtCtxt<'a> { self.expr_call_global(sp, some, vec![expr]) } - pub fn expr_none(&self, sp: Span) -> P { - let none = self.std_path(&[sym::option, sym::Option, sym::None]); - let none = self.path_global(sp, none); - self.expr_path(none) - } - - pub fn expr_break(&self, sp: Span) -> P { - self.expr(sp, ast::ExprKind::Break(None, None)) - } - pub fn expr_tuple(&self, sp: Span, exprs: Vec>) -> P { self.expr(sp, ast::ExprKind::Tup(exprs)) } @@ -513,11 +388,6 @@ impl<'a> ExtCtxt<'a> { self.expr_call_global(sp, ok, vec![expr]) } - pub fn expr_err(&self, sp: Span, expr: P) -> P { - let err = self.std_path(&[sym::result, sym::Result, sym::Err]); - self.expr_call_global(sp, err, vec![expr]) - } - pub fn expr_try(&self, sp: Span, head: P) -> P { let ok = self.std_path(&[sym::result, sym::Result, sym::Ok]); let ok_path = self.path_global(sp, ok); @@ -634,10 +504,6 @@ impl<'a> ExtCtxt<'a> { self.expr(span, ast::ExprKind::If(cond, self.block_expr(then), els)) } - pub fn expr_loop(&self, span: Span, block: P) -> P { - self.expr(span, ast::ExprKind::Loop(block, None)) - } - pub fn lambda_fn_decl(&self, span: Span, fn_decl: P, @@ -681,16 +547,6 @@ impl<'a> ExtCtxt<'a> { self.lambda(span, vec![ident], body) } - pub fn lambda_stmts(&self, - span: Span, - ids: Vec, - stmts: Vec) - -> P { - self.lambda(span, ids, self.expr_block(self.block(span, stmts))) - } - pub fn lambda_stmts_0(&self, span: Span, stmts: Vec) -> P { - self.lambda0(span, self.expr_block(self.block(span, stmts))) - } pub fn lambda_stmts_1(&self, span: Span, stmts: Vec, ident: ast::Ident) -> P { self.lambda1(span, self.expr_block(self.block(span, stmts)), ident) @@ -732,43 +588,6 @@ impl<'a> ExtCtxt<'a> { }) } - pub fn item_fn_poly(&self, - span: Span, - name: Ident, - inputs: Vec , - output: P, - generics: Generics, - body: P) -> P { - self.item(span, - name, - Vec::new(), - ast::ItemKind::Fn(self.fn_decl(inputs, ast::FunctionRetTy::Ty(output)), - ast::FnHeader { - unsafety: ast::Unsafety::Normal, - asyncness: dummy_spanned(ast::IsAsync::NotAsync), - constness: dummy_spanned(ast::Constness::NotConst), - abi: Abi::Rust, - }, - generics, - body)) - } - - pub fn item_fn(&self, - span: Span, - name: Ident, - inputs: Vec , - output: P, - body: P - ) -> P { - self.item_fn_poly( - span, - name, - inputs, - output, - Generics::default(), - body) - } - pub fn variant(&self, span: Span, ident: Ident, tys: Vec> ) -> ast::Variant { let fields: Vec<_> = tys.into_iter().map(|ty| { ast::StructField { @@ -799,52 +618,6 @@ impl<'a> ExtCtxt<'a> { } } - pub fn item_enum_poly(&self, span: Span, name: Ident, - enum_definition: ast::EnumDef, - generics: Generics) -> P { - self.item(span, name, Vec::new(), ast::ItemKind::Enum(enum_definition, generics)) - } - - pub fn item_enum(&self, span: Span, name: Ident, - enum_definition: ast::EnumDef) -> P { - self.item_enum_poly(span, name, enum_definition, - Generics::default()) - } - - pub fn item_struct(&self, span: Span, name: Ident, - struct_def: ast::VariantData) -> P { - self.item_struct_poly( - span, - name, - struct_def, - Generics::default() - ) - } - - pub fn item_struct_poly(&self, span: Span, name: Ident, - struct_def: ast::VariantData, generics: Generics) -> P { - self.item(span, name, Vec::new(), ast::ItemKind::Struct(struct_def, generics)) - } - - pub fn item_mod(&self, span: Span, inner_span: Span, name: Ident, - attrs: Vec, - items: Vec>) -> P { - self.item( - span, - name, - attrs, - ast::ItemKind::Mod(ast::Mod { - inner: inner_span, - items, - inline: true - }) - ) - } - - pub fn item_extern_crate(&self, span: Span, name: Ident) -> P { - self.item(span, name, Vec::new(), ast::ItemKind::ExternCrate(None)) - } - pub fn item_static(&self, span: Span, name: Ident, @@ -864,15 +637,6 @@ impl<'a> ExtCtxt<'a> { self.item(span, name, Vec::new(), ast::ItemKind::Const(ty, expr)) } - pub fn item_ty_poly(&self, span: Span, name: Ident, ty: P, - generics: Generics) -> P { - self.item(span, name, Vec::new(), ast::ItemKind::TyAlias(ty, generics)) - } - - pub fn item_ty(&self, span: Span, name: Ident, ty: P) -> P { - self.item_ty_poly(span, name, ty, Generics::default()) - } - pub fn attribute(&self, mi: ast::MetaItem) -> ast::Attribute { attr::mk_attr_outer(mi) } @@ -894,56 +658,4 @@ impl<'a> ExtCtxt<'a> { -> ast::MetaItem { attr::mk_name_value_item(Ident::new(name, span), lit_kind, span) } - - pub fn item_use(&self, sp: Span, - vis: ast::Visibility, vp: P) -> P { - P(ast::Item { - id: ast::DUMMY_NODE_ID, - ident: Ident::invalid(), - attrs: vec![], - node: ast::ItemKind::Use(vp), - vis, - span: sp, - tokens: None, - }) - } - - pub fn item_use_simple(&self, sp: Span, vis: ast::Visibility, path: ast::Path) -> P { - self.item_use_simple_(sp, vis, None, path) - } - - pub fn item_use_simple_(&self, sp: Span, vis: ast::Visibility, - rename: Option, path: ast::Path) -> P { - self.item_use(sp, vis, P(ast::UseTree { - span: sp, - prefix: path, - kind: ast::UseTreeKind::Simple(rename, ast::DUMMY_NODE_ID, ast::DUMMY_NODE_ID), - })) - } - - pub fn item_use_list(&self, sp: Span, vis: ast::Visibility, - path: Vec, imports: &[ast::Ident]) -> P { - let imports = imports.iter().map(|id| { - (ast::UseTree { - span: sp, - prefix: self.path(sp, vec![*id]), - kind: ast::UseTreeKind::Simple(None, ast::DUMMY_NODE_ID, ast::DUMMY_NODE_ID), - }, ast::DUMMY_NODE_ID) - }).collect(); - - self.item_use(sp, vis, P(ast::UseTree { - span: sp, - prefix: self.path(sp, path), - kind: ast::UseTreeKind::Nested(imports), - })) - } - - pub fn item_use_glob(&self, sp: Span, - vis: ast::Visibility, path: Vec) -> P { - self.item_use(sp, vis, P(ast::UseTree { - span: sp, - prefix: self.path(sp, path), - kind: ast::UseTreeKind::Glob, - })) - } } From e41aa8c0d04d9a663638e66a82868f0fbeb83bd8 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 21 Sep 2019 15:05:31 -0400 Subject: [PATCH 42/63] Inline ty_infer --- src/libsyntax/ext/build.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 70f915bf8c4db..cadd7d563dab2 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -111,10 +111,6 @@ impl<'a> ExtCtxt<'a> { ast::TyKind::Ptr(self.ty_mt(ty, mutbl))) } - pub fn ty_infer(&self, span: Span) -> P { - self.ty(span, ast::TyKind::Infer) - } - pub fn typaram(&self, span: Span, ident: ast::Ident, @@ -524,7 +520,7 @@ impl<'a> ExtCtxt<'a> { body: P) -> P { let fn_decl = self.fn_decl( - ids.iter().map(|id| self.param(span, *id, self.ty_infer(span))).collect(), + ids.iter().map(|id| self.param(span, *id, self.ty(span, ast::TyKind::Infer))).collect(), ast::FunctionRetTy::Default(span)); // FIXME -- We are using `span` as the span of the `|...|` From 8417ac67c3fe979098facad586438ea5244617b3 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 21 Sep 2019 15:26:15 -0400 Subject: [PATCH 43/63] Inline attribute constructors --- src/libsyntax/ext/build.rs | 14 -------------- src/libsyntax_ext/deriving/cmp/eq.rs | 6 +++--- src/libsyntax_ext/deriving/generic/mod.rs | 7 +++++-- src/libsyntax_ext/test.rs | 4 ++-- 4 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index cadd7d563dab2..ccd73bb66c677 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -640,18 +640,4 @@ impl<'a> ExtCtxt<'a> { pub fn meta_word(&self, sp: Span, w: ast::Name) -> ast::MetaItem { attr::mk_word_item(Ident::new(w, sp)) } - - pub fn meta_list_item_word(&self, sp: Span, w: ast::Name) -> ast::NestedMetaItem { - attr::mk_nested_word_item(Ident::new(w, sp)) - } - - pub fn meta_list(&self, sp: Span, name: ast::Name, mis: Vec) - -> ast::MetaItem { - attr::mk_list_item(Ident::new(name, sp), mis) - } - - pub fn meta_name_value(&self, span: Span, name: ast::Name, lit_kind: ast::LitKind) - -> ast::MetaItem { - attr::mk_name_value_item(Ident::new(name, span), lit_kind, span) - } } diff --git a/src/libsyntax_ext/deriving/cmp/eq.rs b/src/libsyntax_ext/deriving/cmp/eq.rs index 471c92dd99949..c92339dd2fbd5 100644 --- a/src/libsyntax_ext/deriving/cmp/eq.rs +++ b/src/libsyntax_ext/deriving/cmp/eq.rs @@ -2,7 +2,7 @@ use crate::deriving::path_std; use crate::deriving::generic::*; use crate::deriving::generic::ty::*; -use syntax::ast::{self, Expr, MetaItem, GenericArg}; +use syntax::ast::{self, Ident, Expr, MetaItem, GenericArg}; use syntax::ext::base::{Annotatable, ExtCtxt, SpecialDerives}; use syntax::ptr::P; use syntax::symbol::{sym, Symbol}; @@ -16,8 +16,8 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt<'_>, cx.resolver.add_derives(cx.current_expansion.id.expn_data().parent, SpecialDerives::EQ); let inline = cx.meta_word(span, sym::inline); - let hidden = cx.meta_list_item_word(span, sym::hidden); - let doc = cx.meta_list(span, sym::doc, vec![hidden]); + let hidden = syntax::attr::mk_nested_word_item(Ident::new(sym::hidden, span)); + let doc = syntax::attr::mk_list_item(Ident::new(sym::doc, span), vec![hidden]); let attrs = vec![cx.attribute(inline), cx.attribute(doc)]; let trait_def = TraitDef { span, diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 5c332eccb62cc..fec035d331dc5 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -672,8 +672,11 @@ impl<'a> TraitDef<'a> { attr::mark_used(&attr); let opt_trait_ref = Some(trait_ref); let unused_qual = { - let word = cx.meta_list_item_word(self.span, Symbol::intern("unused_qualifications")); - cx.attribute(cx.meta_list(self.span, sym::allow, vec![word])) + let word = syntax::attr::mk_nested_word_item( + Ident::new(Symbol::intern("unused_qualifications"), self.span)); + let list = syntax::attr::mk_list_item( + Ident::new(sym::allow, self.span), vec![word]); + cx.attribute(list) }; let mut a = vec![attr, unused_qual]; diff --git a/src/libsyntax_ext/test.rs b/src/libsyntax_ext/test.rs index 0910c00a8a2a9..6c7e3e3eb9875 100644 --- a/src/libsyntax_ext/test.rs +++ b/src/libsyntax_ext/test.rs @@ -145,8 +145,8 @@ pub fn expand_test_or_bench( let mut test_const = cx.item(sp, ast::Ident::new(item.ident.name, sp), vec![ // #[cfg(test)] - cx.attribute(cx.meta_list(attr_sp, sym::cfg, vec![ - cx.meta_list_item_word(attr_sp, sym::test) + cx.attribute(attr::mk_list_item(ast::Ident::new(sym::cfg, attr_sp), vec![ + attr::mk_nested_word_item(ast::Ident::new(sym::test, attr_sp)) ])), // #[rustc_test_marker] cx.attribute(cx.meta_word(attr_sp, sym::rustc_test_marker)), From 3e6b84474d7cd813bda0956568966024915d0ea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 21 Sep 2019 16:31:27 -0700 Subject: [PATCH 44/63] Propagate `types.err` in locals further to avoid spurious knock-down errors --- src/librustc_typeck/check/coercion.rs | 8 ++++++-- src/librustc_typeck/check/mod.rs | 23 ++++++++++++++++++++++- src/test/ui/issues/issue-33575.rs | 4 ++++ src/test/ui/issues/issue-33575.stderr | 9 +++++++++ 4 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 src/test/ui/issues/issue-33575.rs create mode 100644 src/test/ui/issues/issue-33575.stderr diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index ee4f0a868c10a..ac1bf8e91a149 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -163,7 +163,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { // Just ignore error types. if a.references_error() || b.references_error() { - return success(vec![], b, vec![]); + return success(vec![], self.fcx.tcx.types.err, vec![]); } if a.is_never() { @@ -821,7 +821,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let (adjustments, _) = self.register_infer_ok_obligations(ok); self.apply_adjustments(expr, adjustments); - Ok(target) + if expr_ty.references_error() { + Ok(self.tcx.types.err) + } else { + Ok(target) + } } /// Same as `try_coerce()`, but without side-effects. diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 0eeeee01c82f1..75942731d8790 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -153,7 +153,7 @@ use self::method::{MethodCallee, SelfSource}; use self::TupleArgumentsFlag::*; /// The type of a local binding, including the revealed type for anon types. -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] pub struct LocalTy<'tcx> { decl_ty: Ty<'tcx>, revealed_ty: Ty<'tcx> @@ -3752,14 +3752,35 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Some(ref init) = local.init { let init_ty = self.check_decl_initializer(local, &init); if init_ty.references_error() { + // Override the types everywhere with `types.err` to avoid knock down errors. self.write_ty(local.hir_id, init_ty); + self.write_ty(local.pat.hir_id, init_ty); + self.locals.borrow_mut().insert(local.hir_id, LocalTy { + decl_ty: t, + revealed_ty: init_ty, + }); + self.locals.borrow_mut().insert(local.pat.hir_id, LocalTy { + decl_ty: t, + revealed_ty: init_ty, + }); } } self.check_pat_top(&local.pat, t, None); let pat_ty = self.node_ty(local.pat.hir_id); + debug!("check_decl_local pat_ty {:?}", pat_ty); if pat_ty.references_error() { + // Override the types everywhere with `types.err` to avoid knock down errors. self.write_ty(local.hir_id, pat_ty); + self.write_ty(local.pat.hir_id, pat_ty); + self.locals.borrow_mut().insert(local.hir_id, LocalTy { + decl_ty: t, + revealed_ty: pat_ty, + }); + self.locals.borrow_mut().insert(local.pat.hir_id, LocalTy { + decl_ty: t, + revealed_ty: pat_ty, + }); } } diff --git a/src/test/ui/issues/issue-33575.rs b/src/test/ui/issues/issue-33575.rs new file mode 100644 index 0000000000000..d97afc3d31d5c --- /dev/null +++ b/src/test/ui/issues/issue-33575.rs @@ -0,0 +1,4 @@ +fn main() { + let baz = ().foo(); //~ ERROR no method named `foo` found for type `()` in the current scope + ::from_str(&baz); // No complains about `str` being unsized +} diff --git a/src/test/ui/issues/issue-33575.stderr b/src/test/ui/issues/issue-33575.stderr new file mode 100644 index 0000000000000..e6b74d262c340 --- /dev/null +++ b/src/test/ui/issues/issue-33575.stderr @@ -0,0 +1,9 @@ +error[E0599]: no method named `foo` found for type `()` in the current scope + --> $DIR/issue-33575.rs:2:18 + | +LL | let baz = ().foo(); + | ^^^ method not found in `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. From 9991d548c72529a7475d33c6925ee23601568aec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 21 Sep 2019 16:34:16 -0700 Subject: [PATCH 45/63] review comments --- src/test/ui/lint/unreachable-async-fn.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/ui/lint/unreachable-async-fn.rs b/src/test/ui/lint/unreachable-async-fn.rs index 6e09c3136b5a0..eedd877fe7841 100644 --- a/src/test/ui/lint/unreachable-async-fn.rs +++ b/src/test/ui/lint/unreachable-async-fn.rs @@ -1,7 +1,7 @@ -// run-pass +// check-pass // edition:2018 -#[allow(dead_code)] +#[allow(dead_code)] async fn foo () { // unreachable lint doesn't trigger unimplemented!() } From 60560bc2a2c149e179cd7e58a8b48e06c2c4e3f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 21 Sep 2019 17:11:09 -0700 Subject: [PATCH 46/63] Parse assoc type bounds in generic params and provide custom diagnostic --- src/libsyntax/parse/parser/generics.rs | 99 ++++++++++++------- src/test/ui/parser/assoc-type-in-type-arg.rs | 11 +++ .../ui/parser/assoc-type-in-type-arg.stderr | 8 ++ 3 files changed, 80 insertions(+), 38 deletions(-) create mode 100644 src/test/ui/parser/assoc-type-in-type-arg.rs create mode 100644 src/test/ui/parser/assoc-type-in-type-arg.stderr diff --git a/src/libsyntax/parse/parser/generics.rs b/src/libsyntax/parse/parser/generics.rs index 3e6118ad86f47..1ffdda19c80b5 100644 --- a/src/libsyntax/parse/parser/generics.rs +++ b/src/libsyntax/parse/parser/generics.rs @@ -100,13 +100,31 @@ impl<'a> Parser<'a> { } else if self.check_ident() { // Parse type parameter. params.push(self.parse_ty_param(attrs)?); + } else if self.token.can_begin_type() { + // Trying to write an associated type bound? (#26271) + let snapshot = self.clone(); + match self.parse_ty_where_predicate() { + Ok(where_predicate) => { + self.struct_span_err( + where_predicate.span(), + "associated type bounds do not belong here", + ) + .span_label(where_predicate.span(), "belongs in `where` clause") + .emit(); + } + Err(mut err) => { + err.cancel(); + std::mem::replace(self, snapshot); + break + } + } } else { // Check for trailing attributes and stop parsing. if !attrs.is_empty() { if !params.is_empty() { self.struct_span_err( attrs[0].span, - &format!("trailing attribute after generic parameter"), + "trailing attribute after generic parameter", ) .span_label(attrs[0].span, "attributes must go before parameters") .emit(); @@ -202,43 +220,7 @@ impl<'a> Parser<'a> { } )); } else if self.check_type() { - // Parse optional `for<'a, 'b>`. - // This `for` is parsed greedily and applies to the whole predicate, - // the bounded type can have its own `for` applying only to it. - // Examples: - // * `for<'a> Trait1<'a>: Trait2<'a /* ok */>` - // * `(for<'a> Trait1<'a>): Trait2<'a /* not ok */>` - // * `for<'a> for<'b> Trait1<'a, 'b>: Trait2<'a /* ok */, 'b /* not ok */>` - let lifetime_defs = self.parse_late_bound_lifetime_defs()?; - - // Parse type with mandatory colon and (possibly empty) bounds, - // or with mandatory equality sign and the second type. - let ty = self.parse_ty()?; - if self.eat(&token::Colon) { - let bounds = self.parse_generic_bounds(Some(self.prev_span))?; - where_clause.predicates.push(ast::WherePredicate::BoundPredicate( - ast::WhereBoundPredicate { - span: lo.to(self.prev_span), - bound_generic_params: lifetime_defs, - bounded_ty: ty, - bounds, - } - )); - // FIXME: Decide what should be used here, `=` or `==`. - // FIXME: We are just dropping the binders in lifetime_defs on the floor here. - } else if self.eat(&token::Eq) || self.eat(&token::EqEq) { - let rhs_ty = self.parse_ty()?; - where_clause.predicates.push(ast::WherePredicate::EqPredicate( - ast::WhereEqPredicate { - span: lo.to(self.prev_span), - lhs_ty: ty, - rhs_ty, - id: ast::DUMMY_NODE_ID, - } - )); - } else { - return self.unexpected(); - } + where_clause.predicates.push(self.parse_ty_where_predicate()?); } else { break } @@ -252,6 +234,47 @@ impl<'a> Parser<'a> { Ok(where_clause) } + fn parse_ty_where_predicate(&mut self) -> PResult<'a, ast::WherePredicate> { + let lo = self.token.span; + // Parse optional `for<'a, 'b>`. + // This `for` is parsed greedily and applies to the whole predicate, + // the bounded type can have its own `for` applying only to it. + // Examples: + // * `for<'a> Trait1<'a>: Trait2<'a /* ok */>` + // * `(for<'a> Trait1<'a>): Trait2<'a /* not ok */>` + // * `for<'a> for<'b> Trait1<'a, 'b>: Trait2<'a /* ok */, 'b /* not ok */>` + let lifetime_defs = self.parse_late_bound_lifetime_defs()?; + + // Parse type with mandatory colon and (possibly empty) bounds, + // or with mandatory equality sign and the second type. + let ty = self.parse_ty()?; + if self.eat(&token::Colon) { + let bounds = self.parse_generic_bounds(Some(self.prev_span))?; + Ok(ast::WherePredicate::BoundPredicate( + ast::WhereBoundPredicate { + span: lo.to(self.prev_span), + bound_generic_params: lifetime_defs, + bounded_ty: ty, + bounds, + } + )) + // FIXME: Decide what should be used here, `=` or `==`. + // FIXME: We are just dropping the binders in lifetime_defs on the floor here. + } else if self.eat(&token::Eq) || self.eat(&token::EqEq) { + let rhs_ty = self.parse_ty()?; + Ok(ast::WherePredicate::EqPredicate( + ast::WhereEqPredicate { + span: lo.to(self.prev_span), + lhs_ty: ty, + rhs_ty, + id: ast::DUMMY_NODE_ID, + } + )) + } else { + self.unexpected() + } + } + pub(super) fn choose_generics_over_qpath(&self) -> bool { // There's an ambiguity between generic parameters and qualified paths in impls. // If we see `<` it may start both, so we have to inspect some following tokens. diff --git a/src/test/ui/parser/assoc-type-in-type-arg.rs b/src/test/ui/parser/assoc-type-in-type-arg.rs new file mode 100644 index 0000000000000..09765f01371aa --- /dev/null +++ b/src/test/ui/parser/assoc-type-in-type-arg.rs @@ -0,0 +1,11 @@ +trait Tr { + type TrSubtype; +} + +struct Bar<'a, Item: Tr, ::TrSubtype: 'a> { + //~^ ERROR associated type bounds do not belong here + item: Item, + item_sub: &'a ::TrSubtype, +} + +fn main() {} diff --git a/src/test/ui/parser/assoc-type-in-type-arg.stderr b/src/test/ui/parser/assoc-type-in-type-arg.stderr new file mode 100644 index 0000000000000..06addb0241725 --- /dev/null +++ b/src/test/ui/parser/assoc-type-in-type-arg.stderr @@ -0,0 +1,8 @@ +error: associated type bounds do not belong here + --> $DIR/assoc-type-in-type-arg.rs:5:26 + | +LL | struct Bar<'a, Item: Tr, ::TrSubtype: 'a> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ belongs in `where` clause + +error: aborting due to previous error + From c3d791740f7bc5f85d24e30c835f23cc1423797c Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Sun, 22 Sep 2019 02:23:41 +0200 Subject: [PATCH 47/63] remove outdated comment --- src/librustc_mir/borrow_check/flows.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/librustc_mir/borrow_check/flows.rs b/src/librustc_mir/borrow_check/flows.rs index 4400e0c8395a2..1f17ab69f6660 100644 --- a/src/librustc_mir/borrow_check/flows.rs +++ b/src/librustc_mir/borrow_check/flows.rs @@ -23,7 +23,6 @@ use std::rc::Rc; crate type PoloniusOutput = Output; -// (forced to be `pub` due to its use as an associated type below.) crate struct Flows<'b, 'tcx> { borrows: FlowAtLocation<'tcx, Borrows<'b, 'tcx>>, pub uninits: FlowAtLocation<'tcx, MaybeUninitializedPlaces<'b, 'tcx>>, From daed67481511b65475069214cd8325ca9d018509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 21 Sep 2019 17:28:07 -0700 Subject: [PATCH 48/63] review comments --- src/librustc_typeck/check/coercion.rs | 8 +++--- src/librustc_typeck/check/mod.rs | 39 ++++++++++----------------- src/test/ui/issues/issue-33575.rs | 2 +- 3 files changed, 19 insertions(+), 30 deletions(-) diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index ac1bf8e91a149..d98e1f3e1283f 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -821,11 +821,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let (adjustments, _) = self.register_infer_ok_obligations(ok); self.apply_adjustments(expr, adjustments); - if expr_ty.references_error() { - Ok(self.tcx.types.err) + Ok(if expr_ty.references_error() { + self.tcx.types.err } else { - Ok(target) - } + target + }) } /// Same as `try_coerce()`, but without side-effects. diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 75942731d8790..07eb034054c95 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3751,36 +3751,25 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Some(ref init) = local.init { let init_ty = self.check_decl_initializer(local, &init); - if init_ty.references_error() { - // Override the types everywhere with `types.err` to avoid knock down errors. - self.write_ty(local.hir_id, init_ty); - self.write_ty(local.pat.hir_id, init_ty); - self.locals.borrow_mut().insert(local.hir_id, LocalTy { - decl_ty: t, - revealed_ty: init_ty, - }); - self.locals.borrow_mut().insert(local.pat.hir_id, LocalTy { - decl_ty: t, - revealed_ty: init_ty, - }); - } + self.overwrite_local_ty_if_err(local, t, init_ty); } self.check_pat_top(&local.pat, t, None); let pat_ty = self.node_ty(local.pat.hir_id); - debug!("check_decl_local pat_ty {:?}", pat_ty); - if pat_ty.references_error() { + self.overwrite_local_ty_if_err(local, t, pat_ty); + } + + fn overwrite_local_ty_if_err(&self, local: &'tcx hir::Local, decl_ty: Ty<'tcx>, ty: Ty<'tcx>) { + if ty.references_error() { // Override the types everywhere with `types.err` to avoid knock down errors. - self.write_ty(local.hir_id, pat_ty); - self.write_ty(local.pat.hir_id, pat_ty); - self.locals.borrow_mut().insert(local.hir_id, LocalTy { - decl_ty: t, - revealed_ty: pat_ty, - }); - self.locals.borrow_mut().insert(local.pat.hir_id, LocalTy { - decl_ty: t, - revealed_ty: pat_ty, - }); + self.write_ty(local.hir_id, ty); + self.write_ty(local.pat.hir_id, ty); + let local_ty = LocalTy { + decl_ty, + revealed_ty: ty, + }; + self.locals.borrow_mut().insert(local.hir_id, local_ty); + self.locals.borrow_mut().insert(local.pat.hir_id, local_ty); } } diff --git a/src/test/ui/issues/issue-33575.rs b/src/test/ui/issues/issue-33575.rs index d97afc3d31d5c..09c499452adb6 100644 --- a/src/test/ui/issues/issue-33575.rs +++ b/src/test/ui/issues/issue-33575.rs @@ -1,4 +1,4 @@ fn main() { let baz = ().foo(); //~ ERROR no method named `foo` found for type `()` in the current scope - ::from_str(&baz); // No complains about `str` being unsized + ::from_str(&baz); // No complaints about `str` being unsized } From 0f2f16db5364663b4a2f092bba61dc3b056902e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 21 Sep 2019 18:57:37 -0700 Subject: [PATCH 49/63] review comments: wording --- src/libsyntax/parse/parser/generics.rs | 2 +- src/test/ui/parser/assoc-type-in-type-arg.rs | 2 +- src/test/ui/parser/assoc-type-in-type-arg.stderr | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libsyntax/parse/parser/generics.rs b/src/libsyntax/parse/parser/generics.rs index 1ffdda19c80b5..2ecd9cca3c64b 100644 --- a/src/libsyntax/parse/parser/generics.rs +++ b/src/libsyntax/parse/parser/generics.rs @@ -107,7 +107,7 @@ impl<'a> Parser<'a> { Ok(where_predicate) => { self.struct_span_err( where_predicate.span(), - "associated type bounds do not belong here", + "bounds on associated types do not belong here", ) .span_label(where_predicate.span(), "belongs in `where` clause") .emit(); diff --git a/src/test/ui/parser/assoc-type-in-type-arg.rs b/src/test/ui/parser/assoc-type-in-type-arg.rs index 09765f01371aa..000956ea24fad 100644 --- a/src/test/ui/parser/assoc-type-in-type-arg.rs +++ b/src/test/ui/parser/assoc-type-in-type-arg.rs @@ -3,7 +3,7 @@ trait Tr { } struct Bar<'a, Item: Tr, ::TrSubtype: 'a> { - //~^ ERROR associated type bounds do not belong here + //~^ ERROR bounds on associated types do not belong here item: Item, item_sub: &'a ::TrSubtype, } diff --git a/src/test/ui/parser/assoc-type-in-type-arg.stderr b/src/test/ui/parser/assoc-type-in-type-arg.stderr index 06addb0241725..b637702f21e90 100644 --- a/src/test/ui/parser/assoc-type-in-type-arg.stderr +++ b/src/test/ui/parser/assoc-type-in-type-arg.stderr @@ -1,4 +1,4 @@ -error: associated type bounds do not belong here +error: bounds on associated types do not belong here --> $DIR/assoc-type-in-type-arg.rs:5:26 | LL | struct Bar<'a, Item: Tr, ::TrSubtype: 'a> { From 3f2855e4a6003f7e4d5736843d9ca5f327bef9d7 Mon Sep 17 00:00:00 2001 From: ben Date: Sun, 22 Sep 2019 17:24:09 +1200 Subject: [PATCH 50/63] Infer consts consistently. Moved some logic into super_combined_consts, also removed some duplicated logic from TypeRelation methods. --- src/librustc/infer/combine.rs | 7 ++++ src/librustc/infer/equate.rs | 40 ++---------------- src/librustc/infer/glb.rs | 5 --- src/librustc/infer/lub.rs | 5 --- src/librustc/infer/sub.rs | 42 ++----------------- src/test/ui/const-generics/issue-64519.rs | 21 ++++++++++ src/test/ui/const-generics/issue-64519.stderr | 8 ++++ 7 files changed, 42 insertions(+), 86 deletions(-) create mode 100644 src/test/ui/const-generics/issue-64519.rs create mode 100644 src/test/ui/const-generics/issue-64519.stderr diff --git a/src/librustc/infer/combine.rs b/src/librustc/infer/combine.rs index 4a9b68f24371d..966c5810171af 100644 --- a/src/librustc/infer/combine.rs +++ b/src/librustc/infer/combine.rs @@ -30,6 +30,7 @@ use super::sub::Sub; use super::type_variable::TypeVariableValue; use super::unify_key::{ConstVarValue, ConstVariableValue}; use super::unify_key::{ConstVariableOrigin, ConstVariableOriginKind}; +use super::unify_key::replace_if_possible; use crate::hir::def_id::DefId; use crate::mir::interpret::ConstValue; @@ -127,6 +128,12 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> { where R: TypeRelation<'tcx>, { + debug!("{}.consts({:?}, {:?})", relation.tag(), a, b); + if a == b { return Ok(a); } + + let a = replace_if_possible(self.const_unification_table.borrow_mut(), a); + let b = replace_if_possible(self.const_unification_table.borrow_mut(), b); + let a_is_expected = relation.a_is_expected(); match (a.val, b.val) { diff --git a/src/librustc/infer/equate.rs b/src/librustc/infer/equate.rs index 96d40bc81add2..6065387647fa7 100644 --- a/src/librustc/infer/equate.rs +++ b/src/librustc/infer/equate.rs @@ -1,14 +1,12 @@ -use super::combine::{CombineFields, RelationDir, const_unification_error}; +use super::combine::{CombineFields, RelationDir}; use super::Subtype; use crate::hir::def_id::DefId; -use crate::ty::{self, Ty, TyCtxt, InferConst}; +use crate::ty::{self, Ty, TyCtxt}; use crate::ty::TyVar; use crate::ty::subst::SubstsRef; use crate::ty::relate::{self, Relate, RelateResult, TypeRelation}; -use crate::mir::interpret::ConstValue; -use crate::infer::unify_key::replace_if_possible; /// Ensures `a` is made equal to `b`. Returns `a` on success. pub struct Equate<'combine, 'infcx, 'tcx> { @@ -108,39 +106,7 @@ impl TypeRelation<'tcx> for Equate<'combine, 'infcx, 'tcx> { a: &'tcx ty::Const<'tcx>, b: &'tcx ty::Const<'tcx>, ) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> { - debug!("{}.consts({:?}, {:?})", self.tag(), a, b); - if a == b { return Ok(a); } - - let infcx = self.fields.infcx; - let a = replace_if_possible(infcx.const_unification_table.borrow_mut(), a); - let b = replace_if_possible(infcx.const_unification_table.borrow_mut(), b); - let a_is_expected = self.a_is_expected(); - - match (a.val, b.val) { - (ConstValue::Infer(InferConst::Var(a_vid)), - ConstValue::Infer(InferConst::Var(b_vid))) => { - infcx.const_unification_table - .borrow_mut() - .unify_var_var(a_vid, b_vid) - .map_err(|e| const_unification_error(a_is_expected, e))?; - return Ok(a); - } - - (ConstValue::Infer(InferConst::Var(a_id)), _) => { - self.fields.infcx.unify_const_variable(a_is_expected, a_id, b)?; - return Ok(a); - } - - (_, ConstValue::Infer(InferConst::Var(b_id))) => { - self.fields.infcx.unify_const_variable(!a_is_expected, b_id, a)?; - return Ok(a); - } - - _ => {} - } - - self.fields.infcx.super_combine_consts(self, a, b)?; - Ok(a) + self.fields.infcx.super_combine_consts(self, a, b) } fn binders(&mut self, a: &ty::Binder, b: &ty::Binder) diff --git a/src/librustc/infer/glb.rs b/src/librustc/infer/glb.rs index 10e45321a6d6a..37de54a7e8558 100644 --- a/src/librustc/infer/glb.rs +++ b/src/librustc/infer/glb.rs @@ -66,11 +66,6 @@ impl TypeRelation<'tcx> for Glb<'combine, 'infcx, 'tcx> { a: &'tcx ty::Const<'tcx>, b: &'tcx ty::Const<'tcx>, ) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> { - debug!("{}.consts({:?}, {:?})", self.tag(), a, b); - if a == b { - return Ok(a); - } - self.fields.infcx.super_combine_consts(self, a, b) } diff --git a/src/librustc/infer/lub.rs b/src/librustc/infer/lub.rs index 8b64cda7bd26d..a1a94865e74e3 100644 --- a/src/librustc/infer/lub.rs +++ b/src/librustc/infer/lub.rs @@ -66,11 +66,6 @@ impl TypeRelation<'tcx> for Lub<'combine, 'infcx, 'tcx> { a: &'tcx ty::Const<'tcx>, b: &'tcx ty::Const<'tcx>, ) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> { - debug!("{}.consts({:?}, {:?})", self.tag(), a, b); - if a == b { - return Ok(a); - } - self.fields.infcx.super_combine_consts(self, a, b) } diff --git a/src/librustc/infer/sub.rs b/src/librustc/infer/sub.rs index 76db55ecfa8ef..67c97ef5d8b29 100644 --- a/src/librustc/infer/sub.rs +++ b/src/librustc/infer/sub.rs @@ -1,13 +1,11 @@ use super::SubregionOrigin; -use super::combine::{CombineFields, RelationDir, const_unification_error}; +use super::combine::{CombineFields, RelationDir}; use crate::traits::Obligation; -use crate::ty::{self, Ty, TyCtxt, InferConst}; +use crate::ty::{self, Ty, TyCtxt}; use crate::ty::TyVar; use crate::ty::fold::TypeFoldable; use crate::ty::relate::{Cause, Relate, RelateResult, TypeRelation}; -use crate::infer::unify_key::replace_if_possible; -use crate::mir::interpret::ConstValue; use std::mem; /// Ensures `a` is made a subtype of `b`. Returns `a` on success. @@ -142,41 +140,7 @@ impl TypeRelation<'tcx> for Sub<'combine, 'infcx, 'tcx> { a: &'tcx ty::Const<'tcx>, b: &'tcx ty::Const<'tcx>, ) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> { - debug!("{}.consts({:?}, {:?})", self.tag(), a, b); - if a == b { return Ok(a); } - - let infcx = self.fields.infcx; - let a = replace_if_possible(infcx.const_unification_table.borrow_mut(), a); - let b = replace_if_possible(infcx.const_unification_table.borrow_mut(), b); - - // Consts can only be equal or unequal to each other: there's no subtyping - // relation, so we're just going to perform equating here instead. - let a_is_expected = self.a_is_expected(); - match (a.val, b.val) { - (ConstValue::Infer(InferConst::Var(a_vid)), - ConstValue::Infer(InferConst::Var(b_vid))) => { - infcx.const_unification_table - .borrow_mut() - .unify_var_var(a_vid, b_vid) - .map_err(|e| const_unification_error(a_is_expected, e))?; - return Ok(a); - } - - (ConstValue::Infer(InferConst::Var(a_id)), _) => { - self.fields.infcx.unify_const_variable(a_is_expected, a_id, b)?; - return Ok(a); - } - - (_, ConstValue::Infer(InferConst::Var(b_id))) => { - self.fields.infcx.unify_const_variable(!a_is_expected, b_id, a)?; - return Ok(a); - } - - _ => {} - } - - self.fields.infcx.super_combine_consts(self, a, b)?; - Ok(a) + self.fields.infcx.super_combine_consts(self, a, b) } fn binders(&mut self, a: &ty::Binder, b: &ty::Binder) diff --git a/src/test/ui/const-generics/issue-64519.rs b/src/test/ui/const-generics/issue-64519.rs new file mode 100644 index 0000000000000..72cce9b4843d7 --- /dev/null +++ b/src/test/ui/const-generics/issue-64519.rs @@ -0,0 +1,21 @@ +// check-pass + +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +struct Foo { + state: Option<[u8; D]>, +} + +impl Iterator for Foo<{D}> { + type Item = [u8; D]; + fn next(&mut self) -> Option { + if true { + return Some(self.state.unwrap().clone()); + } else { + return Some(self.state.unwrap().clone()); + } + } +} + +fn main() {} diff --git a/src/test/ui/const-generics/issue-64519.stderr b/src/test/ui/const-generics/issue-64519.stderr new file mode 100644 index 0000000000000..d368f39d903a0 --- /dev/null +++ b/src/test/ui/const-generics/issue-64519.stderr @@ -0,0 +1,8 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/issue-64519.rs:3:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + From bbce971bf7cc37f5f02b759b7e4235ec591a5a4b Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 19 Sep 2019 08:32:31 +0000 Subject: [PATCH 51/63] Update clippy --- Cargo.lock | 30 +++++++++++++++++++++--------- src/tools/clippy | 2 +- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f52e9738da8f9..fa749e5e3aebe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -455,7 +455,7 @@ dependencies = [ "itertools 0.8.0", "lazy_static 1.3.0", "matches", - "pulldown-cmark", + "pulldown-cmark 0.6.0", "quine-mc_cluskey", "regex-syntax", "semver", @@ -1637,7 +1637,7 @@ dependencies = [ "num_cpus", "tokio", "tokio-codec", - "unicase 2.4.0", + "unicase 2.5.1", ] [[package]] @@ -1875,7 +1875,7 @@ dependencies = [ "log", "memchr", "open", - "pulldown-cmark", + "pulldown-cmark 0.5.3", "regex", "serde", "serde_derive", @@ -1897,7 +1897,7 @@ dependencies = [ "log", "mdbook", "memchr", - "pulldown-cmark", + "pulldown-cmark 0.5.3", "rayon", "regex", "reqwest", @@ -1957,7 +1957,7 @@ version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e27ca21f40a310bd06d9031785f4801710d566c184a6e15bad4f1d9b65f9425" dependencies = [ - "unicase 2.4.0", + "unicase 2.5.1", ] [[package]] @@ -2561,7 +2561,19 @@ dependencies = [ "bitflags", "getopts", "memchr", - "unicase 2.4.0", + "unicase 2.5.1", +] + +[[package]] +name = "pulldown-cmark" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b0ad0d4c1702965ee6bb5b4ff5e71f83850b497d497e9444302987bf9e26a4" +dependencies = [ + "bitflags", + "getopts", + "memchr", + "unicase 2.5.1", ] [[package]] @@ -3732,7 +3744,7 @@ name = "rustdoc" version = "0.0.0" dependencies = [ "minifier", - "pulldown-cmark", + "pulldown-cmark 0.5.3", "rustc-rayon", "tempfile", ] @@ -4739,9 +4751,9 @@ dependencies = [ [[package]] name = "unicase" -version = "2.4.0" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a84e5511b2a947f3ae965dcb29b13b7b1691b6e7332cf5dbc1744138d5acb7f6" +checksum = "2e2e6bd1e59e56598518beb94fd6db628ded570326f0a98c679a304bd9f00150" dependencies = [ "version_check", ] diff --git a/src/tools/clippy b/src/tools/clippy index 58e01ea4d7df6..157edad6205fd 160000 --- a/src/tools/clippy +++ b/src/tools/clippy @@ -1 +1 @@ -Subproject commit 58e01ea4d7df69e658c034afbfa6d0abd90808ed +Subproject commit 157edad6205fdd6a4f5932fba2675c6190746358 From d06de5d8503c46938e3fa52bfde75c3ea6f98f14 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sat, 21 Sep 2019 05:28:47 +0000 Subject: [PATCH 52/63] Update rls to fix build error --- src/tools/rls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rls b/src/tools/rls index d9aa23a43ad29..80a1d340f7d65 160000 --- a/src/tools/rls +++ b/src/tools/rls @@ -1 +1 @@ -Subproject commit d9aa23a43ad29e3a10551a1425ef5d5baef28d70 +Subproject commit 80a1d340f7d65b466bd3e0513c6b4b53498de2ff From ad4787a992774bc91d257ffab129e6d66dd451ed Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sun, 22 Sep 2019 17:18:45 +0200 Subject: [PATCH 53/63] Clarify the "since" tidy check --- src/tools/tidy/src/features.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index 50e9116c778ea..6d38cfc8630d1 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -307,7 +307,7 @@ fn collect_lang_features_in(base: &Path, file: &str, bad: &mut bool) -> Features if prev_since > since { tidy_error!( bad, - "{}:{}: feature {} is not sorted by since", + "{}:{}: feature {} is not sorted by \"since\" (version number)", path.display(), line_number, name, From b370c111fdb2bc6c6a67bc0ebb7bc4946344a15a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 4 Sep 2019 10:17:59 -0700 Subject: [PATCH 54/63] On obligation errors point at the unfulfilled binding when possible --- src/librustc/hir/mod.rs | 13 +++ src/librustc/traits/error_reporting.rs | 22 ++++- src/librustc/traits/mod.rs | 3 + src/librustc/traits/structural_impls.rs | 1 + src/librustc/ty/mod.rs | 4 + src/librustc_typeck/check/mod.rs | 44 ++++++--- .../anonymous-higher-ranked-lifetime.stderr | 44 ++++----- ...nding-to-type-defined-in-supertrait.stderr | 4 +- .../associated-types-eq-3.stderr | 2 +- .../associated-types-eq-hr.stderr | 98 ++++++++----------- .../associated-types-issue-20346.stderr | 2 +- ...ated-types-multiple-types-one-trait.stderr | 4 +- .../associated-types-path-2.stderr | 4 +- .../higher-ranked-projection.bad.stderr | 12 +-- .../ui/async-await/async-fn-nonsend.stderr | 8 +- .../async-await/issues/issue-62009-1.stderr | 5 +- src/test/ui/chalkify/type_inference.stderr | 2 +- .../expect-fn-supply-fn.stderr | 51 +++++----- .../expect-infer-var-appearing-twice.stderr | 17 ++-- .../ui/closures/closure-bounds-subtype.stderr | 2 +- src/test/ui/closures/closure-move-sync.stderr | 12 ++- src/test/ui/defaulted-never-note.rs | 3 +- src/test/ui/defaulted-never-note.stderr | 4 +- ...rives-span-Hash-enum-struct-variant.stderr | 5 +- .../ui/derives/derives-span-Hash-enum.stderr | 5 +- .../derives/derives-span-Hash-struct.stderr | 5 +- .../derives-span-Hash-tuple-struct.stderr | 5 +- src/test/ui/derives/deriving-copyclone.stderr | 6 +- .../ui/did_you_mean/recursion_limit.stderr | 2 +- src/test/ui/error-codes/E0271.stderr | 2 +- src/test/ui/error-codes/E0277-2.stderr | 2 +- src/test/ui/error-codes/E0277.stderr | 2 +- .../ui/error-should-say-copy-not-pod.stderr | 2 +- .../extern/extern-types-not-sync-send.stderr | 4 +- .../ui/extern/extern-types-unsized.stderr | 8 +- .../ui/extern/extern-wrong-value-type.stderr | 2 +- src/test/ui/fmt/send-sync.stderr | 4 +- src/test/ui/fn/fn-trait-formatting.stderr | 2 +- ...erator-yielding-or-returning-itself.stderr | 13 ++- src/test/ui/generator/not-send-sync.stderr | 4 +- src/test/ui/generator/static-not-unpin.stderr | 2 +- src/test/ui/hrtb/hrtb-conflate-regions.stderr | 13 ++- ...b-exists-forall-trait-contravariant.stderr | 15 ++- .../hrtb-exists-forall-trait-covariant.stderr | 15 ++- .../hrtb-exists-forall-trait-invariant.stderr | 15 ++- ...igher-ranker-supertraits-transitive.stderr | 13 ++- .../hrtb-higher-ranker-supertraits.stderr | 31 +++--- src/test/ui/hrtb/hrtb-just-for-static.stderr | 26 +++-- src/test/ui/hrtb/issue-46989.stderr | 2 +- src/test/ui/impl-trait/auto-trait-leak.stderr | 2 +- .../ui/impl-trait/auto-trait-leak2.stderr | 4 +- .../interior-mutability.stderr | 6 +- src/test/ui/issues/issue-1920-1.stderr | 2 +- src/test/ui/issues/issue-1920-2.stderr | 2 +- src/test/ui/issues/issue-1920-3.stderr | 2 +- src/test/ui/issues/issue-21160.stderr | 5 +- src/test/ui/issues/issue-21763.stderr | 2 +- src/test/ui/issues/issue-25076.stderr | 2 +- src/test/ui/issues/issue-32963.stderr | 2 +- src/test/ui/issues/issue-40827.stderr | 4 +- src/test/ui/issues/issue-43623.stderr | 38 ++++--- src/test/ui/issues/issue-47706.stderr | 19 ++-- src/test/ui/issues/issue-60283.stderr | 32 +++--- src/test/ui/kindck/kindck-copy.stderr | 22 ++--- .../kindck/kindck-impl-type-params-2.stderr | 2 +- .../kindck/kindck-inherited-copy-bound.stderr | 2 +- .../ui/kindck/kindck-nonsendable-1.stderr | 2 +- src/test/ui/kindck/kindck-send-object.stderr | 4 +- src/test/ui/kindck/kindck-send-object1.stderr | 4 +- src/test/ui/kindck/kindck-send-object2.stderr | 4 +- src/test/ui/kindck/kindck-send-owned.stderr | 2 +- src/test/ui/kindck/kindck-send-unsafe.stderr | 2 +- .../overlap-marker-trait.stderr | 2 +- src/test/ui/mismatched_types/E0631.stderr | 8 +- .../mismatched_types/closure-arg-count.stderr | 6 +- .../closure-arg-type-mismatch.stderr | 4 +- .../mismatched_types/closure-mismatch.stderr | 4 +- .../ui/mismatched_types/fn-variance-1.stderr | 4 +- .../unboxed-closures-vtable-mismatch.rs | 3 +- .../unboxed-closures-vtable-mismatch.stderr | 4 +- src/test/ui/mut/mutable-enum-indirect.stderr | 2 +- src/test/ui/mutexguard-sync.stderr | 2 +- src/test/ui/namespace/namespace-mix.stderr | 88 ++++++++--------- src/test/ui/no-send-res-ports.stderr | 6 +- src/test/ui/no_send-enum.stderr | 2 +- src/test/ui/no_send-rc.stderr | 2 +- src/test/ui/no_send-struct.stderr | 2 +- src/test/ui/no_share-enum.stderr | 2 +- src/test/ui/no_share-struct.stderr | 2 +- src/test/ui/not-panic/not-panic-safe-2.stderr | 4 +- src/test/ui/not-panic/not-panic-safe-3.stderr | 4 +- src/test/ui/not-panic/not-panic-safe-4.stderr | 4 +- src/test/ui/not-panic/not-panic-safe-5.stderr | 2 +- src/test/ui/not-panic/not-panic-safe-6.stderr | 4 +- src/test/ui/not-panic/not-panic-safe.stderr | 2 +- src/test/ui/not-sync.stderr | 12 +-- src/test/ui/object-does-not-impl-trait.stderr | 2 +- src/test/ui/on-unimplemented/on-trait.stderr | 4 +- src/test/ui/overlap-marker-trait.stderr | 2 +- src/test/ui/phantom-oibit.stderr | 4 +- .../regions-close-object-into-object-5.stderr | 12 +-- .../termination-trait-test-wrong-type.stderr | 6 +- src/test/ui/str/str-mut-idx.stderr | 2 +- src/test/ui/substs-ppaux.normal.stderr | 2 +- src/test/ui/substs-ppaux.verbose.stderr | 2 +- ...rg-where-it-should-have-been-called.stderr | 2 +- ...rg-where-it-should-have-been-called.stderr | 2 +- src/test/ui/suggestions/into-str.stderr | 2 +- .../trait-alias-cross-crate.stderr | 4 +- .../traits/trait-suggest-where-clause.stderr | 24 ++++- ...its-inductive-overflow-simultaneous.stderr | 2 +- ...inductive-overflow-supertrait-oibit.stderr | 2 +- ...raits-inductive-overflow-supertrait.stderr | 2 +- ...raits-inductive-overflow-two-traits.stderr | 2 +- .../ui/traits/traits-negative-impls.stderr | 10 +- .../trivial-bounds/trivial-bounds-leak.stderr | 2 +- src/test/ui/try-operator-on-main.stderr | 2 +- src/test/ui/type/type-annotation-needed.rs | 1 + .../ui/type/type-annotation-needed.stderr | 4 +- ...ypeck-default-trait-impl-assoc-type.stderr | 2 +- ...ault-trait-impl-constituent-types-2.stderr | 2 +- ...efault-trait-impl-constituent-types.stderr | 2 +- ...ck-default-trait-impl-negation-send.stderr | 2 +- ...ck-default-trait-impl-negation-sync.stderr | 6 +- .../typeck-default-trait-impl-negation.stderr | 4 +- ...ypeck-default-trait-impl-precedence.stderr | 2 +- ...ypeck-default-trait-impl-send-param.stderr | 2 +- .../typeck/typeck-unsafe-always-share.stderr | 8 +- .../unboxed-closure-sugar-default.stderr | 2 +- .../unboxed-closure-sugar-equiv.stderr | 2 +- .../unboxed-closures-fnmut-as-fn.stderr | 2 +- .../unboxed-closures-unsafe-extern-fn.stderr | 10 +- .../unboxed-closures-wrong-abi.stderr | 10 +- ...d-closures-wrong-arg-type-extern-fn.stderr | 10 +- .../ui/unsized/unsized-bare-typaram.stderr | 2 +- src/test/ui/unsized/unsized-struct.stderr | 2 +- src/test/ui/unsized3.stderr | 8 +- ...traints-are-local-for-inherent-impl.stderr | 2 +- ...onstraints-are-local-for-trait-impl.stderr | 2 +- .../where-clauses-unsatisfied.stderr | 2 +- .../ui/where-clauses/where-for-self-2.stderr | 12 +-- 141 files changed, 588 insertions(+), 512 deletions(-) diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 2c8590aa4e3fa..4f942a22cb8ae 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -2750,3 +2750,16 @@ pub enum Node<'hir> { Crate, } + +impl<'hir> Node<'hir> { + pub fn ident(&self) -> Option { + + match self { + Node::TraitItem(TraitItem { ident, .. }) | + Node::ImplItem(ImplItem { ident, .. }) | + Node::ForeignItem(ForeignItem { ident, .. }) | + Node::Item(Item { ident, .. }) => Some(*ident), + _ => None, + } + } +} diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index c9018f1c290d2..03f8ac250e925 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -40,10 +40,12 @@ use syntax::symbol::{sym, kw}; use syntax_pos::{DUMMY_SP, Span, ExpnKind}; impl<'a, 'tcx> InferCtxt<'a, 'tcx> { - pub fn report_fulfillment_errors(&self, - errors: &[FulfillmentError<'tcx>], - body_id: Option, - fallback_has_occurred: bool) { + pub fn report_fulfillment_errors( + &self, + errors: &[FulfillmentError<'tcx>], + body_id: Option, + fallback_has_occurred: bool, + ) { #[derive(Debug)] struct ErrorDescriptor<'tcx> { predicate: ty::Predicate<'tcx>, @@ -1651,6 +1653,18 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { err.note(&msg); } } + ObligationCauseCode::BindingObligation(item_def_id, span) => { + let item_name = tcx.def_path_str(item_def_id); + let msg = format!("required by this bound in `{}`", item_name); + if let Some(ident) = tcx.opt_item_name(item_def_id) { + err.span_label(ident.span, ""); + } + if span != DUMMY_SP { + err.span_label(span, &msg); + } else { + err.note(&msg); + } + } ObligationCauseCode::ObjectCastObligation(object_ty) => { err.note(&format!("required for the cast to the object type `{}`", self.ty_to_string(object_ty))); diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index 27e4d1237c252..1123422ad6008 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -176,6 +176,9 @@ pub enum ObligationCauseCode<'tcx> { /// also implement all supertraits of `X`. ItemObligation(DefId), + /// Like `ItemObligation`, but with extra detail on the source of the obligation. + BindingObligation(DefId, Span), + /// A type like `&'a T` is WF only if `T: 'a`. ReferenceOutlivesReferent(Ty<'tcx>), diff --git a/src/librustc/traits/structural_impls.rs b/src/librustc/traits/structural_impls.rs index 6930c9368282b..68c97226f89cf 100644 --- a/src/librustc/traits/structural_impls.rs +++ b/src/librustc/traits/structural_impls.rs @@ -472,6 +472,7 @@ impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> { super::TupleElem => Some(super::TupleElem), super::ProjectionWf(proj) => tcx.lift(&proj).map(super::ProjectionWf), super::ItemObligation(def_id) => Some(super::ItemObligation(def_id)), + super::BindingObligation(def_id, span) => Some(super::BindingObligation(def_id, span)), super::ReferenceOutlivesReferent(ty) => { tcx.lift(&ty).map(super::ReferenceOutlivesReferent) } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 5ca819e12f232..8bb9648e031ef 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2797,6 +2797,10 @@ impl<'tcx> TyCtxt<'tcx> { }) } + pub fn opt_item_name(self, def_id: DefId) -> Option { + self.hir().as_local_hir_id(def_id).and_then(|hir_id| self.hir().get(hir_id).ident()) + } + pub fn opt_associated_item(self, def_id: DefId) -> Option { let is_associated_item = if let Some(hir_id) = self.hir().as_local_hir_id(def_id) { match self.hir().get(hir_id) { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index c96eab8629889..743e6661247b6 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -2617,16 +2617,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// As `instantiate_type_scheme`, but for the bounds found in a /// generic type scheme. - fn instantiate_bounds(&self, span: Span, def_id: DefId, substs: SubstsRef<'tcx>) - -> ty::InstantiatedPredicates<'tcx> { + fn instantiate_bounds( + &self, + span: Span, + def_id: DefId, + substs: SubstsRef<'tcx>, + ) -> (ty::InstantiatedPredicates<'tcx>, Vec) { let bounds = self.tcx.predicates_of(def_id); + let spans: Vec = bounds.predicates.iter().map(|(_, span)| *span).collect(); let result = bounds.instantiate(self.tcx, substs); let result = self.normalize_associated_types_in(span, &result); - debug!("instantiate_bounds(bounds={:?}, substs={:?}) = {:?}", + debug!( + "instantiate_bounds(bounds={:?}, substs={:?}) = {:?}, {:?}", bounds, substs, - result); - result + result, + spans, + ); + (result, spans) } /// Replaces the opaque types from the given value with type variables, @@ -3194,8 +3202,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // All the input types from the fn signature must outlive the call // so as to validate implied bounds. - for &fn_input_ty in fn_inputs { - self.register_wf_obligation(fn_input_ty, sp, traits::MiscObligation); + for (fn_input_ty, arg_expr) in fn_inputs.iter().zip(args.iter()) { + self.register_wf_obligation(fn_input_ty, arg_expr.span, traits::MiscObligation); } let expected_arg_count = fn_inputs.len(); @@ -3604,7 +3612,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.write_user_type_annotation_from_substs(hir_id, did, substs, None); // Check bounds on type arguments used in the path. - let bounds = self.instantiate_bounds(path_span, did, substs); + let (bounds, _) = self.instantiate_bounds(path_span, did, substs); let cause = traits::ObligationCause::new( path_span, self.body_id, @@ -4730,11 +4738,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Add all the obligations that are required, substituting and // normalized appropriately. - let bounds = self.instantiate_bounds(span, def_id, &substs); - self.add_obligations_for_parameters( - traits::ObligationCause::new(span, self.body_id, traits::ItemObligation(def_id)), + let (bounds, spans) = self.instantiate_bounds(span, def_id, &substs); + + for (i, mut obligation) in traits::predicates_for_generics( + traits::ObligationCause::new( + span, + self.body_id, + traits::ItemObligation(def_id), + ), + self.param_env, &bounds, - ); + ).into_iter().enumerate() { + // This makes the error point at the bound, but we want to point at the argument + if let Some(span) = spans.get(i) { + obligation.cause.code = traits::BindingObligation(def_id, *span); + } + self.register_predicate(obligation); + } // Substitute the values for the type parameters into the type of // the referenced item. diff --git a/src/test/ui/anonymous-higher-ranked-lifetime.stderr b/src/test/ui/anonymous-higher-ranked-lifetime.stderr index c65a44bfbccfe..51550e1471e72 100644 --- a/src/test/ui/anonymous-higher-ranked-lifetime.stderr +++ b/src/test/ui/anonymous-higher-ranked-lifetime.stderr @@ -7,7 +7,7 @@ LL | f1(|_: (), _: ()| {}); | expected signature of `for<'r, 's> fn(&'r (), &'s ()) -> _` ... LL | fn f1(_: F) where F: Fn(&(), &()) {} - | ------------------------------------ required by `f1` + | -- ------------ required by this bound in `f1` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:2:5 @@ -18,7 +18,7 @@ LL | f1(|_: (), _: ()| {}); | expected signature of `fn(&(), &()) -> _` ... LL | fn f1(_: F) where F: Fn(&(), &()) {} - | ------------------------------------ required by `f1` + | -- ---------- required by this bound in `f1` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:4:5 @@ -29,7 +29,7 @@ LL | f2(|_: (), _: ()| {}); | expected signature of `for<'a, 'r> fn(&'a (), &'r ()) -> _` ... LL | fn f2(_: F) where F: for<'a> Fn(&'a (), &()) {} - | ----------------------------------------------- required by `f2` + | -- ----------------------- required by this bound in `f2` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:4:5 @@ -40,7 +40,7 @@ LL | f2(|_: (), _: ()| {}); | expected signature of `fn(&'a (), &()) -> _` ... LL | fn f2(_: F) where F: for<'a> Fn(&'a (), &()) {} - | ----------------------------------------------- required by `f2` + | -- ------------- required by this bound in `f2` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:6:5 @@ -51,7 +51,7 @@ LL | f3(|_: (), _: ()| {}); | expected signature of `for<'r> fn(&(), &'r ()) -> _` ... LL | fn f3<'a, F>(_: F) where F: Fn(&'a (), &()) {} - | ------------------------------------------- required by `f3` + | -- --------------- required by this bound in `f3` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:6:5 @@ -62,7 +62,7 @@ LL | f3(|_: (), _: ()| {}); | expected signature of `fn(&(), &()) -> _` ... LL | fn f3<'a, F>(_: F) where F: Fn(&'a (), &()) {} - | ------------------------------------------- required by `f3` + | -- ------------- required by this bound in `f3` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:8:5 @@ -73,7 +73,7 @@ LL | f4(|_: (), _: ()| {}); | expected signature of `for<'s, 'r> fn(&'s (), &'r ()) -> _` ... LL | fn f4(_: F) where F: for<'r> Fn(&(), &'r ()) {} - | ----------------------------------------------- required by `f4` + | -- ----------------------- required by this bound in `f4` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:8:5 @@ -84,7 +84,7 @@ LL | f4(|_: (), _: ()| {}); | expected signature of `fn(&(), &'r ()) -> _` ... LL | fn f4(_: F) where F: for<'r> Fn(&(), &'r ()) {} - | ----------------------------------------------- required by `f4` + | -- ------------- required by this bound in `f4` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:10:5 @@ -95,7 +95,7 @@ LL | f5(|_: (), _: ()| {}); | expected signature of `for<'r> fn(&'r (), &'r ()) -> _` ... LL | fn f5(_: F) where F: for<'r> Fn(&'r (), &'r ()) {} - | -------------------------------------------------- required by `f5` + | -- -------------------------- required by this bound in `f5` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:10:5 @@ -106,7 +106,7 @@ LL | f5(|_: (), _: ()| {}); | expected signature of `fn(&'r (), &'r ()) -> _` ... LL | fn f5(_: F) where F: for<'r> Fn(&'r (), &'r ()) {} - | -------------------------------------------------- required by `f5` + | -- ---------------- required by this bound in `f5` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:12:5 @@ -117,7 +117,7 @@ LL | g1(|_: (), _: ()| {}); | expected signature of `for<'r> fn(&'r (), std::boxed::Box<(dyn for<'s> std::ops::Fn(&'s ()) + 'static)>) -> _` ... LL | fn g1(_: F) where F: Fn(&(), Box) {} - | ------------------------------------------------- required by `g1` + | -- ------------------------- required by this bound in `g1` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:12:5 @@ -128,7 +128,7 @@ LL | g1(|_: (), _: ()| {}); | expected signature of `fn(&(), std::boxed::Box<(dyn for<'r> std::ops::Fn(&'r ()) + 'static)>) -> _` ... LL | fn g1(_: F) where F: Fn(&(), Box) {} - | ------------------------------------------------- required by `g1` + | -- ----------------------- required by this bound in `g1` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:14:5 @@ -139,7 +139,7 @@ LL | g2(|_: (), _: ()| {}); | expected signature of `for<'r> fn(&'r (), for<'s> fn(&'s ())) -> _` ... LL | fn g2(_: F) where F: Fn(&(), fn(&())) {} - | ---------------------------------------- required by `g2` + | -- ---------------- required by this bound in `g2` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:14:5 @@ -150,7 +150,7 @@ LL | g2(|_: (), _: ()| {}); | expected signature of `fn(&(), for<'r> fn(&'r ())) -> _` ... LL | fn g2(_: F) where F: Fn(&(), fn(&())) {} - | ---------------------------------------- required by `g2` + | -- -------------- required by this bound in `g2` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:16:5 @@ -161,7 +161,7 @@ LL | g3(|_: (), _: ()| {}); | expected signature of `for<'s> fn(&'s (), std::boxed::Box<(dyn for<'r> std::ops::Fn(&'r ()) + 'static)>) -> _` ... LL | fn g3(_: F) where F: for<'s> Fn(&'s (), Box) {} - | ------------------------------------------------------------ required by `g3` + | -- ------------------------------------ required by this bound in `g3` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:16:5 @@ -172,7 +172,7 @@ LL | g3(|_: (), _: ()| {}); | expected signature of `fn(&'s (), std::boxed::Box<(dyn for<'r> std::ops::Fn(&'r ()) + 'static)>) -> _` ... LL | fn g3(_: F) where F: for<'s> Fn(&'s (), Box) {} - | ------------------------------------------------------------ required by `g3` + | -- -------------------------- required by this bound in `g3` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:18:5 @@ -183,7 +183,7 @@ LL | g4(|_: (), _: ()| {}); | expected signature of `for<'s> fn(&'s (), for<'r> fn(&'r ())) -> _` ... LL | fn g4(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {} - | --------------------------------------------------- required by `g4` + | -- --------------------------- required by this bound in `g4` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:18:5 @@ -194,7 +194,7 @@ LL | g4(|_: (), _: ()| {}); | expected signature of `fn(&(), for<'r> fn(&'r ())) -> _` ... LL | fn g4(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {} - | --------------------------------------------------- required by `g4` + | -- ------------------------- required by this bound in `g4` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:20:5 @@ -205,7 +205,7 @@ LL | h1(|_: (), _: (), _: (), _: ()| {}); | expected signature of `for<'r, 's> fn(&'r (), std::boxed::Box<(dyn for<'t0> std::ops::Fn(&'t0 ()) + 'static)>, &'s (), for<'t0, 't1> fn(&'t0 (), &'t1 ())) -> _` ... LL | fn h1(_: F) where F: Fn(&(), Box, &(), fn(&(), &())) {} - | -------------------------------------------------------------------- required by `h1` + | -- -------------------------------------------- required by this bound in `h1` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:20:5 @@ -216,7 +216,7 @@ LL | h1(|_: (), _: (), _: (), _: ()| {}); | expected signature of `fn(&(), std::boxed::Box<(dyn for<'r> std::ops::Fn(&'r ()) + 'static)>, &(), for<'r, 's> fn(&'r (), &'s ())) -> _` ... LL | fn h1(_: F) where F: Fn(&(), Box, &(), fn(&(), &())) {} - | -------------------------------------------------------------------- required by `h1` + | -- ------------------------------------------ required by this bound in `h1` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:22:5 @@ -227,7 +227,7 @@ LL | h2(|_: (), _: (), _: (), _: ()| {}); | expected signature of `for<'r, 't0> fn(&'r (), std::boxed::Box<(dyn for<'s> std::ops::Fn(&'s ()) + 'static)>, &'t0 (), for<'s, 't1> fn(&'s (), &'t1 ())) -> _` ... LL | fn h2(_: F) where F: for<'t0> Fn(&(), Box, &'t0 (), fn(&(), &())) {} - | --------------------------------------------------------------------------------- required by `h2` + | -- --------------------------------------------------------- required by this bound in `h2` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:22:5 @@ -238,7 +238,7 @@ LL | h2(|_: (), _: (), _: (), _: ()| {}); | expected signature of `fn(&(), std::boxed::Box<(dyn for<'r> std::ops::Fn(&'r ()) + 'static)>, &'t0 (), for<'r, 's> fn(&'r (), &'s ())) -> _` ... LL | fn h2(_: F) where F: for<'t0> Fn(&(), Box, &'t0 (), fn(&(), &())) {} - | --------------------------------------------------------------------------------- required by `h2` + | -- ---------------------------------------------- required by this bound in `h2` error: aborting due to 22 previous errors diff --git a/src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.stderr b/src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.stderr index a3049892abc39..6a2135ca46445 100644 --- a/src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.stderr +++ b/src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.stderr @@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `::Color == Blue` --> $DIR/associated-types-binding-to-type-defined-in-supertrait.rs:31:10 | LL | fn blue_car>(c: C) { - | ------------------------------------ required by `blue_car` + | -------- ---------- required by this bound in `blue_car` ... LL | fn b() { blue_car(ModelT); } | ^^^^^^^^ expected struct `Black`, found struct `Blue` @@ -14,7 +14,7 @@ error[E0271]: type mismatch resolving `::Color == Black` --> $DIR/associated-types-binding-to-type-defined-in-supertrait.rs:32:10 | LL | fn black_car>(c: C) { - | -------------------------------------- required by `black_car` + | --------- ----------- required by this bound in `black_car` ... LL | fn c() { black_car(ModelU); } | ^^^^^^^^^ expected struct `Blue`, found struct `Black` diff --git a/src/test/ui/associated-types/associated-types-eq-3.stderr b/src/test/ui/associated-types/associated-types-eq-3.stderr index c9d88b7af0753..83d89924944ab 100644 --- a/src/test/ui/associated-types/associated-types-eq-3.stderr +++ b/src/test/ui/associated-types/associated-types-eq-3.stderr @@ -13,7 +13,7 @@ error[E0271]: type mismatch resolving `::A == Bar` --> $DIR/associated-types-eq-3.rs:38:5 | LL | fn foo1>(x: I) { - | ---------------------------- required by `foo1` + | ---- ----- required by this bound in `foo1` ... LL | foo1(a); | ^^^^ expected usize, found struct `Bar` diff --git a/src/test/ui/associated-types/associated-types-eq-hr.stderr b/src/test/ui/associated-types/associated-types-eq-hr.stderr index 05e6ed69812ad..f560aefd637c0 100644 --- a/src/test/ui/associated-types/associated-types-eq-hr.stderr +++ b/src/test/ui/associated-types/associated-types-eq-hr.stderr @@ -1,15 +1,13 @@ error[E0271]: type mismatch resolving `for<'x> >::A == &'x isize` --> $DIR/associated-types-eq-hr.rs:82:5 | -LL | / fn foo() -LL | | where T : for<'x> TheTrait<&'x isize, A = &'x isize> -LL | | { -LL | | // ok for IntStruct, but not UintStruct -LL | | } - | |_- required by `foo` +LL | fn foo() + | --- +LL | where T : for<'x> TheTrait<&'x isize, A = &'x isize> + | ------------- required by this bound in `foo` ... -LL | foo::(); - | ^^^^^^^^^^^^^^^^^ expected usize, found isize +LL | foo::(); + | ^^^^^^^^^^^^^^^^^ expected usize, found isize | = note: expected type `&usize` found type `&isize` @@ -17,15 +15,13 @@ LL | foo::(); error[E0271]: type mismatch resolving `for<'x> >::A == &'x usize` --> $DIR/associated-types-eq-hr.rs:86:5 | -LL | / fn bar() -LL | | where T : for<'x> TheTrait<&'x isize, A = &'x usize> -LL | | { -LL | | // ok for UintStruct, but not IntStruct -LL | | } - | |_- required by `bar` +LL | fn bar() + | --- +LL | where T : for<'x> TheTrait<&'x isize, A = &'x usize> + | ------------- required by this bound in `bar` ... -LL | bar::(); - | ^^^^^^^^^^^^^^^^ expected isize, found usize +LL | bar::(); + | ^^^^^^^^^^^^^^^^ expected isize, found usize | = note: expected type `&isize` found type `&usize` @@ -33,15 +29,13 @@ LL | bar::(); error[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize)>` is not satisfied --> $DIR/associated-types-eq-hr.rs:91:5 | -LL | / fn tuple_one() -LL | | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'x isize> -LL | | { -LL | | // not ok for tuple, two lifetimes and we pick first -LL | | } - | |_- required by `tuple_one` +LL | fn tuple_one() + | --------- +LL | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'x isize> + | ---------------------------------------------------------- required by this bound in `tuple_one` ... -LL | tuple_one::(); - | ^^^^^^^^^^^^^^^^^^ the trait `for<'x, 'y> TheTrait<(&'x isize, &'y isize)>` is not implemented for `Tuple` +LL | tuple_one::(); + | ^^^^^^^^^^^^^^^^^^ the trait `for<'x, 'y> TheTrait<(&'x isize, &'y isize)>` is not implemented for `Tuple` | = help: the following implementations were found: > @@ -49,28 +43,24 @@ LL | tuple_one::(); error[E0271]: type mismatch resolving `for<'x, 'y> >::A == &'x isize` --> $DIR/associated-types-eq-hr.rs:91:5 | -LL | / fn tuple_one() -LL | | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'x isize> -LL | | { -LL | | // not ok for tuple, two lifetimes and we pick first -LL | | } - | |_- required by `tuple_one` +LL | fn tuple_one() + | --------- +LL | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'x isize> + | ------------- required by this bound in `tuple_one` ... -LL | tuple_one::(); - | ^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'x, found concrete lifetime +LL | tuple_one::(); + | ^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'x, found concrete lifetime error[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize)>` is not satisfied --> $DIR/associated-types-eq-hr.rs:97:5 | -LL | / fn tuple_two() -LL | | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'y isize> -LL | | { -LL | | // not ok for tuple, two lifetimes and we pick second -LL | | } - | |_- required by `tuple_two` +LL | fn tuple_two() + | --------- +LL | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'y isize> + | ---------------------------------------------------------- required by this bound in `tuple_two` ... -LL | tuple_two::(); - | ^^^^^^^^^^^^^^^^^^ the trait `for<'x, 'y> TheTrait<(&'x isize, &'y isize)>` is not implemented for `Tuple` +LL | tuple_two::(); + | ^^^^^^^^^^^^^^^^^^ the trait `for<'x, 'y> TheTrait<(&'x isize, &'y isize)>` is not implemented for `Tuple` | = help: the following implementations were found: > @@ -78,28 +68,24 @@ LL | tuple_two::(); error[E0271]: type mismatch resolving `for<'x, 'y> >::A == &'y isize` --> $DIR/associated-types-eq-hr.rs:97:5 | -LL | / fn tuple_two() -LL | | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'y isize> -LL | | { -LL | | // not ok for tuple, two lifetimes and we pick second -LL | | } - | |_- required by `tuple_two` +LL | fn tuple_two() + | --------- +LL | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'y isize> + | ------------- required by this bound in `tuple_two` ... -LL | tuple_two::(); - | ^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'x, found concrete lifetime +LL | tuple_two::(); + | ^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'x, found concrete lifetime error[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize)>` is not satisfied --> $DIR/associated-types-eq-hr.rs:107:5 | -LL | / fn tuple_four() -LL | | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize)> -LL | | { -LL | | // not ok for tuple, two lifetimes, and lifetime matching is invariant -LL | | } - | |_- required by `tuple_four` +LL | fn tuple_four() + | ---------- +LL | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize)> + | ------------------------------------------- required by this bound in `tuple_four` ... -LL | tuple_four::(); - | ^^^^^^^^^^^^^^^^^^^ the trait `for<'x, 'y> TheTrait<(&'x isize, &'y isize)>` is not implemented for `Tuple` +LL | tuple_four::(); + | ^^^^^^^^^^^^^^^^^^^ the trait `for<'x, 'y> TheTrait<(&'x isize, &'y isize)>` is not implemented for `Tuple` | = help: the following implementations were found: > diff --git a/src/test/ui/associated-types/associated-types-issue-20346.stderr b/src/test/ui/associated-types/associated-types-issue-20346.stderr index e037bd851ca21..c8f8725afc45c 100644 --- a/src/test/ui/associated-types/associated-types-issue-20346.stderr +++ b/src/test/ui/associated-types/associated-types-issue-20346.stderr @@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving ` as Iterator>::Item == std::op --> $DIR/associated-types-issue-20346.rs:34:5 | LL | fn is_iterator_of>(_: &I) {} - | ------------------------------------------------ required by `is_iterator_of` + | -------------- ------ required by this bound in `is_iterator_of` ... LL | is_iterator_of::, _>(&adapter); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter, found enum `std::option::Option` diff --git a/src/test/ui/associated-types/associated-types-multiple-types-one-trait.stderr b/src/test/ui/associated-types/associated-types-multiple-types-one-trait.stderr index d6328a64c7c74..c7de186c1d3e0 100644 --- a/src/test/ui/associated-types/associated-types-multiple-types-one-trait.stderr +++ b/src/test/ui/associated-types/associated-types-multiple-types-one-trait.stderr @@ -5,7 +5,7 @@ LL | want_y(t); | ^^^^^^ expected associated type, found i32 ... LL | fn want_y>(t: &T) { } - | ------------------------------ required by `want_y` + | ------ ----- required by this bound in `want_y` | = note: expected type `::Y` found type `i32` @@ -19,7 +19,7 @@ LL | want_x(t); | ^^^^^^ expected associated type, found u32 ... LL | fn want_x>(t: &T) { } - | ------------------------------ required by `want_x` + | ------ ----- required by this bound in `want_x` | = note: expected type `::X` found type `u32` diff --git a/src/test/ui/associated-types/associated-types-path-2.stderr b/src/test/ui/associated-types/associated-types-path-2.stderr index a8fcaeac95d5f..bb2e7251849d3 100644 --- a/src/test/ui/associated-types/associated-types-path-2.stderr +++ b/src/test/ui/associated-types/associated-types-path-2.stderr @@ -12,7 +12,7 @@ error[E0277]: the trait bound `u32: Foo` is not satisfied --> $DIR/associated-types-path-2.rs:29:5 | LL | pub fn f1(a: T, x: T::A) {} - | -------------------------------- required by `f1` + | -- --- required by this bound in `f1` ... LL | f1(2u32, 4u32); | ^^ the trait `Foo` is not implemented for `u32` @@ -27,7 +27,7 @@ error[E0277]: the trait bound `u32: Foo` is not satisfied --> $DIR/associated-types-path-2.rs:35:5 | LL | pub fn f1(a: T, x: T::A) {} - | -------------------------------- required by `f1` + | -- --- required by this bound in `f1` ... LL | f1(2u32, 4i32); | ^^ the trait `Foo` is not implemented for `u32` diff --git a/src/test/ui/associated-types/higher-ranked-projection.bad.stderr b/src/test/ui/associated-types/higher-ranked-projection.bad.stderr index 22d44888e951b..74c9ad2c39e67 100644 --- a/src/test/ui/associated-types/higher-ranked-projection.bad.stderr +++ b/src/test/ui/associated-types/higher-ranked-projection.bad.stderr @@ -1,13 +1,13 @@ error[E0271]: type mismatch resolving `for<'a> <&'a _ as Mirror>::Image == _` --> $DIR/higher-ranked-projection.rs:25:5 | -LL | / fn foo(_t: T) -LL | | where for<'a> &'a T: Mirror -LL | | {} - | |__- required by `foo` +LL | fn foo(_t: T) + | --- +LL | where for<'a> &'a T: Mirror + | ------- required by this bound in `foo` ... -LL | foo(()); - | ^^^ expected bound lifetime parameter 'a, found concrete lifetime +LL | foo(()); + | ^^^ expected bound lifetime parameter 'a, found concrete lifetime error: aborting due to previous error diff --git a/src/test/ui/async-await/async-fn-nonsend.stderr b/src/test/ui/async-await/async-fn-nonsend.stderr index d2f92f04f40a7..001e0b1cad305 100644 --- a/src/test/ui/async-await/async-fn-nonsend.stderr +++ b/src/test/ui/async-await/async-fn-nonsend.stderr @@ -2,7 +2,7 @@ error[E0277]: `std::rc::Rc<()>` cannot be sent between threads safely --> $DIR/async-fn-nonsend.rs:50:5 | LL | fn assert_send(_: impl Send) {} - | ---------------------------- required by `assert_send` + | ----------- ---- required by this bound in `assert_send` ... LL | assert_send(local_dropped_before_await()); | ^^^^^^^^^^^ `std::rc::Rc<()>` cannot be sent between threads safely @@ -19,7 +19,7 @@ error[E0277]: `std::rc::Rc<()>` cannot be sent between threads safely --> $DIR/async-fn-nonsend.rs:52:5 | LL | fn assert_send(_: impl Send) {} - | ---------------------------- required by `assert_send` + | ----------- ---- required by this bound in `assert_send` ... LL | assert_send(non_send_temporary_in_match()); | ^^^^^^^^^^^ `std::rc::Rc<()>` cannot be sent between threads safely @@ -36,7 +36,7 @@ error[E0277]: `dyn std::fmt::Write` cannot be sent between threads safely --> $DIR/async-fn-nonsend.rs:54:5 | LL | fn assert_send(_: impl Send) {} - | ---------------------------- required by `assert_send` + | ----------- ---- required by this bound in `assert_send` ... LL | assert_send(non_sync_with_method_call()); | ^^^^^^^^^^^ `dyn std::fmt::Write` cannot be sent between threads safely @@ -55,7 +55,7 @@ error[E0277]: `*mut (dyn std::ops::Fn() + 'static)` cannot be shared between thr --> $DIR/async-fn-nonsend.rs:54:5 | LL | fn assert_send(_: impl Send) {} - | ---------------------------- required by `assert_send` + | ----------- ---- required by this bound in `assert_send` ... LL | assert_send(non_sync_with_method_call()); | ^^^^^^^^^^^ `*mut (dyn std::ops::Fn() + 'static)` cannot be shared between threads safely diff --git a/src/test/ui/async-await/issues/issue-62009-1.stderr b/src/test/ui/async-await/issues/issue-62009-1.stderr index cd155f0fc32b6..3d8028635f5a5 100644 --- a/src/test/ui/async-await/issues/issue-62009-1.stderr +++ b/src/test/ui/async-await/issues/issue-62009-1.stderr @@ -32,8 +32,11 @@ error[E0277]: the trait bound `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]: std: | LL | (|_| 2333).await; | ^^^^^^^^^^^^^^^^ the trait `std::future::Future` is not implemented for `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]` + | + ::: $SRC_DIR/libstd/future.rs:LL:COL | - = note: required by `std::future::poll_with_tls_context` +LL | F: Future + | ------ required by this bound in `std::future::poll_with_tls_context` error: aborting due to 4 previous errors diff --git a/src/test/ui/chalkify/type_inference.stderr b/src/test/ui/chalkify/type_inference.stderr index 15c52f461c183..c6bc306e45a1c 100644 --- a/src/test/ui/chalkify/type_inference.stderr +++ b/src/test/ui/chalkify/type_inference.stderr @@ -11,7 +11,7 @@ error[E0277]: the trait bound `{float}: Bar` is not satisfied --> $DIR/type_inference.rs:25:5 | LL | fn only_bar(_x: T) { } - | -------------------------- required by `only_bar` + | -------- --- required by this bound in `only_bar` ... LL | only_bar(x); | ^^^^^^^^ the trait `Bar` is not implemented for `{float}` diff --git a/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr b/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr index c618c2c550ba1..6fadea31f7e69 100644 --- a/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr +++ b/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr @@ -39,44 +39,41 @@ LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); error[E0631]: type mismatch in closure arguments --> $DIR/expect-fn-supply-fn.rs:30:5 | -LL | / fn with_closure_expecting_fn_with_free_region(_: F) -LL | | where F: for<'a> FnOnce(fn(&'a u32), &i32) -LL | | { -LL | | } - | |_- required by `with_closure_expecting_fn_with_free_region` +LL | fn with_closure_expecting_fn_with_free_region(_: F) + | ------------------------------------------ +LL | where F: for<'a> FnOnce(fn(&'a u32), &i32) + | ------------------- required by this bound in `with_closure_expecting_fn_with_free_region` ... -LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {}); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------- found signature of `fn(for<'r> fn(&'r u32), _) -> _` - | | - | expected signature of `fn(fn(&'a u32), &i32) -> _` +LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------- found signature of `fn(for<'r> fn(&'r u32), _) -> _` + | | + | expected signature of `fn(fn(&'a u32), &i32) -> _` error[E0631]: type mismatch in closure arguments --> $DIR/expect-fn-supply-fn.rs:37:5 | -LL | / fn with_closure_expecting_fn_with_bound_region(_: F) -LL | | where F: FnOnce(fn(&u32), &i32) -LL | | { -LL | | } - | |_- required by `with_closure_expecting_fn_with_bound_region` +LL | fn with_closure_expecting_fn_with_bound_region(_: F) + | ------------------------------------------- +LL | where F: FnOnce(fn(&u32), &i32) + | ---------------- required by this bound in `with_closure_expecting_fn_with_bound_region` ... -LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {}); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------------------- found signature of `fn(fn(&'x u32), _) -> _` - | | - | expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _` +LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------------------- found signature of `fn(fn(&'x u32), _) -> _` + | | + | expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _` error[E0631]: type mismatch in closure arguments --> $DIR/expect-fn-supply-fn.rs:46:5 | -LL | / fn with_closure_expecting_fn_with_bound_region(_: F) -LL | | where F: FnOnce(fn(&u32), &i32) -LL | | { -LL | | } - | |_- required by `with_closure_expecting_fn_with_bound_region` +LL | fn with_closure_expecting_fn_with_bound_region(_: F) + | ------------------------------------------- +LL | where F: FnOnce(fn(&u32), &i32) + | ---------------- required by this bound in `with_closure_expecting_fn_with_bound_region` ... -LL | with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --------------- found signature of `for<'r> fn(fn(&'r u32), _) -> _` - | | - | expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _` +LL | with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --------------- found signature of `for<'r> fn(fn(&'r u32), _) -> _` + | | + | expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _` error: aborting due to 5 previous errors diff --git a/src/test/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr b/src/test/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr index a2b3a66dc4d23..9fbe95a9c3945 100644 --- a/src/test/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr +++ b/src/test/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr @@ -1,16 +1,15 @@ error[E0631]: type mismatch in closure arguments --> $DIR/expect-infer-var-appearing-twice.rs:14:5 | -LL | / fn with_closure(_: F) -LL | | where F: FnOnce(A, A) -LL | | { -LL | | } - | |_- required by `with_closure` +LL | fn with_closure(_: F) + | ------------ +LL | where F: FnOnce(A, A) + | ------------ required by this bound in `with_closure` ... -LL | with_closure(|x: u32, y: i32| { - | ^^^^^^^^^^^^ ---------------- found signature of `fn(u32, i32) -> _` - | | - | expected signature of `fn(_, _) -> _` +LL | with_closure(|x: u32, y: i32| { + | ^^^^^^^^^^^^ ---------------- found signature of `fn(u32, i32) -> _` + | | + | expected signature of `fn(_, _) -> _` error: aborting due to previous error diff --git a/src/test/ui/closures/closure-bounds-subtype.stderr b/src/test/ui/closures/closure-bounds-subtype.stderr index e9b34e05ac2e2..4b703eded69c3 100644 --- a/src/test/ui/closures/closure-bounds-subtype.stderr +++ b/src/test/ui/closures/closure-bounds-subtype.stderr @@ -2,7 +2,7 @@ error[E0277]: `F` cannot be shared between threads safely --> $DIR/closure-bounds-subtype.rs:13:22 | LL | fn take_const_owned(_: F) where F: FnOnce() + Sync + Send { - | ------------------------------------------------------------ required by `take_const_owned` + | ---------------- ---- required by this bound in `take_const_owned` ... LL | take_const_owned(f); | ^ `F` cannot be shared between threads safely diff --git a/src/test/ui/closures/closure-move-sync.stderr b/src/test/ui/closures/closure-move-sync.stderr index 8afebc7c74816..aaa5f76233f91 100644 --- a/src/test/ui/closures/closure-move-sync.stderr +++ b/src/test/ui/closures/closure-move-sync.stderr @@ -3,22 +3,30 @@ error[E0277]: `std::sync::mpsc::Receiver<()>` cannot be shared between threads s | LL | let t = thread::spawn(|| { | ^^^^^^^^^^^^^ `std::sync::mpsc::Receiver<()>` cannot be shared between threads safely + | + ::: $SRC_DIR/libstd/thread/mod.rs:LL:COL + | +LL | F: FnOnce() -> T, F: Send + 'static, T: Send + 'static + | ---- required by this bound in `std::thread::spawn` | = help: the trait `std::marker::Sync` is not implemented for `std::sync::mpsc::Receiver<()>` = note: required because of the requirements on the impl of `std::marker::Send` for `&std::sync::mpsc::Receiver<()>` = note: required because it appears within the type `[closure@$DIR/closure-move-sync.rs:6:27: 9:6 recv:&std::sync::mpsc::Receiver<()>]` - = note: required by `std::thread::spawn` error[E0277]: `std::sync::mpsc::Sender<()>` cannot be shared between threads safely --> $DIR/closure-move-sync.rs:18:5 | LL | thread::spawn(|| tx.send(()).unwrap()); | ^^^^^^^^^^^^^ `std::sync::mpsc::Sender<()>` cannot be shared between threads safely + | + ::: $SRC_DIR/libstd/thread/mod.rs:LL:COL + | +LL | F: FnOnce() -> T, F: Send + 'static, T: Send + 'static + | ---- required by this bound in `std::thread::spawn` | = help: the trait `std::marker::Sync` is not implemented for `std::sync::mpsc::Sender<()>` = note: required because of the requirements on the impl of `std::marker::Send` for `&std::sync::mpsc::Sender<()>` = note: required because it appears within the type `[closure@$DIR/closure-move-sync.rs:18:19: 18:42 tx:&std::sync::mpsc::Sender<()>]` - = note: required by `std::thread::spawn` error: aborting due to 2 previous errors diff --git a/src/test/ui/defaulted-never-note.rs b/src/test/ui/defaulted-never-note.rs index cf1922ecc789f..d3fb8a09414ce 100644 --- a/src/test/ui/defaulted-never-note.rs +++ b/src/test/ui/defaulted-never-note.rs @@ -19,7 +19,8 @@ trait ImplementedForUnitButNotNever {} impl ImplementedForUnitButNotNever for () {} fn foo(_t: T) {} -//~^ NOTE required by `foo` +//~^ NOTE required by this bound in `foo` +//~| NOTE fn smeg() { let _x = return; diff --git a/src/test/ui/defaulted-never-note.stderr b/src/test/ui/defaulted-never-note.stderr index 277477a0b0acd..28c9da059edaa 100644 --- a/src/test/ui/defaulted-never-note.stderr +++ b/src/test/ui/defaulted-never-note.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `!: ImplementedForUnitButNotNever` is not satisfied - --> $DIR/defaulted-never-note.rs:26:5 + --> $DIR/defaulted-never-note.rs:27:5 | LL | fn foo(_t: T) {} - | ----------------------------------------------- required by `foo` + | --- ----------------------------- required by this bound in `foo` ... LL | foo(_x); | ^^^ the trait `ImplementedForUnitButNotNever` is not implemented for `!` diff --git a/src/test/ui/derives/derives-span-Hash-enum-struct-variant.stderr b/src/test/ui/derives/derives-span-Hash-enum-struct-variant.stderr index 417c720c63e99..4752ef3713d42 100644 --- a/src/test/ui/derives/derives-span-Hash-enum-struct-variant.stderr +++ b/src/test/ui/derives/derives-span-Hash-enum-struct-variant.stderr @@ -3,8 +3,11 @@ error[E0277]: the trait bound `Error: std::hash::Hash` is not satisfied | LL | x: Error | ^^^^^^^^ the trait `std::hash::Hash` is not implemented for `Error` + | + ::: $SRC_DIR/libcore/hash/mod.rs:LL:COL | - = note: required by `std::hash::Hash::hash` +LL | fn hash(&self, state: &mut H); + | - required by this bound in `std::hash::Hash::hash` error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Hash-enum.stderr b/src/test/ui/derives/derives-span-Hash-enum.stderr index 25be8794889fc..efaa679c410be 100644 --- a/src/test/ui/derives/derives-span-Hash-enum.stderr +++ b/src/test/ui/derives/derives-span-Hash-enum.stderr @@ -3,8 +3,11 @@ error[E0277]: the trait bound `Error: std::hash::Hash` is not satisfied | LL | Error | ^^^^^ the trait `std::hash::Hash` is not implemented for `Error` + | + ::: $SRC_DIR/libcore/hash/mod.rs:LL:COL | - = note: required by `std::hash::Hash::hash` +LL | fn hash(&self, state: &mut H); + | - required by this bound in `std::hash::Hash::hash` error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Hash-struct.stderr b/src/test/ui/derives/derives-span-Hash-struct.stderr index c0574453a7a6b..a92103032ee1f 100644 --- a/src/test/ui/derives/derives-span-Hash-struct.stderr +++ b/src/test/ui/derives/derives-span-Hash-struct.stderr @@ -3,8 +3,11 @@ error[E0277]: the trait bound `Error: std::hash::Hash` is not satisfied | LL | x: Error | ^^^^^^^^ the trait `std::hash::Hash` is not implemented for `Error` + | + ::: $SRC_DIR/libcore/hash/mod.rs:LL:COL | - = note: required by `std::hash::Hash::hash` +LL | fn hash(&self, state: &mut H); + | - required by this bound in `std::hash::Hash::hash` error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Hash-tuple-struct.stderr b/src/test/ui/derives/derives-span-Hash-tuple-struct.stderr index 6339c38578eb8..4af96ada66c28 100644 --- a/src/test/ui/derives/derives-span-Hash-tuple-struct.stderr +++ b/src/test/ui/derives/derives-span-Hash-tuple-struct.stderr @@ -3,8 +3,11 @@ error[E0277]: the trait bound `Error: std::hash::Hash` is not satisfied | LL | Error | ^^^^^ the trait `std::hash::Hash` is not implemented for `Error` + | + ::: $SRC_DIR/libcore/hash/mod.rs:LL:COL | - = note: required by `std::hash::Hash::hash` +LL | fn hash(&self, state: &mut H); + | - required by this bound in `std::hash::Hash::hash` error: aborting due to previous error diff --git a/src/test/ui/derives/deriving-copyclone.stderr b/src/test/ui/derives/deriving-copyclone.stderr index f142257604cc8..4cca14ae089e9 100644 --- a/src/test/ui/derives/deriving-copyclone.stderr +++ b/src/test/ui/derives/deriving-copyclone.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `C: std::marker::Copy` is not satisfied --> $DIR/deriving-copyclone.rs:31:13 | LL | fn is_copy(_: T) {} - | ------------------------- required by `is_copy` + | ------- ---- required by this bound in `is_copy` ... LL | is_copy(B { a: 1, b: C }); | ^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `C` @@ -13,7 +13,7 @@ error[E0277]: the trait bound `C: std::clone::Clone` is not satisfied --> $DIR/deriving-copyclone.rs:32:14 | LL | fn is_clone(_: T) {} - | --------------------------- required by `is_clone` + | -------- ----- required by this bound in `is_clone` ... LL | is_clone(B { a: 1, b: C }); | ^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `C` @@ -24,7 +24,7 @@ error[E0277]: the trait bound `D: std::marker::Copy` is not satisfied --> $DIR/deriving-copyclone.rs:35:13 | LL | fn is_copy(_: T) {} - | ------------------------- required by `is_copy` + | ------- ---- required by this bound in `is_copy` ... LL | is_copy(B { a: 1, b: D }); | ^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `D` diff --git a/src/test/ui/did_you_mean/recursion_limit.stderr b/src/test/ui/did_you_mean/recursion_limit.stderr index 745d90a5d4cbf..b05b92bf1e94b 100644 --- a/src/test/ui/did_you_mean/recursion_limit.stderr +++ b/src/test/ui/did_you_mean/recursion_limit.stderr @@ -2,7 +2,7 @@ error[E0275]: overflow evaluating the requirement `J: std::marker::Send` --> $DIR/recursion_limit.rs:34:5 | LL | fn is_send() { } - | -------------------- required by `is_send` + | ------- ---- required by this bound in `is_send` ... LL | is_send::(); | ^^^^^^^^^^^^ diff --git a/src/test/ui/error-codes/E0271.stderr b/src/test/ui/error-codes/E0271.stderr index 0afcbcc79eee9..c56853f45a0b0 100644 --- a/src/test/ui/error-codes/E0271.stderr +++ b/src/test/ui/error-codes/E0271.stderr @@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `::AssociatedType == u32` --> $DIR/E0271.rs:10:5 | LL | fn foo(t: T) where T: Trait { - | -------------------------------------------------- required by `foo` + | --- ------------------ required by this bound in `foo` ... LL | foo(3_i8); | ^^^ expected reference, found u32 diff --git a/src/test/ui/error-codes/E0277-2.stderr b/src/test/ui/error-codes/E0277-2.stderr index b42849cd84201..407e51e4f5f9c 100644 --- a/src/test/ui/error-codes/E0277-2.stderr +++ b/src/test/ui/error-codes/E0277-2.stderr @@ -2,7 +2,7 @@ error[E0277]: `*const u8` cannot be sent between threads safely --> $DIR/E0277-2.rs:16:5 | LL | fn is_send() { } - | --------------------- required by `is_send` + | ------- ---- required by this bound in `is_send` ... LL | is_send::(); | ^^^^^^^^^^^^^^ `*const u8` cannot be sent between threads safely diff --git a/src/test/ui/error-codes/E0277.stderr b/src/test/ui/error-codes/E0277.stderr index 9cd0dc7a68e7c..a069d048c8862 100644 --- a/src/test/ui/error-codes/E0277.stderr +++ b/src/test/ui/error-codes/E0277.stderr @@ -14,7 +14,7 @@ error[E0277]: the trait bound `i32: Foo` is not satisfied --> $DIR/E0277.rs:17:15 | LL | fn some_func(foo: T) { - | ---------------------------- required by `some_func` + | --------- --- required by this bound in `some_func` ... LL | some_func(5i32); | ^^^^ the trait `Foo` is not implemented for `i32` diff --git a/src/test/ui/error-should-say-copy-not-pod.stderr b/src/test/ui/error-should-say-copy-not-pod.stderr index df79aeea054ca..d0148f418e33b 100644 --- a/src/test/ui/error-should-say-copy-not-pod.stderr +++ b/src/test/ui/error-should-say-copy-not-pod.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not sa --> $DIR/error-should-say-copy-not-pod.rs:6:17 | LL | fn check_bound(_: T) {} - | ---------------------------- required by `check_bound` + | ----------- ---- required by this bound in `check_bound` ... LL | check_bound("nocopy".to_string()); | ^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` diff --git a/src/test/ui/extern/extern-types-not-sync-send.stderr b/src/test/ui/extern/extern-types-not-sync-send.stderr index 0f32d4489dece..803bd9dbac62c 100644 --- a/src/test/ui/extern/extern-types-not-sync-send.stderr +++ b/src/test/ui/extern/extern-types-not-sync-send.stderr @@ -2,7 +2,7 @@ error[E0277]: `A` cannot be shared between threads safely --> $DIR/extern-types-not-sync-send.rs:13:5 | LL | fn assert_sync() { } - | ---------------------------------- required by `assert_sync` + | ----------- ---- required by this bound in `assert_sync` ... LL | assert_sync::(); | ^^^^^^^^^^^^^^^^ `A` cannot be shared between threads safely @@ -13,7 +13,7 @@ error[E0277]: `A` cannot be sent between threads safely --> $DIR/extern-types-not-sync-send.rs:16:5 | LL | fn assert_send() { } - | ---------------------------------- required by `assert_send` + | ----------- ---- required by this bound in `assert_send` ... LL | assert_send::(); | ^^^^^^^^^^^^^^^^ `A` cannot be sent between threads safely diff --git a/src/test/ui/extern/extern-types-unsized.stderr b/src/test/ui/extern/extern-types-unsized.stderr index 06527d973e2ab..1f69a4e154eb3 100644 --- a/src/test/ui/extern/extern-types-unsized.stderr +++ b/src/test/ui/extern/extern-types-unsized.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim --> $DIR/extern-types-unsized.rs:22:5 | LL | fn assert_sized() { } - | -------------------- required by `assert_sized` + | ------------ - required by this bound in `assert_sized` ... LL | assert_sized::(); | ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -14,7 +14,7 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim --> $DIR/extern-types-unsized.rs:25:5 | LL | fn assert_sized() { } - | -------------------- required by `assert_sized` + | ------------ - required by this bound in `assert_sized` ... LL | assert_sized::(); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -27,7 +27,7 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim --> $DIR/extern-types-unsized.rs:28:5 | LL | fn assert_sized() { } - | -------------------- required by `assert_sized` + | ------------ - required by this bound in `assert_sized` ... LL | assert_sized::>(); | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -40,7 +40,7 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim --> $DIR/extern-types-unsized.rs:31:5 | LL | fn assert_sized() { } - | -------------------- required by `assert_sized` + | ------------ - required by this bound in `assert_sized` ... LL | assert_sized::>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time diff --git a/src/test/ui/extern/extern-wrong-value-type.stderr b/src/test/ui/extern/extern-wrong-value-type.stderr index f2468895d21d1..9a6af8119a8c5 100644 --- a/src/test/ui/extern/extern-wrong-value-type.stderr +++ b/src/test/ui/extern/extern-wrong-value-type.stderr @@ -2,7 +2,7 @@ error[E0277]: expected a `std::ops::Fn<()>` closure, found `extern "C" fn() {f}` --> $DIR/extern-wrong-value-type.rs:9:11 | LL | fn is_fn(_: F) where F: Fn() {} - | ------------------------------- required by `is_fn` + | ----- ---- required by this bound in `is_fn` ... LL | is_fn(f); | ^ expected an `Fn<()>` closure, found `extern "C" fn() {f}` diff --git a/src/test/ui/fmt/send-sync.stderr b/src/test/ui/fmt/send-sync.stderr index 599dcfaa72617..be6e41afaf811 100644 --- a/src/test/ui/fmt/send-sync.stderr +++ b/src/test/ui/fmt/send-sync.stderr @@ -2,7 +2,7 @@ error[E0277]: `*mut (dyn std::ops::Fn() + 'static)` cannot be shared between thr --> $DIR/send-sync.rs:8:5 | LL | fn send(_: T) {} - | ---------------------- required by `send` + | ---- ---- required by this bound in `send` ... LL | send(format_args!("{:?}", c)); | ^^^^ `*mut (dyn std::ops::Fn() + 'static)` cannot be shared between threads safely @@ -20,7 +20,7 @@ error[E0277]: `*mut (dyn std::ops::Fn() + 'static)` cannot be shared between thr --> $DIR/send-sync.rs:9:5 | LL | fn sync(_: T) {} - | ---------------------- required by `sync` + | ---- ---- required by this bound in `sync` ... LL | sync(format_args!("{:?}", c)); | ^^^^ `*mut (dyn std::ops::Fn() + 'static)` cannot be shared between threads safely diff --git a/src/test/ui/fn/fn-trait-formatting.stderr b/src/test/ui/fn/fn-trait-formatting.stderr index 4d610b49dff8e..f891b9c6439be 100644 --- a/src/test/ui/fn/fn-trait-formatting.stderr +++ b/src/test/ui/fn/fn-trait-formatting.stderr @@ -29,7 +29,7 @@ error[E0277]: expected a `std::ops::Fn<(isize,)>` closure, found `{integer}` --> $DIR/fn-trait-formatting.rs:19:14 | LL | fn needs_fn(x: F) where F: Fn(isize) -> isize {} - | ------------------------------------------------ required by `needs_fn` + | -------- ------------------ required by this bound in `needs_fn` ... LL | needs_fn(1); | ^ expected an `Fn<(isize,)>` closure, found `{integer}` diff --git a/src/test/ui/generator-yielding-or-returning-itself.stderr b/src/test/ui/generator-yielding-or-returning-itself.stderr index 1049bb6240a24..c9a71e03858f1 100644 --- a/src/test/ui/generator-yielding-or-returning-itself.stderr +++ b/src/test/ui/generator-yielding-or-returning-itself.stderr @@ -16,14 +16,13 @@ LL | | }) error[E0271]: type mismatch resolving `<[generator@$DIR/generator-yielding-or-returning-itself.rs:28:33: 32:6 _] as std::ops::Generator>::Yield == [generator@$DIR/generator-yielding-or-returning-itself.rs:28:33: 32:6 _]` --> $DIR/generator-yielding-or-returning-itself.rs:28:5 | -LL | / pub fn want_cyclic_generator_yield(_: T) -LL | | where T: Generator -LL | | { -LL | | } - | |_- required by `want_cyclic_generator_yield` +LL | pub fn want_cyclic_generator_yield(_: T) + | --------------------------- +LL | where T: Generator + | --------- required by this bound in `want_cyclic_generator_yield` ... -LL | want_cyclic_generator_yield(|| { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ cyclic type of infinite size +LL | want_cyclic_generator_yield(|| { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ cyclic type of infinite size | = note: closures cannot capture themselves or take themselves as argument; this error may be the result of a recent compiler bug-fix, diff --git a/src/test/ui/generator/not-send-sync.stderr b/src/test/ui/generator/not-send-sync.stderr index 51416ce0d2f7a..620db245d3e57 100644 --- a/src/test/ui/generator/not-send-sync.stderr +++ b/src/test/ui/generator/not-send-sync.stderr @@ -2,7 +2,7 @@ error[E0277]: `std::cell::Cell` cannot be shared between threads safely --> $DIR/not-send-sync.rs:16:5 | LL | fn assert_send(_: T) {} - | ----------------------------- required by `main::assert_send` + | ----------- ---- required by this bound in `main::assert_send` ... LL | assert_send(|| { | ^^^^^^^^^^^ `std::cell::Cell` cannot be shared between threads safely @@ -15,7 +15,7 @@ error[E0277]: `std::cell::Cell` cannot be shared between threads safely --> $DIR/not-send-sync.rs:9:5 | LL | fn assert_sync(_: T) {} - | ----------------------------- required by `main::assert_sync` + | ----------- ---- required by this bound in `main::assert_sync` ... LL | assert_sync(|| { | ^^^^^^^^^^^ `std::cell::Cell` cannot be shared between threads safely diff --git a/src/test/ui/generator/static-not-unpin.stderr b/src/test/ui/generator/static-not-unpin.stderr index b7871ee3478a4..f2b1078e2b532 100644 --- a/src/test/ui/generator/static-not-unpin.stderr +++ b/src/test/ui/generator/static-not-unpin.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `[static generator@$DIR/static-not-unpin.rs:11:25: --> $DIR/static-not-unpin.rs:14:18 | LL | fn assert_unpin(_: T) { - | ------------------------------- required by `assert_unpin` + | ------------ ----- required by this bound in `assert_unpin` ... LL | assert_unpin(generator); | ^^^^^^^^^ the trait `std::marker::Unpin` is not implemented for `[static generator@$DIR/static-not-unpin.rs:11:25: 13:6 _]` diff --git a/src/test/ui/hrtb/hrtb-conflate-regions.stderr b/src/test/ui/hrtb/hrtb-conflate-regions.stderr index e0b968b67645e..205fa2b5bc81f 100644 --- a/src/test/ui/hrtb/hrtb-conflate-regions.stderr +++ b/src/test/ui/hrtb/hrtb-conflate-regions.stderr @@ -1,14 +1,13 @@ error[E0277]: the trait bound `for<'a, 'b> SomeStruct: Foo<(&'a isize, &'b isize)>` is not satisfied --> $DIR/hrtb-conflate-regions.rs:27:10 | -LL | / fn want_foo2() -LL | | where T : for<'a,'b> Foo<(&'a isize, &'b isize)> -LL | | { -LL | | } - | |_- required by `want_foo2` +LL | fn want_foo2() + | --------- +LL | where T : for<'a,'b> Foo<(&'a isize, &'b isize)> + | -------------------------------------- required by this bound in `want_foo2` ... -LL | fn b() { want_foo2::(); } - | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a, 'b> Foo<(&'a isize, &'b isize)>` is not implemented for `SomeStruct` +LL | fn b() { want_foo2::(); } + | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a, 'b> Foo<(&'a isize, &'b isize)>` is not implemented for `SomeStruct` | = help: the following implementations were found: > diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr index bc58b8e16aaf2..ceba22234be6a 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr @@ -1,15 +1,14 @@ error[E0277]: the trait bound `(): Trait fn(&'b u32)>` is not satisfied --> $DIR/hrtb-exists-forall-trait-contravariant.rs:34:5 | -LL | / fn foo() -LL | | where -LL | | T: Trait fn(&'b u32)>, -LL | | { -LL | | } - | |_- required by `foo` +LL | fn foo() + | --- +LL | where +LL | T: Trait fn(&'b u32)>, + | -------------------------- required by this bound in `foo` ... -LL | foo::<()>(); - | ^^^^^^^^^ the trait `Trait fn(&'b u32)>` is not implemented for `()` +LL | foo::<()>(); + | ^^^^^^^^^ the trait `Trait fn(&'b u32)>` is not implemented for `()` | = help: the following implementations were found: <() as Trait> diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.stderr b/src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.stderr index 441f75135f3a4..a1cb3b230fea2 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.stderr +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.stderr @@ -1,15 +1,14 @@ error[E0277]: the trait bound `(): Trait fn(fn(&'b u32))>` is not satisfied --> $DIR/hrtb-exists-forall-trait-covariant.rs:36:5 | -LL | / fn foo() -LL | | where -LL | | T: Trait fn(fn(&'b u32))>, -LL | | { -LL | | } - | |_- required by `foo` +LL | fn foo() + | --- +LL | where +LL | T: Trait fn(fn(&'b u32))>, + | ------------------------------ required by this bound in `foo` ... -LL | foo::<()>(); - | ^^^^^^^^^ the trait `Trait fn(fn(&'b u32))>` is not implemented for `()` +LL | foo::<()>(); + | ^^^^^^^^^ the trait `Trait fn(fn(&'b u32))>` is not implemented for `()` | = help: the following implementations were found: <() as Trait> diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr b/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr index a11949735b9d2..093bee375bb0b 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr @@ -1,15 +1,14 @@ error[E0277]: the trait bound `(): Trait fn(std::cell::Cell<&'b u32>)>` is not satisfied --> $DIR/hrtb-exists-forall-trait-invariant.rs:28:5 | -LL | / fn foo() -LL | | where -LL | | T: Trait fn(Cell<&'b u32>)>, -LL | | { -LL | | } - | |_- required by `foo` +LL | fn foo() + | --- +LL | where +LL | T: Trait fn(Cell<&'b u32>)>, + | -------------------------------- required by this bound in `foo` ... -LL | foo::<()>(); - | ^^^^^^^^^ the trait `Trait fn(std::cell::Cell<&'b u32>)>` is not implemented for `()` +LL | foo::<()>(); + | ^^^^^^^^^ the trait `Trait fn(std::cell::Cell<&'b u32>)>` is not implemented for `()` | = help: the following implementations were found: <() as Trait)>> diff --git a/src/test/ui/hrtb/hrtb-higher-ranker-supertraits-transitive.stderr b/src/test/ui/hrtb/hrtb-higher-ranker-supertraits-transitive.stderr index 18f49089302e5..c2cc8ebad2726 100644 --- a/src/test/ui/hrtb/hrtb-higher-ranker-supertraits-transitive.stderr +++ b/src/test/ui/hrtb/hrtb-higher-ranker-supertraits-transitive.stderr @@ -1,14 +1,13 @@ error[E0277]: the trait bound `for<'ccx> B: Bar<'ccx>` is not satisfied --> $DIR/hrtb-higher-ranker-supertraits-transitive.rs:47:26 | -LL | / fn want_bar_for_any_ccx(b: &B) -LL | | where B : for<'ccx> Bar<'ccx> -LL | | { -LL | | } - | |_- required by `want_bar_for_any_ccx` +LL | fn want_bar_for_any_ccx(b: &B) + | -------------------- +LL | where B : for<'ccx> Bar<'ccx> + | ------------------- required by this bound in `want_bar_for_any_ccx` ... -LL | want_bar_for_any_ccx(b); - | ^ the trait `for<'ccx> Bar<'ccx>` is not implemented for `B` +LL | want_bar_for_any_ccx(b); + | ^ the trait `for<'ccx> Bar<'ccx>` is not implemented for `B` | = help: consider adding a `where for<'ccx> B: Bar<'ccx>` bound diff --git a/src/test/ui/hrtb/hrtb-higher-ranker-supertraits.stderr b/src/test/ui/hrtb/hrtb-higher-ranker-supertraits.stderr index 7857ab6e86a20..a93814ad4c25e 100644 --- a/src/test/ui/hrtb/hrtb-higher-ranker-supertraits.stderr +++ b/src/test/ui/hrtb/hrtb-higher-ranker-supertraits.stderr @@ -1,33 +1,26 @@ error[E0277]: the trait bound `for<'tcx> F: Foo<'tcx>` is not satisfied --> $DIR/hrtb-higher-ranker-supertraits.rs:18:26 | -LL | want_foo_for_any_tcx(f); - | ^ the trait `for<'tcx> Foo<'tcx>` is not implemented for `F` +LL | want_foo_for_any_tcx(f); + | ^ the trait `for<'tcx> Foo<'tcx>` is not implemented for `F` ... -LL | / fn want_foo_for_any_tcx(f: &F) -LL | | where F : for<'tcx> Foo<'tcx> -LL | | { -LL | | want_foo_for_some_tcx(f); -LL | | want_foo_for_any_tcx(f); -LL | | } - | |_- required by `want_foo_for_any_tcx` +LL | fn want_foo_for_any_tcx(f: &F) + | -------------------- +LL | where F : for<'tcx> Foo<'tcx> + | ------------------- required by this bound in `want_foo_for_any_tcx` | = help: consider adding a `where for<'tcx> F: Foo<'tcx>` bound error[E0277]: the trait bound `for<'ccx> B: Bar<'ccx>` is not satisfied --> $DIR/hrtb-higher-ranker-supertraits.rs:35:26 | -LL | want_bar_for_any_ccx(b); - | ^ the trait `for<'ccx> Bar<'ccx>` is not implemented for `B` +LL | want_bar_for_any_ccx(b); + | ^ the trait `for<'ccx> Bar<'ccx>` is not implemented for `B` ... -LL | / fn want_bar_for_any_ccx(b: &B) -LL | | where B : for<'ccx> Bar<'ccx> -LL | | { -LL | | want_foo_for_some_tcx(b); -... | -LL | | want_bar_for_any_ccx(b); -LL | | } - | |_- required by `want_bar_for_any_ccx` +LL | fn want_bar_for_any_ccx(b: &B) + | -------------------- +LL | where B : for<'ccx> Bar<'ccx> + | ------------------- required by this bound in `want_bar_for_any_ccx` | = help: consider adding a `where for<'ccx> B: Bar<'ccx>` bound diff --git a/src/test/ui/hrtb/hrtb-just-for-static.stderr b/src/test/ui/hrtb/hrtb-just-for-static.stderr index b2938e541fdd8..f4cf3555868f2 100644 --- a/src/test/ui/hrtb/hrtb-just-for-static.stderr +++ b/src/test/ui/hrtb/hrtb-just-for-static.stderr @@ -1,14 +1,13 @@ error[E0277]: the trait bound `for<'a> StaticInt: Foo<&'a isize>` is not satisfied --> $DIR/hrtb-just-for-static.rs:24:5 | -LL | / fn want_hrtb() -LL | | where T : for<'a> Foo<&'a isize> -LL | | { -LL | | } - | |_- required by `want_hrtb` +LL | fn want_hrtb() + | --------- +LL | where T : for<'a> Foo<&'a isize> + | ---------------------- required by this bound in `want_hrtb` ... -LL | want_hrtb::() - | ^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Foo<&'a isize>` is not implemented for `StaticInt` +LL | want_hrtb::() + | ^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Foo<&'a isize>` is not implemented for `StaticInt` | = help: the following implementations were found: > @@ -16,14 +15,13 @@ LL | want_hrtb::() error[E0277]: the trait bound `for<'a> &'a u32: Foo<&'a isize>` is not satisfied --> $DIR/hrtb-just-for-static.rs:30:5 | -LL | / fn want_hrtb() -LL | | where T : for<'a> Foo<&'a isize> -LL | | { -LL | | } - | |_- required by `want_hrtb` +LL | fn want_hrtb() + | --------- +LL | where T : for<'a> Foo<&'a isize> + | ---------------------- required by this bound in `want_hrtb` ... -LL | want_hrtb::<&'a u32>() - | ^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Foo<&'a isize>` is not implemented for `&'a u32` +LL | want_hrtb::<&'a u32>() + | ^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Foo<&'a isize>` is not implemented for `&'a u32` | = help: the following implementations were found: <&'a u32 as Foo<&'a isize>> diff --git a/src/test/ui/hrtb/issue-46989.stderr b/src/test/ui/hrtb/issue-46989.stderr index 57eaf2aad2bc5..4da3e3ddb7ebd 100644 --- a/src/test/ui/hrtb/issue-46989.stderr +++ b/src/test/ui/hrtb/issue-46989.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `for<'r> fn(&'r i32): Foo` is not satisfied --> $DIR/issue-46989.rs:40:5 | LL | fn assert_foo() {} - | ----------------------- required by `assert_foo` + | ---------- --- required by this bound in `assert_foo` ... LL | assert_foo::(); | ^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `for<'r> fn(&'r i32)` diff --git a/src/test/ui/impl-trait/auto-trait-leak.stderr b/src/test/ui/impl-trait/auto-trait-leak.stderr index af641a89e7f9c..d11941fee1824 100644 --- a/src/test/ui/impl-trait/auto-trait-leak.stderr +++ b/src/test/ui/impl-trait/auto-trait-leak.stderr @@ -73,7 +73,7 @@ error[E0277]: `std::rc::Rc` cannot be sent between threads --> $DIR/auto-trait-leak.rs:15:5 | LL | fn send(_: T) {} - | ---------------------- required by `send` + | ---- ---- required by this bound in `send` ... LL | send(cycle2().clone()); | ^^^^ `std::rc::Rc` cannot be sent between threads safely diff --git a/src/test/ui/impl-trait/auto-trait-leak2.stderr b/src/test/ui/impl-trait/auto-trait-leak2.stderr index 460af7dedbea8..d163e1dff7ac9 100644 --- a/src/test/ui/impl-trait/auto-trait-leak2.stderr +++ b/src/test/ui/impl-trait/auto-trait-leak2.stderr @@ -2,7 +2,7 @@ error[E0277]: `std::rc::Rc>` cannot be sent between threads --> $DIR/auto-trait-leak2.rs:13:5 | LL | fn send(_: T) {} - | ---------------------- required by `send` + | ---- ---- required by this bound in `send` ... LL | send(before()); | ^^^^ `std::rc::Rc>` cannot be sent between threads safely @@ -15,7 +15,7 @@ error[E0277]: `std::rc::Rc>` cannot be sent between threads --> $DIR/auto-trait-leak2.rs:16:5 | LL | fn send(_: T) {} - | ---------------------- required by `send` + | ---- ---- required by this bound in `send` ... LL | send(after()); | ^^^^ `std::rc::Rc>` cannot be sent between threads safely diff --git a/src/test/ui/interior-mutability/interior-mutability.stderr b/src/test/ui/interior-mutability/interior-mutability.stderr index 31390bc6ccefd..1a726be4aa6f4 100644 --- a/src/test/ui/interior-mutability/interior-mutability.stderr +++ b/src/test/ui/interior-mutability/interior-mutability.stderr @@ -3,12 +3,16 @@ error[E0277]: the type `std::cell::UnsafeCell` may contain interior mutabil | LL | catch_unwind(|| { x.set(23); }); | ^^^^^^^^^^^^ `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + | + ::: $SRC_DIR/libstd/panic.rs:LL:COL + | +LL | pub fn catch_unwind R + UnwindSafe, R>(f: F) -> Result { + | ---------- required by this bound in `std::panic::catch_unwind` | = help: within `std::cell::Cell`, the trait `std::panic::RefUnwindSafe` is not implemented for `std::cell::UnsafeCell` = note: required because it appears within the type `std::cell::Cell` = note: required because of the requirements on the impl of `std::panic::UnwindSafe` for `&std::cell::Cell` = note: required because it appears within the type `[closure@$DIR/interior-mutability.rs:5:18: 5:35 x:&std::cell::Cell]` - = note: required by `std::panic::catch_unwind` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-1920-1.stderr b/src/test/ui/issues/issue-1920-1.stderr index c62cbb0cf8b96..56f70aa296cb9 100644 --- a/src/test/ui/issues/issue-1920-1.stderr +++ b/src/test/ui/issues/issue-1920-1.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `foo::issue_1920::S: std::clone::Clone` is not sat --> $DIR/issue-1920-1.rs:12:5 | LL | fn assert_clone() where T : Clone { } - | ------------------------------------ required by `assert_clone` + | ------------ ----- required by this bound in `assert_clone` ... LL | assert_clone::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `foo::issue_1920::S` diff --git a/src/test/ui/issues/issue-1920-2.stderr b/src/test/ui/issues/issue-1920-2.stderr index aad076244699a..37027b0579265 100644 --- a/src/test/ui/issues/issue-1920-2.stderr +++ b/src/test/ui/issues/issue-1920-2.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `bar::S: std::clone::Clone` is not satisfied --> $DIR/issue-1920-2.rs:10:5 | LL | fn assert_clone() where T : Clone { } - | ------------------------------------ required by `assert_clone` + | ------------ ----- required by this bound in `assert_clone` ... LL | assert_clone::(); | ^^^^^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `bar::S` diff --git a/src/test/ui/issues/issue-1920-3.stderr b/src/test/ui/issues/issue-1920-3.stderr index 4378ea49755a7..dbcb3aee11703 100644 --- a/src/test/ui/issues/issue-1920-3.stderr +++ b/src/test/ui/issues/issue-1920-3.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `issue_1920::S: std::clone::Clone` is not satisfie --> $DIR/issue-1920-3.rs:14:5 | LL | fn assert_clone() where T : Clone { } - | ------------------------------------ required by `assert_clone` + | ------------ ----- required by this bound in `assert_clone` ... LL | assert_clone::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `issue_1920::S` diff --git a/src/test/ui/issues/issue-21160.stderr b/src/test/ui/issues/issue-21160.stderr index e32343e9682db..577baa97d8f9d 100644 --- a/src/test/ui/issues/issue-21160.stderr +++ b/src/test/ui/issues/issue-21160.stderr @@ -3,8 +3,11 @@ error[E0277]: the trait bound `Bar: std::hash::Hash` is not satisfied | LL | struct Foo(Bar); | ^^^ the trait `std::hash::Hash` is not implemented for `Bar` + | + ::: $SRC_DIR/libcore/hash/mod.rs:LL:COL | - = note: required by `std::hash::Hash::hash` +LL | fn hash(&self, state: &mut H); + | - required by this bound in `std::hash::Hash::hash` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-21763.stderr b/src/test/ui/issues/issue-21763.stderr index 99d004a973a26..2bede9120cf1d 100644 --- a/src/test/ui/issues/issue-21763.stderr +++ b/src/test/ui/issues/issue-21763.stderr @@ -2,7 +2,7 @@ error[E0277]: `std::rc::Rc<()>` cannot be sent between threads safely --> $DIR/issue-21763.rs:9:5 | LL | fn foo() {} - | ----------------- required by `foo` + | --- ---- required by this bound in `foo` ... LL | foo::, Rc<()>>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::rc::Rc<()>` cannot be sent between threads safely diff --git a/src/test/ui/issues/issue-25076.stderr b/src/test/ui/issues/issue-25076.stderr index a7b6626b16a1c..0a13a2bc33023 100644 --- a/src/test/ui/issues/issue-25076.stderr +++ b/src/test/ui/issues/issue-25076.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `(): InOut<_>` is not satisfied --> $DIR/issue-25076.rs:10:20 | LL | fn do_fold>(init: B, f: F) {} - | ------------------------------------------------ required by `do_fold` + | ------- --------------- required by this bound in `do_fold` ... LL | do_fold(bot(), ()); | ^^ the trait `InOut<_>` is not implemented for `()` diff --git a/src/test/ui/issues/issue-32963.stderr b/src/test/ui/issues/issue-32963.stderr index 2960f4e598997..e3564e8670174 100644 --- a/src/test/ui/issues/issue-32963.stderr +++ b/src/test/ui/issues/issue-32963.stderr @@ -13,7 +13,7 @@ error[E0277]: the trait bound `dyn Misc: std::marker::Copy` is not satisfied --> $DIR/issue-32963.rs:8:5 | LL | fn size_of_copy() -> usize { mem::size_of::() } - | ------------------------------------------ required by `size_of_copy` + | ------------ ---- required by this bound in `size_of_copy` ... LL | size_of_copy::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `dyn Misc` diff --git a/src/test/ui/issues/issue-40827.stderr b/src/test/ui/issues/issue-40827.stderr index 9131120671f4c..3fe47e249f10c 100644 --- a/src/test/ui/issues/issue-40827.stderr +++ b/src/test/ui/issues/issue-40827.stderr @@ -2,7 +2,7 @@ error[E0277]: `std::rc::Rc` cannot be sent between threads safely --> $DIR/issue-40827.rs:14:5 | LL | fn f(_: T) {} - | ------------------- required by `f` + | - ---- required by this bound in `f` ... LL | f(Foo(Arc::new(Bar::B(None)))); | ^ `std::rc::Rc` cannot be sent between threads safely @@ -16,7 +16,7 @@ error[E0277]: `std::rc::Rc` cannot be shared between threads safely --> $DIR/issue-40827.rs:14:5 | LL | fn f(_: T) {} - | ------------------- required by `f` + | - ---- required by this bound in `f` ... LL | f(Foo(Arc::new(Bar::B(None)))); | ^ `std::rc::Rc` cannot be shared between threads safely diff --git a/src/test/ui/issues/issue-43623.stderr b/src/test/ui/issues/issue-43623.stderr index d843629e8a26f..210d831abf0de 100644 --- a/src/test/ui/issues/issue-43623.stderr +++ b/src/test/ui/issues/issue-43623.stderr @@ -1,31 +1,27 @@ error[E0631]: type mismatch in function arguments --> $DIR/issue-43623.rs:14:5 | -LL | / pub fn break_me(f: F) -LL | | where T: for<'b> Trait<'b>, -LL | | F: for<'b> FnMut(>::Assoc) { -LL | | break_me::; - | | ^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | expected signature of `for<'b> fn(>::Assoc) -> _` - | | found signature of `fn(_) -> _` -LL | | -LL | | -LL | | } - | |_- required by `break_me` +LL | pub fn break_me(f: F) + | -------- +LL | where T: for<'b> Trait<'b>, +LL | F: for<'b> FnMut(>::Assoc) { + | -------------------------------------- required by this bound in `break_me` +LL | break_me::; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected signature of `for<'b> fn(>::Assoc) -> _` + | found signature of `fn(_) -> _` error[E0271]: type mismatch resolving `for<'b> >::Assoc,)>>::Output == ()` --> $DIR/issue-43623.rs:14:5 | -LL | / pub fn break_me(f: F) -LL | | where T: for<'b> Trait<'b>, -LL | | F: for<'b> FnMut(>::Assoc) { -LL | | break_me::; - | | ^^^^^^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'b, found concrete lifetime -LL | | -LL | | -LL | | } - | |_- required by `break_me` +LL | pub fn break_me(f: F) + | -------- +LL | where T: for<'b> Trait<'b>, +LL | F: for<'b> FnMut(>::Assoc) { + | ------------------------- required by this bound in `break_me` +LL | break_me::; + | ^^^^^^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'b, found concrete lifetime error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-47706.stderr b/src/test/ui/issues/issue-47706.stderr index 4f64a643fe57d..6cde93734667f 100644 --- a/src/test/ui/issues/issue-47706.stderr +++ b/src/test/ui/issues/issue-47706.stderr @@ -10,18 +10,17 @@ LL | self.foo.map(Foo::new) error[E0593]: function is expected to take 0 arguments, but it takes 1 argument --> $DIR/issue-47706.rs:27:9 | -LL | Bar(i32), - | -------- takes 1 argument +LL | Bar(i32), + | -------- takes 1 argument ... -LL | / fn foo(f: F) -LL | | where -LL | | F: Fn(), -LL | | { -LL | | } - | |_- required by `foo` +LL | fn foo(f: F) + | --- +LL | where +LL | F: Fn(), + | ---- required by this bound in `foo` ... -LL | foo(Qux::Bar); - | ^^^^^^^^ expected function that takes 0 arguments +LL | foo(Qux::Bar); + | ^^^^^^^^ expected function that takes 0 arguments error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-60283.stderr b/src/test/ui/issues/issue-60283.stderr index 2b01a64d39a9b..dc7952200b18e 100644 --- a/src/test/ui/issues/issue-60283.stderr +++ b/src/test/ui/issues/issue-60283.stderr @@ -1,27 +1,29 @@ error[E0631]: type mismatch in function arguments --> $DIR/issue-60283.rs:14:13 | -LL | / pub fn foo(_: T, _: F) -LL | | where T: for<'a> Trait<'a>, -LL | | F: for<'a> FnMut(>::Item) {} - | |_________________________________________________- required by `foo` +LL | pub fn foo(_: T, _: F) + | --- +LL | where T: for<'a> Trait<'a>, +LL | F: for<'a> FnMut(>::Item) {} + | ------------------------------------- required by this bound in `foo` ... -LL | foo((), drop) - | ^^^^ - | | - | expected signature of `for<'a> fn(<() as Trait<'a>>::Item) -> _` - | found signature of `fn(_) -> _` +LL | foo((), drop) + | ^^^^ + | | + | expected signature of `for<'a> fn(<() as Trait<'a>>::Item) -> _` + | found signature of `fn(_) -> _` error[E0271]: type mismatch resolving `for<'a> } as std::ops::FnOnce<(<() as Trait<'a>>::Item,)>>::Output == ()` --> $DIR/issue-60283.rs:14:5 | -LL | / pub fn foo(_: T, _: F) -LL | | where T: for<'a> Trait<'a>, -LL | | F: for<'a> FnMut(>::Item) {} - | |_________________________________________________- required by `foo` +LL | pub fn foo(_: T, _: F) + | --- +LL | where T: for<'a> Trait<'a>, +LL | F: for<'a> FnMut(>::Item) {} + | ------------------------ required by this bound in `foo` ... -LL | foo((), drop) - | ^^^ expected bound lifetime parameter 'a, found concrete lifetime +LL | foo((), drop) + | ^^^ expected bound lifetime parameter 'a, found concrete lifetime error: aborting due to 2 previous errors diff --git a/src/test/ui/kindck/kindck-copy.stderr b/src/test/ui/kindck/kindck-copy.stderr index 1fe59460e057f..53b4448a7574f 100644 --- a/src/test/ui/kindck/kindck-copy.stderr +++ b/src/test/ui/kindck/kindck-copy.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `&'static mut isize: std::marker::Copy` is not sat --> $DIR/kindck-copy.rs:27:5 | LL | fn assert_copy() { } - | ------------------------ required by `assert_copy` + | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy::<&'static mut isize>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'static mut isize` @@ -14,7 +14,7 @@ error[E0277]: the trait bound `&'a mut isize: std::marker::Copy` is not satisfie --> $DIR/kindck-copy.rs:28:5 | LL | fn assert_copy() { } - | ------------------------ required by `assert_copy` + | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy::<&'a mut isize>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'a mut isize` @@ -26,7 +26,7 @@ error[E0277]: the trait bound `std::boxed::Box: std::marker::Copy` is not --> $DIR/kindck-copy.rs:31:5 | LL | fn assert_copy() { } - | ------------------------ required by `assert_copy` + | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box` @@ -35,7 +35,7 @@ error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not sa --> $DIR/kindck-copy.rs:32:5 | LL | fn assert_copy() { } - | ------------------------ required by `assert_copy` + | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy::(); | ^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` @@ -44,7 +44,7 @@ error[E0277]: the trait bound `std::vec::Vec: std::marker::Copy` is not s --> $DIR/kindck-copy.rs:33:5 | LL | fn assert_copy() { } - | ------------------------ required by `assert_copy` + | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy:: >(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::vec::Vec` @@ -53,7 +53,7 @@ error[E0277]: the trait bound `std::boxed::Box<&'a mut isize>: std::marker::Copy --> $DIR/kindck-copy.rs:34:5 | LL | fn assert_copy() { } - | ------------------------ required by `assert_copy` + | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<&'a mut isize>` @@ -62,7 +62,7 @@ error[E0277]: the trait bound `std::boxed::Box: std::marker::Copy` is --> $DIR/kindck-copy.rs:42:5 | LL | fn assert_copy() { } - | ------------------------ required by `assert_copy` + | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box` @@ -71,7 +71,7 @@ error[E0277]: the trait bound `std::boxed::Box: s --> $DIR/kindck-copy.rs:43:5 | LL | fn assert_copy() { } - | ------------------------ required by `assert_copy` + | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box` @@ -80,7 +80,7 @@ error[E0277]: the trait bound `&'a mut (dyn Dummy + std::marker::Send + 'a): std --> $DIR/kindck-copy.rs:46:5 | LL | fn assert_copy() { } - | ------------------------ required by `assert_copy` + | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy::<&'a mut (dyn Dummy + Send)>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'a mut (dyn Dummy + std::marker::Send + 'a)` @@ -89,7 +89,7 @@ error[E0277]: the trait bound `MyNoncopyStruct: std::marker::Copy` is not satisf --> $DIR/kindck-copy.rs:64:5 | LL | fn assert_copy() { } - | ------------------------ required by `assert_copy` + | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `MyNoncopyStruct` @@ -98,7 +98,7 @@ error[E0277]: the trait bound `std::rc::Rc: std::marker::Copy` is not sat --> $DIR/kindck-copy.rs:67:5 | LL | fn assert_copy() { } - | ------------------------ required by `assert_copy` + | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::rc::Rc` diff --git a/src/test/ui/kindck/kindck-impl-type-params-2.stderr b/src/test/ui/kindck/kindck-impl-type-params-2.stderr index 5e6eca6f0571b..8e98911324411 100644 --- a/src/test/ui/kindck/kindck-impl-type-params-2.stderr +++ b/src/test/ui/kindck/kindck-impl-type-params-2.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `std::boxed::Box<{integer}>: std::marker::Copy` is --> $DIR/kindck-impl-type-params-2.rs:13:16 | LL | fn take_param(foo: &T) { } - | ----------------------------- required by `take_param` + | ---------- --- required by this bound in `take_param` ... LL | take_param(&x); | ^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<{integer}>` diff --git a/src/test/ui/kindck/kindck-inherited-copy-bound.stderr b/src/test/ui/kindck/kindck-inherited-copy-bound.stderr index 9f548083e73d1..27901d0692799 100644 --- a/src/test/ui/kindck/kindck-inherited-copy-bound.stderr +++ b/src/test/ui/kindck/kindck-inherited-copy-bound.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `std::boxed::Box<{integer}>: std::marker::Copy` is --> $DIR/kindck-inherited-copy-bound.rs:18:16 | LL | fn take_param(foo: &T) { } - | ----------------------------- required by `take_param` + | ---------- --- required by this bound in `take_param` ... LL | take_param(&x); | ^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<{integer}>` diff --git a/src/test/ui/kindck/kindck-nonsendable-1.stderr b/src/test/ui/kindck/kindck-nonsendable-1.stderr index 6d60de888c98d..40b67f8fe8cd7 100644 --- a/src/test/ui/kindck/kindck-nonsendable-1.stderr +++ b/src/test/ui/kindck/kindck-nonsendable-1.stderr @@ -2,7 +2,7 @@ error[E0277]: `std::rc::Rc` cannot be sent between threads safely --> $DIR/kindck-nonsendable-1.rs:9:5 | LL | fn bar(_: F) { } - | ------------------------------- required by `bar` + | --- ---- required by this bound in `bar` ... LL | bar(move|| foo(x)); | ^^^ `std::rc::Rc` cannot be sent between threads safely diff --git a/src/test/ui/kindck/kindck-send-object.stderr b/src/test/ui/kindck/kindck-send-object.stderr index 3ca2d730cbae9..8708537f8630f 100644 --- a/src/test/ui/kindck/kindck-send-object.stderr +++ b/src/test/ui/kindck/kindck-send-object.stderr @@ -2,7 +2,7 @@ error[E0277]: `(dyn Dummy + 'static)` cannot be shared between threads safely --> $DIR/kindck-send-object.rs:12:5 | LL | fn assert_send() { } - | ------------------------ required by `assert_send` + | ----------- ---- required by this bound in `assert_send` ... LL | assert_send::<&'static (dyn Dummy + 'static)>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'static)` cannot be shared between threads safely @@ -14,7 +14,7 @@ error[E0277]: `dyn Dummy` cannot be sent between threads safely --> $DIR/kindck-send-object.rs:17:5 | LL | fn assert_send() { } - | ------------------------ required by `assert_send` + | ----------- ---- required by this bound in `assert_send` ... LL | assert_send::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `dyn Dummy` cannot be sent between threads safely diff --git a/src/test/ui/kindck/kindck-send-object1.stderr b/src/test/ui/kindck/kindck-send-object1.stderr index 0f5f7e0890b23..436b92637aaad 100644 --- a/src/test/ui/kindck/kindck-send-object1.stderr +++ b/src/test/ui/kindck/kindck-send-object1.stderr @@ -2,7 +2,7 @@ error[E0277]: `(dyn Dummy + 'a)` cannot be shared between threads safely --> $DIR/kindck-send-object1.rs:10:5 | LL | fn assert_send() { } - | -------------------------------- required by `assert_send` + | ----------- ---- required by this bound in `assert_send` ... LL | assert_send::<&'a dyn Dummy>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be shared between threads safely @@ -22,7 +22,7 @@ error[E0277]: `(dyn Dummy + 'a)` cannot be sent between threads safely --> $DIR/kindck-send-object1.rs:29:5 | LL | fn assert_send() { } - | -------------------------------- required by `assert_send` + | ----------- ---- required by this bound in `assert_send` ... LL | assert_send::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be sent between threads safely diff --git a/src/test/ui/kindck/kindck-send-object2.stderr b/src/test/ui/kindck/kindck-send-object2.stderr index 72cd985cc8639..6cb82edf263b1 100644 --- a/src/test/ui/kindck/kindck-send-object2.stderr +++ b/src/test/ui/kindck/kindck-send-object2.stderr @@ -2,7 +2,7 @@ error[E0277]: `(dyn Dummy + 'static)` cannot be shared between threads safely --> $DIR/kindck-send-object2.rs:7:5 | LL | fn assert_send() { } - | ------------------------ required by `assert_send` + | ----------- ---- required by this bound in `assert_send` ... LL | assert_send::<&'static dyn Dummy>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'static)` cannot be shared between threads safely @@ -14,7 +14,7 @@ error[E0277]: `dyn Dummy` cannot be sent between threads safely --> $DIR/kindck-send-object2.rs:12:5 | LL | fn assert_send() { } - | ------------------------ required by `assert_send` + | ----------- ---- required by this bound in `assert_send` ... LL | assert_send::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `dyn Dummy` cannot be sent between threads safely diff --git a/src/test/ui/kindck/kindck-send-owned.stderr b/src/test/ui/kindck/kindck-send-owned.stderr index ee919f02d6537..c740349542458 100644 --- a/src/test/ui/kindck/kindck-send-owned.stderr +++ b/src/test/ui/kindck/kindck-send-owned.stderr @@ -2,7 +2,7 @@ error[E0277]: `*mut u8` cannot be sent between threads safely --> $DIR/kindck-send-owned.rs:12:5 | LL | fn assert_send() { } - | ------------------------ required by `assert_send` + | ----------- ---- required by this bound in `assert_send` ... LL | assert_send::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*mut u8` cannot be sent between threads safely diff --git a/src/test/ui/kindck/kindck-send-unsafe.stderr b/src/test/ui/kindck/kindck-send-unsafe.stderr index a87e1c7db2a2e..a46705ab1755d 100644 --- a/src/test/ui/kindck/kindck-send-unsafe.stderr +++ b/src/test/ui/kindck/kindck-send-unsafe.stderr @@ -2,7 +2,7 @@ error[E0277]: `*mut &'a isize` cannot be sent between threads safely --> $DIR/kindck-send-unsafe.rs:6:5 | LL | fn assert_send() { } - | ------------------------ required by `assert_send` + | ----------- ---- required by this bound in `assert_send` ... LL | assert_send::<*mut &'a isize>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*mut &'a isize` cannot be sent between threads safely diff --git a/src/test/ui/marker_trait_attr/overlap-marker-trait.stderr b/src/test/ui/marker_trait_attr/overlap-marker-trait.stderr index 4e79fbdeadc5c..be5e649ef8340 100644 --- a/src/test/ui/marker_trait_attr/overlap-marker-trait.stderr +++ b/src/test/ui/marker_trait_attr/overlap-marker-trait.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `NotDebugOrDisplay: Marker` is not satisfied --> $DIR/overlap-marker-trait.rs:27:5 | LL | fn is_marker() { } - | ------------------------- required by `is_marker` + | --------- ------ required by this bound in `is_marker` ... LL | is_marker::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Marker` is not implemented for `NotDebugOrDisplay` diff --git a/src/test/ui/mismatched_types/E0631.stderr b/src/test/ui/mismatched_types/E0631.stderr index 64ddf1deb0639..88c1efdbb90f4 100644 --- a/src/test/ui/mismatched_types/E0631.stderr +++ b/src/test/ui/mismatched_types/E0631.stderr @@ -2,7 +2,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/E0631.rs:7:5 | LL | fn foo(_: F) {} - | -------------------------- required by `foo` + | --- --------- required by this bound in `foo` ... LL | foo(|_: isize| {}); | ^^^ ---------- found signature of `fn(isize) -> _` @@ -13,7 +13,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/E0631.rs:8:5 | LL | fn bar>(_: F) {} - | -------------------------- required by `bar` + | --- --------- required by this bound in `bar` ... LL | bar(|_: isize| {}); | ^^^ ---------- found signature of `fn(isize) -> _` @@ -24,7 +24,7 @@ error[E0631]: type mismatch in function arguments --> $DIR/E0631.rs:9:9 | LL | fn foo(_: F) {} - | -------------------------- required by `foo` + | --- --------- required by this bound in `foo` ... LL | fn f(_: u64) {} | ------------ found signature of `fn(u64) -> _` @@ -36,7 +36,7 @@ error[E0631]: type mismatch in function arguments --> $DIR/E0631.rs:10:9 | LL | fn bar>(_: F) {} - | -------------------------- required by `bar` + | --- --------- required by this bound in `bar` LL | fn main() { LL | fn f(_: u64) {} | ------------ found signature of `fn(u64) -> _` diff --git a/src/test/ui/mismatched_types/closure-arg-count.stderr b/src/test/ui/mismatched_types/closure-arg-count.stderr index 12ae8acaee5cf..ed2b3f0c3ce6c 100644 --- a/src/test/ui/mismatched_types/closure-arg-count.stderr +++ b/src/test/ui/mismatched_types/closure-arg-count.stderr @@ -46,7 +46,7 @@ error[E0593]: closure is expected to take 1 argument, but it takes 0 arguments --> $DIR/closure-arg-count.rs:13:5 | LL | fn f>(_: F) {} - | ------------------------ required by `f` + | - --------- required by this bound in `f` ... LL | f(|| panic!()); | ^ -- takes 0 arguments @@ -61,7 +61,7 @@ error[E0593]: closure is expected to take 1 argument, but it takes 0 arguments --> $DIR/closure-arg-count.rs:15:5 | LL | fn f>(_: F) {} - | ------------------------ required by `f` + | - --------- required by this bound in `f` ... LL | f( move || panic!()); | ^ ---------- takes 0 arguments @@ -143,7 +143,7 @@ LL | call(Foo); | ^^^ expected function that takes 0 arguments ... LL | fn call(_: F) where F: FnOnce() -> R {} - | ------------------------------------------ required by `call` + | ---- ------------- required by this bound in `call` LL | struct Foo(u8); | --------------- takes 1 argument diff --git a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr b/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr index 68bc17b4966f1..a731891bf764e 100644 --- a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr @@ -26,7 +26,7 @@ error[E0631]: type mismatch in function arguments --> $DIR/closure-arg-type-mismatch.rs:10:9 | LL | fn baz(_: F) {} - | ------------------------------ required by `baz` + | --- ------------- required by this bound in `baz` LL | fn _test<'a>(f: fn(*mut &'a u32)) { LL | baz(f); | ^ @@ -38,7 +38,7 @@ error[E0271]: type mismatch resolving `for<'r> $DIR/closure-arg-type-mismatch.rs:10:5 | LL | fn baz(_: F) {} - | ------------------------------ required by `baz` + | --- ----------- required by this bound in `baz` LL | fn _test<'a>(f: fn(*mut &'a u32)) { LL | baz(f); | ^^^ expected bound lifetime parameter, found concrete lifetime diff --git a/src/test/ui/mismatched_types/closure-mismatch.stderr b/src/test/ui/mismatched_types/closure-mismatch.stderr index 0fe4909eaa778..fd2b9f3c66b04 100644 --- a/src/test/ui/mismatched_types/closure-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-mismatch.stderr @@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `for<'r> <[closure@$DIR/closure-mismatch.r --> $DIR/closure-mismatch.rs:8:5 | LL | fn baz(_: T) {} - | -------------------- required by `baz` + | --- --- required by this bound in `baz` ... LL | baz(|_| ()); | ^^^ expected bound lifetime parameter, found concrete lifetime @@ -13,7 +13,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/closure-mismatch.rs:8:5 | LL | fn baz(_: T) {} - | -------------------- required by `baz` + | --- --- required by this bound in `baz` ... LL | baz(|_| ()); | ^^^ ------ found signature of `fn(_) -> _` diff --git a/src/test/ui/mismatched_types/fn-variance-1.stderr b/src/test/ui/mismatched_types/fn-variance-1.stderr index 6342ee770ddaf..1a82dd53edc70 100644 --- a/src/test/ui/mismatched_types/fn-variance-1.stderr +++ b/src/test/ui/mismatched_types/fn-variance-1.stderr @@ -5,7 +5,7 @@ LL | fn takes_mut(x: &mut isize) { } | --------------------------- found signature of `for<'r> fn(&'r mut isize) -> _` LL | LL | fn apply(t: T, f: F) where F: FnOnce(T) { - | --------------------------------------------- required by `apply` + | ----- --------- required by this bound in `apply` ... LL | apply(&3, takes_mut); | ^^^^^^^^^ expected signature of `fn(&{integer}) -> _` @@ -17,7 +17,7 @@ LL | fn takes_imm(x: &isize) { } | ----------------------- found signature of `for<'r> fn(&'r isize) -> _` ... LL | fn apply(t: T, f: F) where F: FnOnce(T) { - | --------------------------------------------- required by `apply` + | ----- --------- required by this bound in `apply` ... LL | apply(&mut 3, takes_imm); | ^^^^^^^^^ expected signature of `fn(&mut {integer}) -> _` diff --git a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs index 88bea979b97fe..2bd4d3384469f 100644 --- a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs +++ b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs @@ -5,7 +5,8 @@ use std::ops::FnMut; fn to_fn_mut>(f: F) -> F { f } fn call_itisize>(y: isize, mut f: F) -> isize { -//~^ NOTE required by `call_it` +//~^ NOTE required by this bound in `call_it` +//~| NOTE f(2, y) } diff --git a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr index 139d87d58b640..6c249f6275181 100644 --- a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr +++ b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr @@ -1,8 +1,8 @@ error[E0631]: type mismatch in closure arguments - --> $DIR/unboxed-closures-vtable-mismatch.rs:15:24 + --> $DIR/unboxed-closures-vtable-mismatch.rs:16:13 | LL | fn call_itisize>(y: isize, mut f: F) -> isize { - | -------------------------------------------------------------------- required by `call_it` + | ------- ------------------------- required by this bound in `call_it` ... LL | let f = to_fn_mut(|x: usize, y: isize| -> isize { (x as isize) + y }); | ----------------------------- found signature of `fn(usize, isize) -> _` diff --git a/src/test/ui/mut/mutable-enum-indirect.stderr b/src/test/ui/mut/mutable-enum-indirect.stderr index 4efb10b56290e..0290efc3d9679 100644 --- a/src/test/ui/mut/mutable-enum-indirect.stderr +++ b/src/test/ui/mut/mutable-enum-indirect.stderr @@ -2,7 +2,7 @@ error[E0277]: `NoSync` cannot be shared between threads safely --> $DIR/mutable-enum-indirect.rs:17:5 | LL | fn bar(_: T) {} - | --------------------- required by `bar` + | --- ---- required by this bound in `bar` ... LL | bar(&x); | ^^^ `NoSync` cannot be shared between threads safely diff --git a/src/test/ui/mutexguard-sync.stderr b/src/test/ui/mutexguard-sync.stderr index 1cda2da5061a5..71a06fce4b9e1 100644 --- a/src/test/ui/mutexguard-sync.stderr +++ b/src/test/ui/mutexguard-sync.stderr @@ -2,7 +2,7 @@ error[E0277]: `std::cell::Cell` cannot be shared between threads safely --> $DIR/mutexguard-sync.rs:11:15 | LL | fn test_sync(_t: T) {} - | ---------------------------- required by `test_sync` + | --------- ---- required by this bound in `test_sync` ... LL | test_sync(guard); | ^^^^^ `std::cell::Cell` cannot be shared between threads safely diff --git a/src/test/ui/namespace/namespace-mix.stderr b/src/test/ui/namespace/namespace-mix.stderr index 249ad1c584421..aa21928aaeff2 100644 --- a/src/test/ui/namespace/namespace-mix.stderr +++ b/src/test/ui/namespace/namespace-mix.stderr @@ -70,7 +70,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:33:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(m1::S{}); | ^^^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -79,7 +79,7 @@ error[E0277]: the trait bound `c::S: Impossible` is not satisfied --> $DIR/namespace-mix.rs:35:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(m2::S{}); | ^^^^^^^ the trait `Impossible` is not implemented for `c::S` @@ -88,7 +88,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:36:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(m2::S); | ^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -97,7 +97,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:39:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(xm1::S{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` @@ -106,7 +106,7 @@ error[E0277]: the trait bound `namespace_mix::c::S: Impossible` is not satisfied --> $DIR/namespace-mix.rs:41:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(xm2::S{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::S` @@ -115,7 +115,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:42:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(xm2::S); | ^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` @@ -124,7 +124,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:55:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(m3::TS{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -133,7 +133,7 @@ error[E0277]: the trait bound `fn() -> c::TS {c::TS}: Impossible` is not satisfi --> $DIR/namespace-mix.rs:56:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(m3::TS); | ^^^^^^ the trait `Impossible` is not implemented for `fn() -> c::TS {c::TS}` @@ -142,7 +142,7 @@ error[E0277]: the trait bound `c::TS: Impossible` is not satisfied --> $DIR/namespace-mix.rs:57:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(m4::TS{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `c::TS` @@ -151,7 +151,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:58:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(m4::TS); | ^^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -160,7 +160,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:61:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(xm3::TS{}); | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` @@ -169,7 +169,7 @@ error[E0277]: the trait bound `fn() -> namespace_mix::c::TS {namespace_mix::c::T --> $DIR/namespace-mix.rs:62:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(xm3::TS); | ^^^^^^^ the trait `Impossible` is not implemented for `fn() -> namespace_mix::c::TS {namespace_mix::c::TS}` @@ -178,7 +178,7 @@ error[E0277]: the trait bound `namespace_mix::c::TS: Impossible` is not satisfie --> $DIR/namespace-mix.rs:63:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(xm4::TS{}); | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::TS` @@ -187,7 +187,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:64:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(xm4::TS); | ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` @@ -196,7 +196,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:77:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(m5::US{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -205,7 +205,7 @@ error[E0277]: the trait bound `c::US: Impossible` is not satisfied --> $DIR/namespace-mix.rs:78:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(m5::US); | ^^^^^^ the trait `Impossible` is not implemented for `c::US` @@ -214,7 +214,7 @@ error[E0277]: the trait bound `c::US: Impossible` is not satisfied --> $DIR/namespace-mix.rs:79:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(m6::US{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `c::US` @@ -223,7 +223,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:80:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(m6::US); | ^^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -232,7 +232,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:83:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(xm5::US{}); | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` @@ -241,7 +241,7 @@ error[E0277]: the trait bound `namespace_mix::c::US: Impossible` is not satisfie --> $DIR/namespace-mix.rs:84:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(xm5::US); | ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::US` @@ -250,7 +250,7 @@ error[E0277]: the trait bound `namespace_mix::c::US: Impossible` is not satisfie --> $DIR/namespace-mix.rs:85:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(xm6::US{}); | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::US` @@ -259,7 +259,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:86:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(xm6::US); | ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` @@ -268,7 +268,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:99:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(m7::V{}); | ^^^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -277,7 +277,7 @@ error[E0277]: the trait bound `c::E: Impossible` is not satisfied --> $DIR/namespace-mix.rs:101:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(m8::V{}); | ^^^^^^^ the trait `Impossible` is not implemented for `c::E` @@ -286,7 +286,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:102:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(m8::V); | ^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -295,7 +295,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:105:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(xm7::V{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` @@ -304,7 +304,7 @@ error[E0277]: the trait bound `namespace_mix::c::E: Impossible` is not satisfied --> $DIR/namespace-mix.rs:107:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(xm8::V{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::E` @@ -313,7 +313,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:108:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(xm8::V); | ^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` @@ -322,7 +322,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:121:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(m9::TV{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -331,7 +331,7 @@ error[E0277]: the trait bound `fn() -> c::E {c::E::TV}: Impossible` is not satis --> $DIR/namespace-mix.rs:122:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(m9::TV); | ^^^^^^ the trait `Impossible` is not implemented for `fn() -> c::E {c::E::TV}` @@ -340,7 +340,7 @@ error[E0277]: the trait bound `c::E: Impossible` is not satisfied --> $DIR/namespace-mix.rs:123:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(mA::TV{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `c::E` @@ -349,7 +349,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:124:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(mA::TV); | ^^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -358,7 +358,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:127:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(xm9::TV{}); | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` @@ -367,7 +367,7 @@ error[E0277]: the trait bound `fn() -> namespace_mix::c::E {namespace_mix::xm7:: --> $DIR/namespace-mix.rs:128:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(xm9::TV); | ^^^^^^^ the trait `Impossible` is not implemented for `fn() -> namespace_mix::c::E {namespace_mix::xm7::TV}` @@ -376,7 +376,7 @@ error[E0277]: the trait bound `namespace_mix::c::E: Impossible` is not satisfied --> $DIR/namespace-mix.rs:129:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(xmA::TV{}); | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::E` @@ -385,7 +385,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:130:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(xmA::TV); | ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` @@ -394,7 +394,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:143:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(mB::UV{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -403,7 +403,7 @@ error[E0277]: the trait bound `c::E: Impossible` is not satisfied --> $DIR/namespace-mix.rs:144:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(mB::UV); | ^^^^^^ the trait `Impossible` is not implemented for `c::E` @@ -412,7 +412,7 @@ error[E0277]: the trait bound `c::E: Impossible` is not satisfied --> $DIR/namespace-mix.rs:145:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(mC::UV{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `c::E` @@ -421,7 +421,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:146:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(mC::UV); | ^^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -430,7 +430,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:149:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(xmB::UV{}); | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` @@ -439,7 +439,7 @@ error[E0277]: the trait bound `namespace_mix::c::E: Impossible` is not satisfied --> $DIR/namespace-mix.rs:150:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(xmB::UV); | ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::E` @@ -448,7 +448,7 @@ error[E0277]: the trait bound `namespace_mix::c::E: Impossible` is not satisfied --> $DIR/namespace-mix.rs:151:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(xmC::UV{}); | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::E` @@ -457,7 +457,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:152:11 | LL | fn check(_: T) {} - | ----------------------------- required by `check` + | ----- ---------- required by this bound in `check` ... LL | check(xmC::UV); | ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` diff --git a/src/test/ui/no-send-res-ports.stderr b/src/test/ui/no-send-res-ports.stderr index 515b948cc7eb2..20f88badbefd4 100644 --- a/src/test/ui/no-send-res-ports.stderr +++ b/src/test/ui/no-send-res-ports.stderr @@ -3,12 +3,16 @@ error[E0277]: `std::rc::Rc<()>` cannot be sent between threads safely | LL | thread::spawn(move|| { | ^^^^^^^^^^^^^ `std::rc::Rc<()>` cannot be sent between threads safely + | + ::: $SRC_DIR/libstd/thread/mod.rs:LL:COL + | +LL | F: FnOnce() -> T, F: Send + 'static, T: Send + 'static + | ---- required by this bound in `std::thread::spawn` | = help: within `[closure@$DIR/no-send-res-ports.rs:25:19: 29:6 x:main::Foo]`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<()>` = note: required because it appears within the type `Port<()>` = note: required because it appears within the type `main::Foo` = note: required because it appears within the type `[closure@$DIR/no-send-res-ports.rs:25:19: 29:6 x:main::Foo]` - = note: required by `std::thread::spawn` error: aborting due to previous error diff --git a/src/test/ui/no_send-enum.stderr b/src/test/ui/no_send-enum.stderr index d1f3398ff9027..8a4b2e9c7a7c1 100644 --- a/src/test/ui/no_send-enum.stderr +++ b/src/test/ui/no_send-enum.stderr @@ -2,7 +2,7 @@ error[E0277]: `NoSend` cannot be sent between threads safely --> $DIR/no_send-enum.rs:16:5 | LL | fn bar(_: T) {} - | --------------------- required by `bar` + | --- ---- required by this bound in `bar` ... LL | bar(x); | ^^^ `NoSend` cannot be sent between threads safely diff --git a/src/test/ui/no_send-rc.stderr b/src/test/ui/no_send-rc.stderr index de08634e16ac4..bd646d0509daf 100644 --- a/src/test/ui/no_send-rc.stderr +++ b/src/test/ui/no_send-rc.stderr @@ -2,7 +2,7 @@ error[E0277]: `std::rc::Rc<{integer}>` cannot be sent between threads safely --> $DIR/no_send-rc.rs:7:9 | LL | fn bar(_: T) {} - | --------------------- required by `bar` + | --- ---- required by this bound in `bar` ... LL | bar(x); | ^ `std::rc::Rc<{integer}>` cannot be sent between threads safely diff --git a/src/test/ui/no_send-struct.stderr b/src/test/ui/no_send-struct.stderr index 3865971fcfdd1..4823852c2ff80 100644 --- a/src/test/ui/no_send-struct.stderr +++ b/src/test/ui/no_send-struct.stderr @@ -2,7 +2,7 @@ error[E0277]: `Foo` cannot be sent between threads safely --> $DIR/no_send-struct.rs:15:9 | LL | fn bar(_: T) {} - | --------------------- required by `bar` + | --- ---- required by this bound in `bar` ... LL | bar(x); | ^ `Foo` cannot be sent between threads safely diff --git a/src/test/ui/no_share-enum.stderr b/src/test/ui/no_share-enum.stderr index 5a9b7cae0b9f6..f42228ef6ab42 100644 --- a/src/test/ui/no_share-enum.stderr +++ b/src/test/ui/no_share-enum.stderr @@ -2,7 +2,7 @@ error[E0277]: `NoSync` cannot be shared between threads safely --> $DIR/no_share-enum.rs:14:5 | LL | fn bar(_: T) {} - | --------------------- required by `bar` + | --- ---- required by this bound in `bar` ... LL | bar(x); | ^^^ `NoSync` cannot be shared between threads safely diff --git a/src/test/ui/no_share-struct.stderr b/src/test/ui/no_share-struct.stderr index 13de5bd6fe84b..620b5427b9aec 100644 --- a/src/test/ui/no_share-struct.stderr +++ b/src/test/ui/no_share-struct.stderr @@ -2,7 +2,7 @@ error[E0277]: `Foo` cannot be shared between threads safely --> $DIR/no_share-struct.rs:12:9 | LL | fn bar(_: T) {} - | --------------------- required by `bar` + | --- ---- required by this bound in `bar` ... LL | bar(x); | ^ `Foo` cannot be shared between threads safely diff --git a/src/test/ui/not-panic/not-panic-safe-2.stderr b/src/test/ui/not-panic/not-panic-safe-2.stderr index 5bacf0bbc6b45..6668d2d0db191 100644 --- a/src/test/ui/not-panic/not-panic-safe-2.stderr +++ b/src/test/ui/not-panic/not-panic-safe-2.stderr @@ -2,7 +2,7 @@ error[E0277]: the type `std::cell::UnsafeCell` may contain interior mutabil --> $DIR/not-panic-safe-2.rs:10:5 | LL | fn assert() {} - | ----------------------------------- required by `assert` + | ------ ---------- required by this bound in `assert` ... LL | assert::>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary @@ -15,7 +15,7 @@ error[E0277]: the type `std::cell::UnsafeCell` may contain interior mutab --> $DIR/not-panic-safe-2.rs:10:5 | LL | fn assert() {} - | ----------------------------------- required by `assert` + | ------ ---------- required by this bound in `assert` ... LL | assert::>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary diff --git a/src/test/ui/not-panic/not-panic-safe-3.stderr b/src/test/ui/not-panic/not-panic-safe-3.stderr index 6d2a450115dff..c23b08fc9eda9 100644 --- a/src/test/ui/not-panic/not-panic-safe-3.stderr +++ b/src/test/ui/not-panic/not-panic-safe-3.stderr @@ -2,7 +2,7 @@ error[E0277]: the type `std::cell::UnsafeCell` may contain interior mutabil --> $DIR/not-panic-safe-3.rs:10:5 | LL | fn assert() {} - | ----------------------------------- required by `assert` + | ------ ---------- required by this bound in `assert` ... LL | assert::>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary @@ -15,7 +15,7 @@ error[E0277]: the type `std::cell::UnsafeCell` may contain interior mutab --> $DIR/not-panic-safe-3.rs:10:5 | LL | fn assert() {} - | ----------------------------------- required by `assert` + | ------ ---------- required by this bound in `assert` ... LL | assert::>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary diff --git a/src/test/ui/not-panic/not-panic-safe-4.stderr b/src/test/ui/not-panic/not-panic-safe-4.stderr index e28f169b72b6c..916804a834f58 100644 --- a/src/test/ui/not-panic/not-panic-safe-4.stderr +++ b/src/test/ui/not-panic/not-panic-safe-4.stderr @@ -2,7 +2,7 @@ error[E0277]: the type `std::cell::UnsafeCell` may contain interior mutabil --> $DIR/not-panic-safe-4.rs:9:5 | LL | fn assert() {} - | ----------------------------------- required by `assert` + | ------ ---------- required by this bound in `assert` ... LL | assert::<&RefCell>(); | ^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary @@ -15,7 +15,7 @@ error[E0277]: the type `std::cell::UnsafeCell` may contain interior mutab --> $DIR/not-panic-safe-4.rs:9:5 | LL | fn assert() {} - | ----------------------------------- required by `assert` + | ------ ---------- required by this bound in `assert` ... LL | assert::<&RefCell>(); | ^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary diff --git a/src/test/ui/not-panic/not-panic-safe-5.stderr b/src/test/ui/not-panic/not-panic-safe-5.stderr index f8c4fe68dde7b..d5c189723f402 100644 --- a/src/test/ui/not-panic/not-panic-safe-5.stderr +++ b/src/test/ui/not-panic/not-panic-safe-5.stderr @@ -2,7 +2,7 @@ error[E0277]: the type `std::cell::UnsafeCell` may contain interior mutabil --> $DIR/not-panic-safe-5.rs:9:5 | LL | fn assert() {} - | ----------------------------------- required by `assert` + | ------ ---------- required by this bound in `assert` ... LL | assert::<*const UnsafeCell>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary diff --git a/src/test/ui/not-panic/not-panic-safe-6.stderr b/src/test/ui/not-panic/not-panic-safe-6.stderr index 2cd780590729c..c8013a836a177 100644 --- a/src/test/ui/not-panic/not-panic-safe-6.stderr +++ b/src/test/ui/not-panic/not-panic-safe-6.stderr @@ -2,7 +2,7 @@ error[E0277]: the type `std::cell::UnsafeCell` may contain interior mutabil --> $DIR/not-panic-safe-6.rs:9:5 | LL | fn assert() {} - | ----------------------------------- required by `assert` + | ------ ---------- required by this bound in `assert` ... LL | assert::<*mut RefCell>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary @@ -15,7 +15,7 @@ error[E0277]: the type `std::cell::UnsafeCell` may contain interior mutab --> $DIR/not-panic-safe-6.rs:9:5 | LL | fn assert() {} - | ----------------------------------- required by `assert` + | ------ ---------- required by this bound in `assert` ... LL | assert::<*mut RefCell>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary diff --git a/src/test/ui/not-panic/not-panic-safe.stderr b/src/test/ui/not-panic/not-panic-safe.stderr index 315ea17971aa9..aa18b923044c6 100644 --- a/src/test/ui/not-panic/not-panic-safe.stderr +++ b/src/test/ui/not-panic/not-panic-safe.stderr @@ -2,7 +2,7 @@ error[E0277]: the type `&mut i32` may not be safely transferred across an unwind --> $DIR/not-panic-safe.rs:9:5 | LL | fn assert() {} - | ----------------------------------- required by `assert` + | ------ ---------- required by this bound in `assert` ... LL | assert::<&mut i32>(); | ^^^^^^^^^^^^^^^^^^ `&mut i32` may not be safely transferred across an unwind boundary diff --git a/src/test/ui/not-sync.stderr b/src/test/ui/not-sync.stderr index 57f1122be2b35..8871abedd00dd 100644 --- a/src/test/ui/not-sync.stderr +++ b/src/test/ui/not-sync.stderr @@ -2,7 +2,7 @@ error[E0277]: `std::cell::Cell` cannot be shared between threads safely --> $DIR/not-sync.rs:8:5 | LL | fn test() {} - | ------------------ required by `test` + | ---- ---- required by this bound in `test` ... LL | test::>(); | ^^^^^^^^^^^^^^^^^ `std::cell::Cell` cannot be shared between threads safely @@ -13,7 +13,7 @@ error[E0277]: `std::cell::RefCell` cannot be shared between threads safely --> $DIR/not-sync.rs:10:5 | LL | fn test() {} - | ------------------ required by `test` + | ---- ---- required by this bound in `test` ... LL | test::>(); | ^^^^^^^^^^^^^^^^^^^^ `std::cell::RefCell` cannot be shared between threads safely @@ -24,7 +24,7 @@ error[E0277]: `std::rc::Rc` cannot be shared between threads safely --> $DIR/not-sync.rs:13:5 | LL | fn test() {} - | ------------------ required by `test` + | ---- ---- required by this bound in `test` ... LL | test::>(); | ^^^^^^^^^^^^^^^ `std::rc::Rc` cannot be shared between threads safely @@ -35,7 +35,7 @@ error[E0277]: `std::rc::Weak` cannot be shared between threads safely --> $DIR/not-sync.rs:15:5 | LL | fn test() {} - | ------------------ required by `test` + | ---- ---- required by this bound in `test` ... LL | test::>(); | ^^^^^^^^^^^^^^^^^ `std::rc::Weak` cannot be shared between threads safely @@ -46,7 +46,7 @@ error[E0277]: `std::sync::mpsc::Receiver` cannot be shared between threads --> $DIR/not-sync.rs:18:5 | LL | fn test() {} - | ------------------ required by `test` + | ---- ---- required by this bound in `test` ... LL | test::>(); | ^^^^^^^^^^^^^^^^^^^^^ `std::sync::mpsc::Receiver` cannot be shared between threads safely @@ -57,7 +57,7 @@ error[E0277]: `std::sync::mpsc::Sender` cannot be shared between threads sa --> $DIR/not-sync.rs:20:5 | LL | fn test() {} - | ------------------ required by `test` + | ---- ---- required by this bound in `test` ... LL | test::>(); | ^^^^^^^^^^^^^^^^^^^ `std::sync::mpsc::Sender` cannot be shared between threads safely diff --git a/src/test/ui/object-does-not-impl-trait.stderr b/src/test/ui/object-does-not-impl-trait.stderr index 83ca9a7212b22..7ac199d094383 100644 --- a/src/test/ui/object-does-not-impl-trait.stderr +++ b/src/test/ui/object-does-not-impl-trait.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `std::boxed::Box: Foo` is not satisfied --> $DIR/object-does-not-impl-trait.rs:6:44 | LL | fn take_foo(f: F) {} - | ------------------------ required by `take_foo` + | -------- --- required by this bound in `take_foo` LL | fn take_object(f: Box) { take_foo(f); } | ^ the trait `Foo` is not implemented for `std::boxed::Box` diff --git a/src/test/ui/on-unimplemented/on-trait.stderr b/src/test/ui/on-unimplemented/on-trait.stderr index 992f53b1da6b6..8fe7ed4a20443 100644 --- a/src/test/ui/on-unimplemented/on-trait.stderr +++ b/src/test/ui/on-unimplemented/on-trait.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `std::option::Option>: MyFromIte --> $DIR/on-trait.rs:28:30 | LL | fn collect, B: MyFromIterator>(it: I) -> B { - | -------------------------------------------------------------------- required by `collect` + | ------- ----------------- required by this bound in `collect` ... LL | let y: Option> = collect(x.iter()); // this should give approximately the same error for x.iter().collect() | ^^^^^^^ a collection of type `std::option::Option>` cannot be built from an iterator over elements of type `&u8` @@ -13,7 +13,7 @@ error[E0277]: the trait bound `std::string::String: Bar::Foo` is not --> $DIR/on-trait.rs:31:21 | LL | fn foobar>() -> T { - | ---------------------------------------------- required by `foobar` + | ------ --------------- required by this bound in `foobar` ... LL | let x: String = foobar(); | ^^^^^^ test error `std::string::String` with `u8` `_` `u32` in `Bar::Foo` diff --git a/src/test/ui/overlap-marker-trait.stderr b/src/test/ui/overlap-marker-trait.stderr index a66e3990e8bd9..daf4e5e69a29b 100644 --- a/src/test/ui/overlap-marker-trait.stderr +++ b/src/test/ui/overlap-marker-trait.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `NotDebugOrDisplay: Marker` is not satisfied --> $DIR/overlap-marker-trait.rs:30:5 | LL | fn is_marker() { } - | ------------------------- required by `is_marker` + | --------- ------ required by this bound in `is_marker` ... LL | is_marker::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Marker` is not implemented for `NotDebugOrDisplay` diff --git a/src/test/ui/phantom-oibit.stderr b/src/test/ui/phantom-oibit.stderr index c1b60e0823fd4..ac48ee0cb0fe3 100644 --- a/src/test/ui/phantom-oibit.stderr +++ b/src/test/ui/phantom-oibit.stderr @@ -2,7 +2,7 @@ error[E0277]: `T` cannot be shared between threads safely --> $DIR/phantom-oibit.rs:21:12 | LL | fn is_zen(_: T) {} - | ----------------------- required by `is_zen` + | ------ --- required by this bound in `is_zen` ... LL | is_zen(x) | ^ `T` cannot be shared between threads safely @@ -17,7 +17,7 @@ error[E0277]: `T` cannot be shared between threads safely --> $DIR/phantom-oibit.rs:26:12 | LL | fn is_zen(_: T) {} - | ----------------------- required by `is_zen` + | ------ --- required by this bound in `is_zen` ... LL | is_zen(x) | ^ `T` cannot be shared between threads safely diff --git a/src/test/ui/regions/regions-close-object-into-object-5.stderr b/src/test/ui/regions/regions-close-object-into-object-5.stderr index 390f8e7baa34a..01975d40fdf1f 100644 --- a/src/test/ui/regions/regions-close-object-into-object-5.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-5.stderr @@ -52,26 +52,26 @@ LL | // oh dear! LL | box B(&*v) as Box | ^^^^^^ | -note: ...so that the reference type `&dyn A` does not outlive the data it points at +note: ...so that the type `T` will meet its required lifetime bounds --> $DIR/regions-close-object-into-object-5.rs:17:9 | LL | box B(&*v) as Box | ^^^^^^ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:9 + --> $DIR/regions-close-object-into-object-5.rs:17:11 | LL | fn f<'a, T, U>(v: Box+'static>) -> Box { | - help: consider adding an explicit lifetime bound `T: 'static`... LL | // oh dear! LL | box B(&*v) as Box - | ^^^^^^ + | ^^^ | -note: ...so that the type `T` will meet its required lifetime bounds - --> $DIR/regions-close-object-into-object-5.rs:17:9 +note: ...so that the reference type `&dyn A` does not outlive the data it points at + --> $DIR/regions-close-object-into-object-5.rs:17:11 | LL | box B(&*v) as Box - | ^^^^^^ + | ^^^ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-object-into-object-5.rs:17:11 diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr index f253b67a01914..983063d19711f 100644 --- a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr @@ -5,9 +5,13 @@ LL | / fn can_parse_zero_as_f32() -> Result { LL | | "0".parse() LL | | } | |_^ `main` can only return types that implement `std::process::Termination` + | + ::: $SRC_DIR/libtest/lib.rs:LL:COL + | +LL | pub fn assert_test_result(result: T) { + | ----------- required by this bound in `test::assert_test_result` | = help: the trait `std::process::Termination` is not implemented for `std::result::Result` - = note: required by `test::assert_test_result` error: aborting due to previous error diff --git a/src/test/ui/str/str-mut-idx.stderr b/src/test/ui/str/str-mut-idx.stderr index 372077a465e4a..3c957970e51c2 100644 --- a/src/test/ui/str/str-mut-idx.stderr +++ b/src/test/ui/str/str-mut-idx.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `str` cannot be known at compilation t --> $DIR/str-mut-idx.rs:4:15 | LL | fn bot() -> T { loop {} } - | ---------------- required by `bot` + | --- - required by this bound in `bot` ... LL | s[1..2] = bot(); | ^^^ doesn't have a size known at compile-time diff --git a/src/test/ui/substs-ppaux.normal.stderr b/src/test/ui/substs-ppaux.normal.stderr index 4a8c99cdef3f5..cb55203c88e31 100644 --- a/src/test/ui/substs-ppaux.normal.stderr +++ b/src/test/ui/substs-ppaux.normal.stderr @@ -62,7 +62,7 @@ error[E0277]: the size for values of type `str` cannot be known at compilation t --> $DIR/substs-ppaux.rs:49:5 | LL | fn bar<'a, T>() where T: 'a {} - | --------------------------- required by `Foo::bar` + | --- -- required by this bound in `Foo::bar` ... LL | >::bar; | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time diff --git a/src/test/ui/substs-ppaux.verbose.stderr b/src/test/ui/substs-ppaux.verbose.stderr index 3314eb60cdea6..cafcba97b92c8 100644 --- a/src/test/ui/substs-ppaux.verbose.stderr +++ b/src/test/ui/substs-ppaux.verbose.stderr @@ -62,7 +62,7 @@ error[E0277]: the size for values of type `str` cannot be known at compilation t --> $DIR/substs-ppaux.rs:49:5 | LL | fn bar<'a, T>() where T: 'a {} - | --------------------------- required by `Foo::bar` + | --- -- required by this bound in `Foo::bar` ... LL | >::bar; | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time diff --git a/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr b/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr index 6bb6533899669..1cc704b443366 100644 --- a/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr +++ b/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `fn() -> impl std::future::Future {foo}: std::futu --> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:9:9 | LL | fn bar(f: impl Future) {} - | --------------------------------- required by `bar` + | --- ----------------- required by this bound in `bar` ... LL | bar(foo); | ^^^ diff --git a/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr b/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr index 59726c82c2377..7a49031bde7c2 100644 --- a/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr +++ b/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `fn() -> impl T {foo}: T` is not satisfied --> $DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:17:9 | LL | fn bar(f: impl T) {} - | ----------------------- required by `bar` + | --- ------- required by this bound in `bar` ... LL | bar(foo); | ^^^ diff --git a/src/test/ui/suggestions/into-str.stderr b/src/test/ui/suggestions/into-str.stderr index da5aeb63b909a..fb3e1096ad54c 100644 --- a/src/test/ui/suggestions/into-str.stderr +++ b/src/test/ui/suggestions/into-str.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `&str: std::convert::From` is --> $DIR/into-str.rs:4:5 | LL | fn foo<'a, T>(_t: T) where T: Into<&'a str> {} - | ------------------------------------------- required by `foo` + | --- ------------- required by this bound in `foo` ... LL | foo(String::new()); | ^^^ the trait `std::convert::From` is not implemented for `&str` diff --git a/src/test/ui/traits/trait-alias/trait-alias-cross-crate.stderr b/src/test/ui/traits/trait-alias/trait-alias-cross-crate.stderr index 8403b2ebaca10..10a9506bd0639 100644 --- a/src/test/ui/traits/trait-alias/trait-alias-cross-crate.stderr +++ b/src/test/ui/traits/trait-alias/trait-alias-cross-crate.stderr @@ -2,7 +2,7 @@ error[E0277]: `std::rc::Rc` cannot be sent between threads safely --> $DIR/trait-alias-cross-crate.rs:14:5 | LL | fn use_alias() {} - | --------------------------- required by `use_alias` + | --------- -------- required by this bound in `use_alias` ... LL | use_alias::>(); | ^^^^^^^^^^^^^^^^^^^^ `std::rc::Rc` cannot be sent between threads safely @@ -13,7 +13,7 @@ error[E0277]: `std::rc::Rc` cannot be shared between threads safely --> $DIR/trait-alias-cross-crate.rs:14:5 | LL | fn use_alias() {} - | --------------------------- required by `use_alias` + | --------- -------- required by this bound in `use_alias` ... LL | use_alias::>(); | ^^^^^^^^^^^^^^^^^^^^ `std::rc::Rc` cannot be shared between threads safely diff --git a/src/test/ui/traits/trait-suggest-where-clause.stderr b/src/test/ui/traits/trait-suggest-where-clause.stderr index f88dae37e48e5..0aa5f429334ef 100644 --- a/src/test/ui/traits/trait-suggest-where-clause.stderr +++ b/src/test/ui/traits/trait-suggest-where-clause.stderr @@ -3,23 +3,31 @@ error[E0277]: the size for values of type `U` cannot be known at compilation tim | LL | mem::size_of::(); | ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + ::: $SRC_DIR/libcore/mem/mod.rs:LL:COL + | +LL | pub const fn size_of() -> usize { + | - required by this bound in `std::mem::size_of` | = help: the trait `std::marker::Sized` is not implemented for `U` = note: to learn more, visit = help: consider adding a `where U: std::marker::Sized` bound - = note: required by `std::mem::size_of` error[E0277]: the size for values of type `U` cannot be known at compilation time --> $DIR/trait-suggest-where-clause.rs:10:5 | LL | mem::size_of::>(); | ^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + ::: $SRC_DIR/libcore/mem/mod.rs:LL:COL + | +LL | pub const fn size_of() -> usize { + | - required by this bound in `std::mem::size_of` | = help: within `Misc`, the trait `std::marker::Sized` is not implemented for `U` = note: to learn more, visit = help: consider adding a `where U: std::marker::Sized` bound = note: required because it appears within the type `Misc` - = note: required by `std::mem::size_of` error[E0277]: the trait bound `u64: std::convert::From` is not satisfied --> $DIR/trait-suggest-where-clause.rs:15:5 @@ -52,20 +60,28 @@ error[E0277]: the size for values of type `[T]` cannot be known at compilation t | LL | mem::size_of::<[T]>(); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + ::: $SRC_DIR/libcore/mem/mod.rs:LL:COL + | +LL | pub const fn size_of() -> usize { + | - required by this bound in `std::mem::size_of` | = help: the trait `std::marker::Sized` is not implemented for `[T]` = note: to learn more, visit - = note: required by `std::mem::size_of` error[E0277]: the size for values of type `[&U]` cannot be known at compilation time --> $DIR/trait-suggest-where-clause.rs:31:5 | LL | mem::size_of::<[&U]>(); | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + ::: $SRC_DIR/libcore/mem/mod.rs:LL:COL + | +LL | pub const fn size_of() -> usize { + | - required by this bound in `std::mem::size_of` | = help: the trait `std::marker::Sized` is not implemented for `[&U]` = note: to learn more, visit - = note: required by `std::mem::size_of` error: aborting due to 7 previous errors diff --git a/src/test/ui/traits/traits-inductive-overflow-simultaneous.stderr b/src/test/ui/traits/traits-inductive-overflow-simultaneous.stderr index b29d726fbba94..6fd6a37b22dfe 100644 --- a/src/test/ui/traits/traits-inductive-overflow-simultaneous.stderr +++ b/src/test/ui/traits/traits-inductive-overflow-simultaneous.stderr @@ -2,7 +2,7 @@ error[E0275]: overflow evaluating the requirement `{integer}: Tweedledum` --> $DIR/traits-inductive-overflow-simultaneous.rs:18:5 | LL | fn is_ee(t: T) { - | ------------------------ required by `is_ee` + | ----- ----- required by this bound in `is_ee` ... LL | is_ee(4); | ^^^^^ diff --git a/src/test/ui/traits/traits-inductive-overflow-supertrait-oibit.stderr b/src/test/ui/traits/traits-inductive-overflow-supertrait-oibit.stderr index 76d486a51e5cc..40c2c2e4c9d10 100644 --- a/src/test/ui/traits/traits-inductive-overflow-supertrait-oibit.stderr +++ b/src/test/ui/traits/traits-inductive-overflow-supertrait-oibit.stderr @@ -8,7 +8,7 @@ error[E0277]: the trait bound `NoClone: std::marker::Copy` is not satisfied --> $DIR/traits-inductive-overflow-supertrait-oibit.rs:15:23 | LL | fn copy(x: T) -> (T, T) { (x, x) } - | --------------------------------- required by `copy` + | ---- ----- required by this bound in `copy` ... LL | let (a, b) = copy(NoClone); | ^^^^^^^ the trait `std::marker::Copy` is not implemented for `NoClone` diff --git a/src/test/ui/traits/traits-inductive-overflow-supertrait.stderr b/src/test/ui/traits/traits-inductive-overflow-supertrait.stderr index 92747be7d2c6b..96a9343d4ebfb 100644 --- a/src/test/ui/traits/traits-inductive-overflow-supertrait.stderr +++ b/src/test/ui/traits/traits-inductive-overflow-supertrait.stderr @@ -2,7 +2,7 @@ error[E0275]: overflow evaluating the requirement `NoClone: Magic` --> $DIR/traits-inductive-overflow-supertrait.rs:13:18 | LL | fn copy(x: T) -> (T, T) { (x, x) } - | --------------------------------- required by `copy` + | ---- ----- required by this bound in `copy` ... LL | let (a, b) = copy(NoClone); | ^^^^ diff --git a/src/test/ui/traits/traits-inductive-overflow-two-traits.stderr b/src/test/ui/traits/traits-inductive-overflow-two-traits.stderr index 58d7fcd56c71e..447fc56434831 100644 --- a/src/test/ui/traits/traits-inductive-overflow-two-traits.stderr +++ b/src/test/ui/traits/traits-inductive-overflow-two-traits.stderr @@ -2,7 +2,7 @@ error[E0275]: overflow evaluating the requirement `*mut (): Magic` --> $DIR/traits-inductive-overflow-two-traits.rs:19:5 | LL | fn wizard() { check::<::X>(); } - | --------------------- required by `wizard` + | ------ ----- required by this bound in `wizard` ... LL | wizard::<*mut ()>(); | ^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/traits/traits-negative-impls.stderr b/src/test/ui/traits/traits-negative-impls.stderr index 022b12d256cc3..22b6d2a0c4e98 100644 --- a/src/test/ui/traits/traits-negative-impls.stderr +++ b/src/test/ui/traits/traits-negative-impls.stderr @@ -24,7 +24,7 @@ error[E0277]: `dummy1b::TestType` cannot be sent between threads safely --> $DIR/traits-negative-impls.rs:32:13 | LL | fn is_send(_: T) {} - | ------------------------- required by `is_send` + | ------- ---- required by this bound in `is_send` ... LL | is_send(TestType); | ^^^^^^^^ `dummy1b::TestType` cannot be sent between threads safely @@ -35,7 +35,7 @@ error[E0277]: `dummy1c::TestType` cannot be sent between threads safely --> $DIR/traits-negative-impls.rs:40:13 | LL | fn is_send(_: T) {} - | ------------------------- required by `is_send` + | ------- ---- required by this bound in `is_send` ... LL | is_send((8, TestType)); | ^^^^^^^^^^^^^ `dummy1c::TestType` cannot be sent between threads safely @@ -47,7 +47,7 @@ error[E0277]: `dummy2::TestType` cannot be sent between threads safely --> $DIR/traits-negative-impls.rs:48:13 | LL | fn is_send(_: T) {} - | ------------------------- required by `is_send` + | ------- ---- required by this bound in `is_send` ... LL | is_send(Box::new(TestType)); | ^^^^^^^^^^^^^^^^^^ `dummy2::TestType` cannot be sent between threads safely @@ -60,7 +60,7 @@ error[E0277]: `dummy3::TestType` cannot be sent between threads safely --> $DIR/traits-negative-impls.rs:56:13 | LL | fn is_send(_: T) {} - | ------------------------- required by `is_send` + | ------- ---- required by this bound in `is_send` ... LL | is_send(Box::new(Outer2(TestType))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `dummy3::TestType` cannot be sent between threads safely @@ -74,7 +74,7 @@ error[E0277]: `main::TestType` cannot be sent between threads safely --> $DIR/traits-negative-impls.rs:66:13 | LL | fn is_sync(_: T) {} - | ------------------------- required by `is_sync` + | ------- ---- required by this bound in `is_sync` ... LL | is_sync(Outer2(TestType)); | ^^^^^^^^^^^^^^^^ `main::TestType` cannot be sent between threads safely diff --git a/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr b/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr index 49393a8678ef8..acf309ac60872 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr +++ b/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr @@ -34,7 +34,7 @@ LL | generic_function(5i32); | ^^^^ the trait `Foo` is not implemented for `i32` ... LL | fn generic_function(t: T) {} - | --------------------------------- required by `generic_function` + | ---------------- --- required by this bound in `generic_function` error: aborting due to 4 previous errors diff --git a/src/test/ui/try-operator-on-main.stderr b/src/test/ui/try-operator-on-main.stderr index 6878cd80629bc..de75d3e313d9e 100644 --- a/src/test/ui/try-operator-on-main.stderr +++ b/src/test/ui/try-operator-on-main.stderr @@ -23,7 +23,7 @@ LL | try_trait_generic::<()>(); | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::ops::Try` is not implemented for `()` ... LL | fn try_trait_generic() -> T { - | ----------------------------------- required by `try_trait_generic` + | ----------------- --- required by this bound in `try_trait_generic` error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try` --> $DIR/try-operator-on-main.rs:22:5 diff --git a/src/test/ui/type/type-annotation-needed.rs b/src/test/ui/type/type-annotation-needed.rs index ff2342c4455c5..ddf16f7699517 100644 --- a/src/test/ui/type/type-annotation-needed.rs +++ b/src/test/ui/type/type-annotation-needed.rs @@ -1,5 +1,6 @@ fn foo>(x: i32) {} //~^ NOTE required by +//~| NOTE fn main() { foo(42); diff --git a/src/test/ui/type/type-annotation-needed.stderr b/src/test/ui/type/type-annotation-needed.stderr index 1dd2aafeb62fa..01287b727d2f8 100644 --- a/src/test/ui/type/type-annotation-needed.stderr +++ b/src/test/ui/type/type-annotation-needed.stderr @@ -1,8 +1,8 @@ error[E0283]: type annotations required: cannot resolve `_: std::convert::Into` - --> $DIR/type-annotation-needed.rs:5:5 + --> $DIR/type-annotation-needed.rs:6:5 | LL | fn foo>(x: i32) {} - | ------------------------------- required by `foo` + | --- ------------ required by this bound in `foo` ... LL | foo(42); | ^^^ diff --git a/src/test/ui/typeck/typeck-default-trait-impl-assoc-type.stderr b/src/test/ui/typeck/typeck-default-trait-impl-assoc-type.stderr index 7fb3731be23e6..b842d0ae1a248 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-assoc-type.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-assoc-type.stderr @@ -5,7 +5,7 @@ LL | is_send::(); | ^^^^^^^^^^^^^^^^^^^^^^^ `::AssocType` cannot be sent between threads safely ... LL | fn is_send() { - | -------------------- required by `is_send` + | ------- ---- required by this bound in `is_send` | = help: the trait `std::marker::Send` is not implemented for `::AssocType` = help: consider adding a `where ::AssocType: std::marker::Send` bound diff --git a/src/test/ui/typeck/typeck-default-trait-impl-constituent-types-2.stderr b/src/test/ui/typeck/typeck-default-trait-impl-constituent-types-2.stderr index 8389356fdd6f6..f060afea24e7f 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-constituent-types-2.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-constituent-types-2.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `MyS2: MyTrait` is not satisfied in `(MyS2, MyS)` --> $DIR/typeck-default-trait-impl-constituent-types-2.rs:16:5 | LL | fn is_mytrait() {} - | --------------------------- required by `is_mytrait` + | ---------- ------- required by this bound in `is_mytrait` ... LL | is_mytrait::<(MyS2, MyS)>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ within `(MyS2, MyS)`, the trait `MyTrait` is not implemented for `MyS2` diff --git a/src/test/ui/typeck/typeck-default-trait-impl-constituent-types.stderr b/src/test/ui/typeck/typeck-default-trait-impl-constituent-types.stderr index eee186feea67d..e5d275083dfe0 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-constituent-types.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-constituent-types.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `MyS2: MyTrait` is not satisfied --> $DIR/typeck-default-trait-impl-constituent-types.rs:20:5 | LL | fn is_mytrait() {} - | --------------------------- required by `is_mytrait` + | ---------- ------- required by this bound in `is_mytrait` ... LL | is_mytrait::(); | ^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `MyS2` diff --git a/src/test/ui/typeck/typeck-default-trait-impl-negation-send.stderr b/src/test/ui/typeck/typeck-default-trait-impl-negation-send.stderr index 1e6adeb430998..2f5be975c6dd7 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-negation-send.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-negation-send.stderr @@ -2,7 +2,7 @@ error[E0277]: `MyNotSendable` cannot be sent between threads safely --> $DIR/typeck-default-trait-impl-negation-send.rs:19:5 | LL | fn is_send() {} - | --------------------- required by `is_send` + | ------- ---- required by this bound in `is_send` ... LL | is_send::(); | ^^^^^^^^^^^^^^^^^^^^^^^^ `MyNotSendable` cannot be sent between threads safely diff --git a/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr b/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr index d4f8f5ad82c9e..77e04a75a25c1 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr @@ -2,7 +2,7 @@ error[E0277]: `MyNotSync` cannot be shared between threads safely --> $DIR/typeck-default-trait-impl-negation-sync.rs:33:5 | LL | fn is_sync() {} - | --------------------- required by `is_sync` + | ------- ---- required by this bound in `is_sync` ... LL | is_sync::(); | ^^^^^^^^^^^^^^^^^^^^ `MyNotSync` cannot be shared between threads safely @@ -13,7 +13,7 @@ error[E0277]: `std::cell::UnsafeCell` cannot be shared between threads safel --> $DIR/typeck-default-trait-impl-negation-sync.rs:36:5 | LL | fn is_sync() {} - | --------------------- required by `is_sync` + | ------- ---- required by this bound in `is_sync` ... LL | is_sync::(); | ^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell` cannot be shared between threads safely @@ -25,7 +25,7 @@ error[E0277]: `Managed` cannot be shared between threads safely --> $DIR/typeck-default-trait-impl-negation-sync.rs:39:5 | LL | fn is_sync() {} - | --------------------- required by `is_sync` + | ------- ---- required by this bound in `is_sync` ... LL | is_sync::(); | ^^^^^^^^^^^^^^^^^^^^^^^^ `Managed` cannot be shared between threads safely diff --git a/src/test/ui/typeck/typeck-default-trait-impl-negation.stderr b/src/test/ui/typeck/typeck-default-trait-impl-negation.stderr index e993098b2deed..09c05825190e7 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-negation.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-negation.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `ThisImplsUnsafeTrait: MyTrait` is not satisfied --> $DIR/typeck-default-trait-impl-negation.rs:21:5 | LL | fn is_my_trait() {} - | ---------------------------- required by `is_my_trait` + | ----------- ------- required by this bound in `is_my_trait` ... LL | is_my_trait::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `ThisImplsUnsafeTrait` @@ -14,7 +14,7 @@ error[E0277]: the trait bound `ThisImplsTrait: MyUnsafeTrait` is not satisfied --> $DIR/typeck-default-trait-impl-negation.rs:24:5 | LL | fn is_my_unsafe_trait() {} - | ----------------------------------------- required by `is_my_unsafe_trait` + | ------------------ ------------- required by this bound in `is_my_unsafe_trait` ... LL | is_my_unsafe_trait::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MyUnsafeTrait` is not implemented for `ThisImplsTrait` diff --git a/src/test/ui/typeck/typeck-default-trait-impl-precedence.stderr b/src/test/ui/typeck/typeck-default-trait-impl-precedence.stderr index d87a6384e5c01..1587730441820 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-precedence.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-precedence.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `u32: Signed` is not satisfied --> $DIR/typeck-default-trait-impl-precedence.rs:18:5 | LL | fn is_defaulted() { } - | ------------------------------ required by `is_defaulted` + | ------------ --------- required by this bound in `is_defaulted` ... LL | is_defaulted::<&'static u32>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Signed` is not implemented for `u32` diff --git a/src/test/ui/typeck/typeck-default-trait-impl-send-param.stderr b/src/test/ui/typeck/typeck-default-trait-impl-send-param.stderr index 5f3a5bc6e0054..46731c0fbb014 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-send-param.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-send-param.stderr @@ -5,7 +5,7 @@ LL | is_send::() | ^^^^^^^^^^^^ `T` cannot be sent between threads safely ... LL | fn is_send() { - | -------------------- required by `is_send` + | ------- ---- required by this bound in `is_send` | = help: the trait `std::marker::Send` is not implemented for `T` = help: consider adding a `where T: std::marker::Send` bound diff --git a/src/test/ui/typeck/typeck-unsafe-always-share.stderr b/src/test/ui/typeck/typeck-unsafe-always-share.stderr index 8b3032b088d0e..d08613238f866 100644 --- a/src/test/ui/typeck/typeck-unsafe-always-share.stderr +++ b/src/test/ui/typeck/typeck-unsafe-always-share.stderr @@ -2,7 +2,7 @@ error[E0277]: `std::cell::UnsafeCell>` cannot be shared betwee --> $DIR/typeck-unsafe-always-share.rs:19:10 | LL | fn test(s: T) {} - | ---------------------- required by `test` + | ---- ---- required by this bound in `test` ... LL | test(us); | ^^ `std::cell::UnsafeCell>` cannot be shared between threads safely @@ -13,7 +13,7 @@ error[E0277]: `std::cell::UnsafeCell` cannot be shared between threads s --> $DIR/typeck-unsafe-always-share.rs:23:10 | LL | fn test(s: T) {} - | ---------------------- required by `test` + | ---- ---- required by this bound in `test` ... LL | test(uns); | ^^^ `std::cell::UnsafeCell` cannot be shared between threads safely @@ -24,7 +24,7 @@ error[E0277]: `std::cell::UnsafeCell` cannot be shared between threads s --> $DIR/typeck-unsafe-always-share.rs:27:5 | LL | fn test(s: T) {} - | ---------------------- required by `test` + | ---- ---- required by this bound in `test` ... LL | test(ms); | ^^^^ `std::cell::UnsafeCell` cannot be shared between threads safely @@ -36,7 +36,7 @@ error[E0277]: `NoSync` cannot be shared between threads safely --> $DIR/typeck-unsafe-always-share.rs:30:10 | LL | fn test(s: T) {} - | ---------------------- required by `test` + | ---- ---- required by this bound in `test` ... LL | test(NoSync); | ^^^^^^ `NoSync` cannot be shared between threads safely diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.stderr index dd024b76c3ba7..6ec4063828917 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `dyn Foo<(isize,), isize, Output = ()>: Eq $DIR/unboxed-closure-sugar-default.rs:21:5 | LL | fn eq() where A : Eq { } - | -------------------------------------------- required by `eq` + | -- ----- required by this bound in `eq` ... LL | eq::, dyn Foo(isize)>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Eq>` is not implemented for `dyn Foo<(isize,), isize, Output = ()>` diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.stderr index 83754bd36ef2a..8dd32ee7f104a 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `dyn Foo<(char,), Output = ()>: Eq $DIR/unboxed-closure-sugar-equiv.rs:43:5 | LL | fn eq>() { } - | ----------------------------------- required by `eq` + | -- ----- required by this bound in `eq` ... LL | / eq::< dyn Foo<(),Output=()>, LL | | dyn Foo(char) >(); diff --git a/src/test/ui/unboxed-closures/unboxed-closures-fnmut-as-fn.stderr b/src/test/ui/unboxed-closures/unboxed-closures-fnmut-as-fn.stderr index d03397e42445c..dc7661815310d 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-fnmut-as-fn.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-fnmut-as-fn.stderr @@ -2,7 +2,7 @@ error[E0277]: expected a `std::ops::Fn<(isize,)>` closure, found `S` --> $DIR/unboxed-closures-fnmut-as-fn.rs:28:21 | LL | fn call_itisize>(f: &F, x: isize) -> isize { - | -------------------------------------------------------- required by `call_it` + | ------- ---------------- required by this bound in `call_it` ... LL | let x = call_it(&S, 22); | ^^ expected an `Fn<(isize,)>` closure, found `S` diff --git a/src/test/ui/unboxed-closures/unboxed-closures-unsafe-extern-fn.stderr b/src/test/ui/unboxed-closures/unboxed-closures-unsafe-extern-fn.stderr index bde30729a3ca3..0b86719df848a 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-unsafe-extern-fn.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-unsafe-extern-fn.stderr @@ -2,7 +2,7 @@ error[E0277]: expected a `std::ops::Fn<(&isize,)>` closure, found `for<'r> unsaf --> $DIR/unboxed-closures-unsafe-extern-fn.rs:12:21 | LL | fn call_itisize>(_: &F, _: isize) -> isize { 0 } - | --------------------------------------------------------- required by `call_it` + | ------- ----------------- required by this bound in `call_it` ... LL | let x = call_it(&square, 22); | ^^^^^^^ expected an `Fn<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}` @@ -13,7 +13,7 @@ error[E0277]: expected a `std::ops::FnOnce<(&isize,)>` closure, found `for<'r> u --> $DIR/unboxed-closures-unsafe-extern-fn.rs:12:21 | LL | fn call_itisize>(_: &F, _: isize) -> isize { 0 } - | --------------------------------------------------------- required by `call_it` + | ------- ----- required by this bound in `call_it` ... LL | let x = call_it(&square, 22); | ^^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}` @@ -24,7 +24,7 @@ error[E0277]: expected a `std::ops::FnMut<(&isize,)>` closure, found `for<'r> un --> $DIR/unboxed-closures-unsafe-extern-fn.rs:18:25 | LL | fn call_it_mutisize>(_: &mut F, _: isize) -> isize { 0 } - | -------------------------------------------------------------------- required by `call_it_mut` + | ----------- -------------------- required by this bound in `call_it_mut` ... LL | let y = call_it_mut(&mut square, 22); | ^^^^^^^^^^^ expected an `FnMut<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}` @@ -35,7 +35,7 @@ error[E0277]: expected a `std::ops::FnOnce<(&isize,)>` closure, found `for<'r> u --> $DIR/unboxed-closures-unsafe-extern-fn.rs:18:25 | LL | fn call_it_mutisize>(_: &mut F, _: isize) -> isize { 0 } - | -------------------------------------------------------------------- required by `call_it_mut` + | ----------- ----- required by this bound in `call_it_mut` ... LL | let y = call_it_mut(&mut square, 22); | ^^^^^^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}` @@ -46,7 +46,7 @@ error[E0277]: expected a `std::ops::FnOnce<(&isize,)>` closure, found `for<'r> u --> $DIR/unboxed-closures-unsafe-extern-fn.rs:24:26 | LL | fn call_it_onceisize>(_: F, _: isize) -> isize { 0 } - | ----------------------------------------------------------------- required by `call_it_once` + | ------------ ----- required by this bound in `call_it_once` ... LL | let z = call_it_once(square, 22); | ^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}` diff --git a/src/test/ui/unboxed-closures/unboxed-closures-wrong-abi.stderr b/src/test/ui/unboxed-closures/unboxed-closures-wrong-abi.stderr index 7b393b35f298d..17faf047c14e3 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-wrong-abi.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-wrong-abi.stderr @@ -2,7 +2,7 @@ error[E0277]: expected a `std::ops::Fn<(&isize,)>` closure, found `for<'r> exter --> $DIR/unboxed-closures-wrong-abi.rs:12:21 | LL | fn call_itisize>(_: &F, _: isize) -> isize { 0 } - | --------------------------------------------------------- required by `call_it` + | ------- ----------------- required by this bound in `call_it` ... LL | let x = call_it(&square, 22); | ^^^^^^^ expected an `Fn<(&isize,)>` closure, found `for<'r> extern "C" fn(&'r isize) -> isize {square}` @@ -13,7 +13,7 @@ error[E0277]: expected a `std::ops::FnOnce<(&isize,)>` closure, found `for<'r> e --> $DIR/unboxed-closures-wrong-abi.rs:12:21 | LL | fn call_itisize>(_: &F, _: isize) -> isize { 0 } - | --------------------------------------------------------- required by `call_it` + | ------- ----- required by this bound in `call_it` ... LL | let x = call_it(&square, 22); | ^^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `for<'r> extern "C" fn(&'r isize) -> isize {square}` @@ -24,7 +24,7 @@ error[E0277]: expected a `std::ops::FnMut<(&isize,)>` closure, found `for<'r> ex --> $DIR/unboxed-closures-wrong-abi.rs:18:25 | LL | fn call_it_mutisize>(_: &mut F, _: isize) -> isize { 0 } - | -------------------------------------------------------------------- required by `call_it_mut` + | ----------- -------------------- required by this bound in `call_it_mut` ... LL | let y = call_it_mut(&mut square, 22); | ^^^^^^^^^^^ expected an `FnMut<(&isize,)>` closure, found `for<'r> extern "C" fn(&'r isize) -> isize {square}` @@ -35,7 +35,7 @@ error[E0277]: expected a `std::ops::FnOnce<(&isize,)>` closure, found `for<'r> e --> $DIR/unboxed-closures-wrong-abi.rs:18:25 | LL | fn call_it_mutisize>(_: &mut F, _: isize) -> isize { 0 } - | -------------------------------------------------------------------- required by `call_it_mut` + | ----------- ----- required by this bound in `call_it_mut` ... LL | let y = call_it_mut(&mut square, 22); | ^^^^^^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `for<'r> extern "C" fn(&'r isize) -> isize {square}` @@ -46,7 +46,7 @@ error[E0277]: expected a `std::ops::FnOnce<(&isize,)>` closure, found `for<'r> e --> $DIR/unboxed-closures-wrong-abi.rs:24:26 | LL | fn call_it_onceisize>(_: F, _: isize) -> isize { 0 } - | ----------------------------------------------------------------- required by `call_it_once` + | ------------ ----- required by this bound in `call_it_once` ... LL | let z = call_it_once(square, 22); | ^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `for<'r> extern "C" fn(&'r isize) -> isize {square}` diff --git a/src/test/ui/unboxed-closures/unboxed-closures-wrong-arg-type-extern-fn.stderr b/src/test/ui/unboxed-closures/unboxed-closures-wrong-arg-type-extern-fn.stderr index 68fc0d45b9a8c..5b1d6eb5b681b 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-wrong-arg-type-extern-fn.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-wrong-arg-type-extern-fn.stderr @@ -2,7 +2,7 @@ error[E0277]: expected a `std::ops::Fn<(&isize,)>` closure, found `unsafe fn(isi --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:13:21 | LL | fn call_itisize>(_: &F, _: isize) -> isize { 0 } - | --------------------------------------------------------- required by `call_it` + | ------- ----------------- required by this bound in `call_it` ... LL | let x = call_it(&square, 22); | ^^^^^^^ expected an `Fn<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}` @@ -13,7 +13,7 @@ error[E0277]: expected a `std::ops::FnOnce<(&isize,)>` closure, found `unsafe fn --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:13:21 | LL | fn call_itisize>(_: &F, _: isize) -> isize { 0 } - | --------------------------------------------------------- required by `call_it` + | ------- ----- required by this bound in `call_it` ... LL | let x = call_it(&square, 22); | ^^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}` @@ -24,7 +24,7 @@ error[E0277]: expected a `std::ops::FnMut<(&isize,)>` closure, found `unsafe fn( --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:19:25 | LL | fn call_it_mutisize>(_: &mut F, _: isize) -> isize { 0 } - | -------------------------------------------------------------------- required by `call_it_mut` + | ----------- -------------------- required by this bound in `call_it_mut` ... LL | let y = call_it_mut(&mut square, 22); | ^^^^^^^^^^^ expected an `FnMut<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}` @@ -35,7 +35,7 @@ error[E0277]: expected a `std::ops::FnOnce<(&isize,)>` closure, found `unsafe fn --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:19:25 | LL | fn call_it_mutisize>(_: &mut F, _: isize) -> isize { 0 } - | -------------------------------------------------------------------- required by `call_it_mut` + | ----------- ----- required by this bound in `call_it_mut` ... LL | let y = call_it_mut(&mut square, 22); | ^^^^^^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}` @@ -46,7 +46,7 @@ error[E0277]: expected a `std::ops::FnOnce<(&isize,)>` closure, found `unsafe fn --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:25:26 | LL | fn call_it_onceisize>(_: F, _: isize) -> isize { 0 } - | ----------------------------------------------------------------- required by `call_it_once` + | ------------ ----- required by this bound in `call_it_once` ... LL | let z = call_it_once(square, 22); | ^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}` diff --git a/src/test/ui/unsized/unsized-bare-typaram.stderr b/src/test/ui/unsized/unsized-bare-typaram.stderr index c39c648f661c6..565d561033722 100644 --- a/src/test/ui/unsized/unsized-bare-typaram.stderr +++ b/src/test/ui/unsized/unsized-bare-typaram.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim --> $DIR/unsized-bare-typaram.rs:2:23 | LL | fn bar() { } - | ------------------ required by `bar` + | --- - required by this bound in `bar` LL | fn foo() { bar::() } | ^^^^^^^^ doesn't have a size known at compile-time | diff --git a/src/test/ui/unsized/unsized-struct.stderr b/src/test/ui/unsized/unsized-struct.stderr index 795115154e72b..0d4776ff6c25b 100644 --- a/src/test/ui/unsized/unsized-struct.stderr +++ b/src/test/ui/unsized/unsized-struct.stderr @@ -15,7 +15,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim --> $DIR/unsized-struct.rs:13:24 | LL | fn is_sized() { } - | ---------------------- required by `is_sized` + | -------- - required by this bound in `is_sized` ... LL | fn bar2() { is_sized::>() } | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time diff --git a/src/test/ui/unsized3.stderr b/src/test/ui/unsized3.stderr index f381cacadf9c0..c821a08f6b585 100644 --- a/src/test/ui/unsized3.stderr +++ b/src/test/ui/unsized3.stderr @@ -5,7 +5,7 @@ LL | f2::(x); | ^ doesn't have a size known at compile-time ... LL | fn f2(x: &X) { - | --------------- required by `f2` + | -- - required by this bound in `f2` | = help: the trait `std::marker::Sized` is not implemented for `X` = note: to learn more, visit @@ -18,7 +18,7 @@ LL | f4::(x); | ^ doesn't have a size known at compile-time ... LL | fn f4(x: &X) { - | ------------------ required by `f4` + | -- - required by this bound in `f4` | = help: the trait `std::marker::Sized` is not implemented for `X` = note: to learn more, visit @@ -28,7 +28,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized3.rs:33:8 | LL | fn f5(x: &Y) {} - | --------------- required by `f5` + | -- - required by this bound in `f5` ... LL | f5(x1); | ^^ doesn't have a size known at compile-time @@ -67,7 +67,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized3.rs:45:8 | LL | fn f5(x: &Y) {} - | --------------- required by `f5` + | -- - required by this bound in `f5` ... LL | f5(&(32, *x1)); | ^^^^^^^^^^ doesn't have a size known at compile-time diff --git a/src/test/ui/where-clauses/where-clause-constraints-are-local-for-inherent-impl.stderr b/src/test/ui/where-clauses/where-clause-constraints-are-local-for-inherent-impl.stderr index 118caf8cccec7..727c9b8e06721 100644 --- a/src/test/ui/where-clauses/where-clause-constraints-are-local-for-inherent-impl.stderr +++ b/src/test/ui/where-clauses/where-clause-constraints-are-local-for-inherent-impl.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/where-clause-constraints-are-local-for-inherent-impl.rs:13:22 | LL | fn require_copy(x: T) {} - | ------------------------------ required by `require_copy` + | ------------ ---- required by this bound in `require_copy` ... LL | require_copy(self.x); | ^^^^^^ the trait `std::marker::Copy` is not implemented for `T` diff --git a/src/test/ui/where-clauses/where-clause-constraints-are-local-for-trait-impl.stderr b/src/test/ui/where-clauses/where-clause-constraints-are-local-for-trait-impl.stderr index d1cb4e1cc7d1d..1c1937c3074db 100644 --- a/src/test/ui/where-clauses/where-clause-constraints-are-local-for-trait-impl.stderr +++ b/src/test/ui/where-clauses/where-clause-constraints-are-local-for-trait-impl.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/where-clause-constraints-are-local-for-trait-impl.rs:18:22 | LL | fn require_copy(x: T) {} - | ------------------------------ required by `require_copy` + | ------------ ---- required by this bound in `require_copy` ... LL | require_copy(self.x); | ^^^^^^ the trait `std::marker::Copy` is not implemented for `T` diff --git a/src/test/ui/where-clauses/where-clauses-unsatisfied.stderr b/src/test/ui/where-clauses/where-clauses-unsatisfied.stderr index e59d6089ea539..1c859ac648c3b 100644 --- a/src/test/ui/where-clauses/where-clauses-unsatisfied.stderr +++ b/src/test/ui/where-clauses/where-clauses-unsatisfied.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `Struct: std::cmp::Eq` is not satisfied --> $DIR/where-clauses-unsatisfied.rs:6:10 | LL | fn equal(a: &T, b: &T) -> bool where T : Eq { a == b } - | ---------------------------------------------- required by `equal` + | ----- -- required by this bound in `equal` ... LL | drop(equal(&Struct, &Struct)) | ^^^^^ the trait `std::cmp::Eq` is not implemented for `Struct` diff --git a/src/test/ui/where-clauses/where-for-self-2.stderr b/src/test/ui/where-clauses/where-for-self-2.stderr index 32dc0e7359cbe..b18b36d029d70 100644 --- a/src/test/ui/where-clauses/where-for-self-2.stderr +++ b/src/test/ui/where-clauses/where-for-self-2.stderr @@ -1,13 +1,13 @@ error[E0277]: the trait bound `for<'a> &'a _: Bar` is not satisfied --> $DIR/where-for-self-2.rs:21:5 | -LL | / fn foo(x: &T) -LL | | where for<'a> &'a T: Bar -LL | | {} - | |__- required by `foo` +LL | fn foo(x: &T) + | --- +LL | where for<'a> &'a T: Bar + | --- required by this bound in `foo` ... -LL | foo(&X); - | ^^^ the trait `for<'a> Bar` is not implemented for `&'a _` +LL | foo(&X); + | ^^^ the trait `for<'a> Bar` is not implemented for `&'a _` | = help: the following implementations were found: <&'static u32 as Bar> From c9d05aa9ceb82f31a86a548eaaffab8bdb229d76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 4 Sep 2019 17:36:01 -0700 Subject: [PATCH 55/63] Point at correct span for parenthesized types --- src/librustc/hir/lowering.rs | 5 +++- src/libsyntax/parse/parser/path.rs | 13 +++++---- .../anonymous-higher-ranked-lifetime.stderr | 22 +++++++-------- .../expect-fn-supply-fn.stderr | 6 ++-- src/test/ui/error-codes/E0214.stderr | 10 +++---- ...-gate-unboxed-closures-manual-impls.stderr | 4 +-- src/test/ui/issues/issue-23589.stderr | 10 +++---- src/test/ui/issues/issue-32995-2.stderr | 12 ++++---- src/test/ui/issues/issue-32995.stderr | 28 +++++++++---------- src/test/ui/issues/issue-39687.stderr | 4 +-- src/test/ui/issues/issue-43623.stderr | 2 +- src/test/ui/issues/issue-60283.stderr | 2 +- .../closure-arg-type-mismatch.stderr | 2 +- .../type-parameters-in-field-exprs.stderr | 12 ++++---- src/test/ui/span/macro-ty-params.stderr | 12 ++++---- .../ui/type/ascription/issue-34255-1.stderr | 4 +-- ...oxed-closure-sugar-used-on-struct-1.stderr | 4 +-- ...oxed-closure-sugar-used-on-struct-3.stderr | 10 +++---- ...nboxed-closure-sugar-used-on-struct.stderr | 4 +-- ...ong-number-number-type-parameters-1.stderr | 4 +-- ...ong-number-number-type-parameters-3.stderr | 4 +-- ...wrong-number-number-type-parameters.stderr | 8 +++--- .../unboxed-closure-sugar-wrong-trait.stderr | 4 +-- 23 files changed, 95 insertions(+), 91 deletions(-) diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 48f7fc4446505..f6b872623d789 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -1893,10 +1893,13 @@ impl<'a> LoweringContext<'a> { if let Ok(snippet) = self.sess.source_map().span_to_snippet(data.span) { // Do not suggest going from `Trait()` to `Trait<>` if data.inputs.len() > 0 { + let split = snippet.find('(').unwrap(); + let trait_name = &snippet[0..split]; + let args = &snippet[split + 1 .. snippet.len() - 1]; err.span_suggestion( data.span, "use angle brackets instead", - format!("<{}>", &snippet[1..snippet.len() - 1]), + format!("{}<{}>", trait_name, args), Applicability::MaybeIncorrect, ); } diff --git a/src/libsyntax/parse/parser/path.rs b/src/libsyntax/parse/parser/path.rs index dcd3c64801742..f6df24c05684a 100644 --- a/src/libsyntax/parse/parser/path.rs +++ b/src/libsyntax/parse/parser/path.rs @@ -129,10 +129,11 @@ impl<'a> Parser<'a> { self.parse_path(style) } - crate fn parse_path_segments(&mut self, - segments: &mut Vec, - style: PathStyle) - -> PResult<'a, ()> { + crate fn parse_path_segments( + &mut self, + segments: &mut Vec, + style: PathStyle, + ) -> PResult<'a, ()> { loop { let segment = self.parse_path_segment(style)?; if style == PathStyle::Expr { @@ -196,12 +197,12 @@ impl<'a> Parser<'a> { let (args, constraints) = self.parse_generic_args_with_leaning_angle_bracket_recovery(style, lo)?; self.expect_gt()?; - let span = lo.to(self.prev_span); + let span = ident.span.to(self.prev_span); AngleBracketedArgs { args, constraints, span }.into() } else { // `(T, U) -> R` let (inputs, _) = self.parse_paren_comma_seq(|p| p.parse_ty())?; - let span = lo.to(self.prev_span); + let span = ident.span.to(self.prev_span); let output = if self.eat(&token::RArrow) { Some(self.parse_ty_common(false, false, false)?) } else { diff --git a/src/test/ui/anonymous-higher-ranked-lifetime.stderr b/src/test/ui/anonymous-higher-ranked-lifetime.stderr index 51550e1471e72..fbe2d192d0cce 100644 --- a/src/test/ui/anonymous-higher-ranked-lifetime.stderr +++ b/src/test/ui/anonymous-higher-ranked-lifetime.stderr @@ -18,7 +18,7 @@ LL | f1(|_: (), _: ()| {}); | expected signature of `fn(&(), &()) -> _` ... LL | fn f1(_: F) where F: Fn(&(), &()) {} - | -- ---------- required by this bound in `f1` + | -- ------------ required by this bound in `f1` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:4:5 @@ -40,7 +40,7 @@ LL | f2(|_: (), _: ()| {}); | expected signature of `fn(&'a (), &()) -> _` ... LL | fn f2(_: F) where F: for<'a> Fn(&'a (), &()) {} - | -- ------------- required by this bound in `f2` + | -- --------------- required by this bound in `f2` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:6:5 @@ -62,7 +62,7 @@ LL | f3(|_: (), _: ()| {}); | expected signature of `fn(&(), &()) -> _` ... LL | fn f3<'a, F>(_: F) where F: Fn(&'a (), &()) {} - | -- ------------- required by this bound in `f3` + | -- --------------- required by this bound in `f3` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:8:5 @@ -84,7 +84,7 @@ LL | f4(|_: (), _: ()| {}); | expected signature of `fn(&(), &'r ()) -> _` ... LL | fn f4(_: F) where F: for<'r> Fn(&(), &'r ()) {} - | -- ------------- required by this bound in `f4` + | -- --------------- required by this bound in `f4` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:10:5 @@ -106,7 +106,7 @@ LL | f5(|_: (), _: ()| {}); | expected signature of `fn(&'r (), &'r ()) -> _` ... LL | fn f5(_: F) where F: for<'r> Fn(&'r (), &'r ()) {} - | -- ---------------- required by this bound in `f5` + | -- ------------------ required by this bound in `f5` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:12:5 @@ -128,7 +128,7 @@ LL | g1(|_: (), _: ()| {}); | expected signature of `fn(&(), std::boxed::Box<(dyn for<'r> std::ops::Fn(&'r ()) + 'static)>) -> _` ... LL | fn g1(_: F) where F: Fn(&(), Box) {} - | -- ----------------------- required by this bound in `g1` + | -- ------------------------- required by this bound in `g1` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:14:5 @@ -150,7 +150,7 @@ LL | g2(|_: (), _: ()| {}); | expected signature of `fn(&(), for<'r> fn(&'r ())) -> _` ... LL | fn g2(_: F) where F: Fn(&(), fn(&())) {} - | -- -------------- required by this bound in `g2` + | -- ---------------- required by this bound in `g2` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:16:5 @@ -172,7 +172,7 @@ LL | g3(|_: (), _: ()| {}); | expected signature of `fn(&'s (), std::boxed::Box<(dyn for<'r> std::ops::Fn(&'r ()) + 'static)>) -> _` ... LL | fn g3(_: F) where F: for<'s> Fn(&'s (), Box) {} - | -- -------------------------- required by this bound in `g3` + | -- ---------------------------- required by this bound in `g3` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:18:5 @@ -194,7 +194,7 @@ LL | g4(|_: (), _: ()| {}); | expected signature of `fn(&(), for<'r> fn(&'r ())) -> _` ... LL | fn g4(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {} - | -- ------------------------- required by this bound in `g4` + | -- --------------------------- required by this bound in `g4` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:20:5 @@ -216,7 +216,7 @@ LL | h1(|_: (), _: (), _: (), _: ()| {}); | expected signature of `fn(&(), std::boxed::Box<(dyn for<'r> std::ops::Fn(&'r ()) + 'static)>, &(), for<'r, 's> fn(&'r (), &'s ())) -> _` ... LL | fn h1(_: F) where F: Fn(&(), Box, &(), fn(&(), &())) {} - | -- ------------------------------------------ required by this bound in `h1` + | -- -------------------------------------------- required by this bound in `h1` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:22:5 @@ -238,7 +238,7 @@ LL | h2(|_: (), _: (), _: (), _: ()| {}); | expected signature of `fn(&(), std::boxed::Box<(dyn for<'r> std::ops::Fn(&'r ()) + 'static)>, &'t0 (), for<'r, 's> fn(&'r (), &'s ())) -> _` ... LL | fn h2(_: F) where F: for<'t0> Fn(&(), Box, &'t0 (), fn(&(), &())) {} - | -- ---------------------------------------------- required by this bound in `h2` + | -- ------------------------------------------------ required by this bound in `h2` error: aborting due to 22 previous errors diff --git a/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr b/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr index 6fadea31f7e69..ac4666fe36de6 100644 --- a/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr +++ b/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr @@ -42,7 +42,7 @@ error[E0631]: type mismatch in closure arguments LL | fn with_closure_expecting_fn_with_free_region(_: F) | ------------------------------------------ LL | where F: for<'a> FnOnce(fn(&'a u32), &i32) - | ------------------- required by this bound in `with_closure_expecting_fn_with_free_region` + | ------------------------- required by this bound in `with_closure_expecting_fn_with_free_region` ... LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------- found signature of `fn(for<'r> fn(&'r u32), _) -> _` @@ -55,7 +55,7 @@ error[E0631]: type mismatch in closure arguments LL | fn with_closure_expecting_fn_with_bound_region(_: F) | ------------------------------------------- LL | where F: FnOnce(fn(&u32), &i32) - | ---------------- required by this bound in `with_closure_expecting_fn_with_bound_region` + | ---------------------- required by this bound in `with_closure_expecting_fn_with_bound_region` ... LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------------------- found signature of `fn(fn(&'x u32), _) -> _` @@ -68,7 +68,7 @@ error[E0631]: type mismatch in closure arguments LL | fn with_closure_expecting_fn_with_bound_region(_: F) | ------------------------------------------- LL | where F: FnOnce(fn(&u32), &i32) - | ---------------- required by this bound in `with_closure_expecting_fn_with_bound_region` + | ---------------------- required by this bound in `with_closure_expecting_fn_with_bound_region` ... LL | with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --------------- found signature of `for<'r> fn(fn(&'r u32), _) -> _` diff --git a/src/test/ui/error-codes/E0214.stderr b/src/test/ui/error-codes/E0214.stderr index a10f2c00578c6..bcbd3a91cb951 100644 --- a/src/test/ui/error-codes/E0214.stderr +++ b/src/test/ui/error-codes/E0214.stderr @@ -1,11 +1,11 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/E0214.rs:2:15 + --> $DIR/E0214.rs:2:12 | LL | let v: Vec(&str) = vec!["foo"]; - | ^^^^^^ - | | - | only `Fn` traits may use parentheses - | help: use angle brackets instead: `<&str>` + | ^^^^^^^^^ + | | + | only `Fn` traits may use parentheses + | help: use angle brackets instead: `Vec<&str>` error: aborting due to previous error diff --git a/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr b/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr index fc4317b316a37..c05379c71eeaf 100644 --- a/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr +++ b/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr @@ -44,10 +44,10 @@ LL | impl Fn<()> for Foo { = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0229]: associated type bindings are not allowed here - --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:15:12 + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:15:6 | LL | impl FnOnce() for Foo1 { - | ^^ associated type not allowed here + | ^^^^^^^^ associated type not allowed here error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:21:6 diff --git a/src/test/ui/issues/issue-23589.stderr b/src/test/ui/issues/issue-23589.stderr index d169fdfe2dddd..c3b419fe939cb 100644 --- a/src/test/ui/issues/issue-23589.stderr +++ b/src/test/ui/issues/issue-23589.stderr @@ -1,11 +1,11 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-23589.rs:2:15 + --> $DIR/issue-23589.rs:2:12 | LL | let v: Vec(&str) = vec!['1', '2']; - | ^^^^^^ - | | - | only `Fn` traits may use parentheses - | help: use angle brackets instead: `<&str>` + | ^^^^^^^^^ + | | + | only `Fn` traits may use parentheses + | help: use angle brackets instead: `Vec<&str>` error[E0308]: mismatched types --> $DIR/issue-23589.rs:2:29 diff --git a/src/test/ui/issues/issue-32995-2.stderr b/src/test/ui/issues/issue-32995-2.stderr index 4a580b09bf372..976e3064db64b 100644 --- a/src/test/ui/issues/issue-32995-2.stderr +++ b/src/test/ui/issues/issue-32995-2.stderr @@ -1,27 +1,27 @@ error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995-2.rs:4:28 + --> $DIR/issue-32995-2.rs:4:22 | LL | { fn f() {} } - | ^^ + | ^^^^^^^^ | = note: `#[deny(parenthesized_params_in_types_and_modules)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42238 error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995-2.rs:8:35 + --> $DIR/issue-32995-2.rs:8:29 | LL | { fn f() -> impl ::std::marker()::Send { } } - | ^^ + | ^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42238 error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995-2.rs:16:19 + --> $DIR/issue-32995-2.rs:16:13 | LL | impl ::std::marker()::Copy for X {} - | ^^ + | ^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42238 diff --git a/src/test/ui/issues/issue-32995.stderr b/src/test/ui/issues/issue-32995.stderr index 59d93ece06742..724e82a59dc35 100644 --- a/src/test/ui/issues/issue-32995.stderr +++ b/src/test/ui/issues/issue-32995.stderr @@ -1,63 +1,63 @@ error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:4:17 + --> $DIR/issue-32995.rs:4:12 | LL | let x: usize() = 1; - | ^^ + | ^^^^^^^ | = note: `#[deny(parenthesized_params_in_types_and_modules)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42238 error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:8:24 + --> $DIR/issue-32995.rs:8:19 | LL | let b: ::std::boxed()::Box<_> = Box::new(1); - | ^^ + | ^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42238 error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:12:25 + --> $DIR/issue-32995.rs:12:20 | LL | let p = ::std::str::()::from_utf8(b"foo").unwrap(); - | ^^ + | ^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42238 error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:16:36 + --> $DIR/issue-32995.rs:16:25 | LL | let p = ::std::str::from_utf8::()(b"foo").unwrap(); - | ^^ + | ^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42238 error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:20:35 + --> $DIR/issue-32995.rs:20:29 | LL | let o : Box = Box::new(1); - | ^^ + | ^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42238 error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:24:41 + --> $DIR/issue-32995.rs:24:35 | LL | let o : Box = Box::new(1); - | ^^ + | ^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42238 error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:30:14 + --> $DIR/issue-32995.rs:30:13 | LL | let d : X() = Default::default(); - | ^^ + | ^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42238 diff --git a/src/test/ui/issues/issue-39687.stderr b/src/test/ui/issues/issue-39687.stderr index 886de1d6faffc..b1b3041ea0275 100644 --- a/src/test/ui/issues/issue-39687.stderr +++ b/src/test/ui/issues/issue-39687.stderr @@ -1,8 +1,8 @@ error[E0229]: associated type bindings are not allowed here - --> $DIR/issue-39687.rs:4:16 + --> $DIR/issue-39687.rs:4:14 | LL | ::call; - | ^^ associated type not allowed here + | ^^^^ associated type not allowed here error: aborting due to previous error diff --git a/src/test/ui/issues/issue-43623.stderr b/src/test/ui/issues/issue-43623.stderr index 210d831abf0de..2c57b8585d924 100644 --- a/src/test/ui/issues/issue-43623.stderr +++ b/src/test/ui/issues/issue-43623.stderr @@ -19,7 +19,7 @@ LL | pub fn break_me(f: F) | -------- LL | where T: for<'b> Trait<'b>, LL | F: for<'b> FnMut(>::Assoc) { - | ------------------------- required by this bound in `break_me` + | ------------------------------ required by this bound in `break_me` LL | break_me::; | ^^^^^^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'b, found concrete lifetime diff --git a/src/test/ui/issues/issue-60283.stderr b/src/test/ui/issues/issue-60283.stderr index dc7952200b18e..69c1d85e4e12d 100644 --- a/src/test/ui/issues/issue-60283.stderr +++ b/src/test/ui/issues/issue-60283.stderr @@ -20,7 +20,7 @@ LL | pub fn foo(_: T, _: F) | --- LL | where T: for<'a> Trait<'a>, LL | F: for<'a> FnMut(>::Item) {} - | ------------------------ required by this bound in `foo` + | ----------------------------- required by this bound in `foo` ... LL | foo((), drop) | ^^^ expected bound lifetime parameter 'a, found concrete lifetime diff --git a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr b/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr index a731891bf764e..85cad61210ebf 100644 --- a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr @@ -38,7 +38,7 @@ error[E0271]: type mismatch resolving `for<'r> $DIR/closure-arg-type-mismatch.rs:10:5 | LL | fn baz(_: F) {} - | --- ----------- required by this bound in `baz` + | --- ------------- required by this bound in `baz` LL | fn _test<'a>(f: fn(*mut &'a u32)) { LL | baz(f); | ^^^ expected bound lifetime parameter, found concrete lifetime diff --git a/src/test/ui/parser/type-parameters-in-field-exprs.stderr b/src/test/ui/parser/type-parameters-in-field-exprs.stderr index 2183c74da0acb..dd8a3feb04954 100644 --- a/src/test/ui/parser/type-parameters-in-field-exprs.stderr +++ b/src/test/ui/parser/type-parameters-in-field-exprs.stderr @@ -1,20 +1,20 @@ error: field expressions may not have generic arguments - --> $DIR/type-parameters-in-field-exprs.rs:13:10 + --> $DIR/type-parameters-in-field-exprs.rs:13:7 | LL | f.x::; - | ^^^^^^^ + | ^^^^^^^^^^ error: field expressions may not have generic arguments - --> $DIR/type-parameters-in-field-exprs.rs:15:10 + --> $DIR/type-parameters-in-field-exprs.rs:15:7 | LL | f.x::<>; - | ^^ + | ^^^^^ error: field expressions may not have generic arguments - --> $DIR/type-parameters-in-field-exprs.rs:17:10 + --> $DIR/type-parameters-in-field-exprs.rs:17:7 | LL | f.x::(); - | ^^ + | ^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/span/macro-ty-params.stderr b/src/test/ui/span/macro-ty-params.stderr index 39b3edc67033d..139247c0388a9 100644 --- a/src/test/ui/span/macro-ty-params.stderr +++ b/src/test/ui/span/macro-ty-params.stderr @@ -1,14 +1,14 @@ error: generic arguments in macro path - --> $DIR/macro-ty-params.rs:10:10 + --> $DIR/macro-ty-params.rs:10:5 | LL | foo::!(); - | ^^^ + | ^^^^^^^^ error: generic arguments in macro path - --> $DIR/macro-ty-params.rs:11:10 + --> $DIR/macro-ty-params.rs:11:5 | LL | foo::<>!(); - | ^^ + | ^^^^^^^ error: unexpected generic arguments in path --> $DIR/macro-ty-params.rs:12:8 @@ -17,10 +17,10 @@ LL | m!(Default<>); | ^^^^^^^^^ error: generic arguments in macro path - --> $DIR/macro-ty-params.rs:12:15 + --> $DIR/macro-ty-params.rs:12:8 | LL | m!(Default<>); - | ^^ + | ^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/src/test/ui/type/ascription/issue-34255-1.stderr b/src/test/ui/type/ascription/issue-34255-1.stderr index 195b393b2f609..0d0acfde88605 100644 --- a/src/test/ui/type/ascription/issue-34255-1.stderr +++ b/src/test/ui/type/ascription/issue-34255-1.stderr @@ -5,10 +5,10 @@ LL | input_cells: Vec::new() | ^^^^^^^^^^^ a field by this name exists in `Self` error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-34255-1.rs:7:30 + --> $DIR/issue-34255-1.rs:7:27 | LL | input_cells: Vec::new() - | ^^ + | ^^^^^ | = note: `#[deny(parenthesized_params_in_types_and_modules)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-used-on-struct-1.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-used-on-struct-1.stderr index 81095826f38ae..32619420f6d53 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-used-on-struct-1.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-used-on-struct-1.stderr @@ -1,8 +1,8 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/unboxed-closure-sugar-used-on-struct-1.rs:8:19 + --> $DIR/unboxed-closure-sugar-used-on-struct-1.rs:8:16 | LL | let x: Box = panic!(); - | ^^ only `Fn` traits may use parentheses + | ^^^^^ only `Fn` traits may use parentheses error[E0107]: wrong number of type arguments: expected 1, found 0 --> $DIR/unboxed-closure-sugar-used-on-struct-1.rs:8:16 diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-used-on-struct-3.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-used-on-struct-3.stderr index 7d05ca55ffdb0..f5cf6db30f99c 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-used-on-struct-3.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-used-on-struct-3.stderr @@ -1,11 +1,11 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/unboxed-closure-sugar-used-on-struct-3.rs:14:18 + --> $DIR/unboxed-closure-sugar-used-on-struct-3.rs:14:13 | LL | let b = Bar::(isize, usize)::new(); // OK too (for the parser) - | ^^^^^^^^^^^^^^ - | | - | only `Fn` traits may use parentheses - | help: use angle brackets instead: `` + | ^^^^^^^^^^^^^^^^^^^ + | | + | only `Fn` traits may use parentheses + | help: use angle brackets instead: `Bar::` error: aborting due to previous error diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-used-on-struct.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-used-on-struct.stderr index 3c78d9f9135cf..ba93b60dad878 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-used-on-struct.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-used-on-struct.stderr @@ -1,8 +1,8 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/unboxed-closure-sugar-used-on-struct.rs:7:18 + --> $DIR/unboxed-closure-sugar-used-on-struct.rs:7:15 | LL | fn foo(b: Box) { - | ^^ only `Fn` traits may use parentheses + | ^^^^^ only `Fn` traits may use parentheses error[E0107]: wrong number of type arguments: expected 1, found 0 --> $DIR/unboxed-closure-sugar-used-on-struct.rs:7:15 diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.stderr index c59082932ddfe..59e7bc8c832d6 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.stderr @@ -1,8 +1,8 @@ error[E0220]: associated type `Output` not found for `One<()>` - --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs:5:19 + --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs:5:16 | LL | fn foo(_: &dyn One()) - | ^^ associated type `Output` not found + | ^^^^^ associated type `Output` not found error: aborting due to previous error diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr index 6c61e74584a50..f42ac38d370d5 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr @@ -5,10 +5,10 @@ LL | fn foo(_: &dyn Three()) | ^^^^^^^ expected 3 type arguments error[E0220]: associated type `Output` not found for `Three<(), [type error], [type error]>` - --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs:5:21 + --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs:5:16 | LL | fn foo(_: &dyn Three()) - | ^^ associated type `Output` not found + | ^^^^^^^ associated type `Output` not found error: aborting due to 2 previous errors diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.stderr index b96e2cbc36bb4..8185a798e7b65 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.stderr @@ -1,14 +1,14 @@ error[E0107]: wrong number of type arguments: expected 0, found 1 - --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:5:19 + --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:5:15 | LL | fn foo(_: dyn Zero()) - | ^^ unexpected type argument + | ^^^^^^ unexpected type argument error[E0220]: associated type `Output` not found for `Zero` - --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:5:19 + --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:5:15 | LL | fn foo(_: dyn Zero()) - | ^^ associated type `Output` not found + | ^^^^^^ associated type `Output` not found error: aborting due to 2 previous errors diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-trait.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-trait.stderr index bd707a8508a7d..c81402a3dcc00 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-trait.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-trait.stderr @@ -1,8 +1,8 @@ error[E0107]: wrong number of type arguments: expected 0, found 1 - --> $DIR/unboxed-closure-sugar-wrong-trait.rs:5:13 + --> $DIR/unboxed-closure-sugar-wrong-trait.rs:5:8 | LL | fn f isize>(x: F) {} - | ^^^^^^^ unexpected type argument + | ^^^^^^^^^^^^ unexpected type argument error[E0220]: associated type `Output` not found for `Trait` --> $DIR/unboxed-closure-sugar-wrong-trait.rs:5:24 From b21408527a77136af7aed22ffbe256a6116ddc4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 4 Sep 2019 23:41:51 -0700 Subject: [PATCH 56/63] review comments --- src/librustc/hir/mod.rs | 3 +- src/librustc_typeck/check/mod.rs | 41 ++++++++++--------- src/libsyntax/parse/parser/path.rs | 2 +- .../type-parameters-in-field-exprs.stderr | 8 ++-- src/test/ui/span/macro-ty-params.stderr | 12 +++--- 5 files changed, 34 insertions(+), 32 deletions(-) diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 4f942a22cb8ae..92a8c00804733 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -2751,9 +2751,8 @@ pub enum Node<'hir> { Crate, } -impl<'hir> Node<'hir> { +impl Node<'_> { pub fn ident(&self) -> Option { - match self { Node::TraitItem(TraitItem { ident, .. }) | Node::ImplItem(ImplItem { ident, .. }) | diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 743e6661247b6..edea91c717ef7 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4736,25 +4736,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // First, store the "user substs" for later. self.write_user_type_annotation_from_substs(hir_id, def_id, substs, user_self_ty); - // Add all the obligations that are required, substituting and - // normalized appropriately. - let (bounds, spans) = self.instantiate_bounds(span, def_id, &substs); - - for (i, mut obligation) in traits::predicates_for_generics( - traits::ObligationCause::new( - span, - self.body_id, - traits::ItemObligation(def_id), - ), - self.param_env, - &bounds, - ).into_iter().enumerate() { - // This makes the error point at the bound, but we want to point at the argument - if let Some(span) = spans.get(i) { - obligation.cause.code = traits::BindingObligation(def_id, *span); - } - self.register_predicate(obligation); - } + self.add_required_obligations(span, def_id, &substs); // Substitute the values for the type parameters into the type of // the referenced item. @@ -4791,6 +4773,27 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { (ty_substituted, res) } + /// Add all the obligations that are required, substituting and normalized appropriately. + fn add_required_obligations(&self, span: Span, def_id: DefId, substs: &SubstsRef<'tcx>) { + let (bounds, spans) = self.instantiate_bounds(span, def_id, &substs); + + for (i, mut obligation) in traits::predicates_for_generics( + traits::ObligationCause::new( + span, + self.body_id, + traits::ItemObligation(def_id), + ), + self.param_env, + &bounds, + ).into_iter().enumerate() { + // This makes the error point at the bound, but we want to point at the argument + if let Some(span) = spans.get(i) { + obligation.cause.code = traits::BindingObligation(def_id, *span); + } + self.register_predicate(obligation); + } + } + fn check_rustc_args_require_const(&self, def_id: DefId, hir_id: hir::HirId, diff --git a/src/libsyntax/parse/parser/path.rs b/src/libsyntax/parse/parser/path.rs index f6df24c05684a..87839f8c70ee8 100644 --- a/src/libsyntax/parse/parser/path.rs +++ b/src/libsyntax/parse/parser/path.rs @@ -197,7 +197,7 @@ impl<'a> Parser<'a> { let (args, constraints) = self.parse_generic_args_with_leaning_angle_bracket_recovery(style, lo)?; self.expect_gt()?; - let span = ident.span.to(self.prev_span); + let span = lo.to(self.prev_span); AngleBracketedArgs { args, constraints, span }.into() } else { // `(T, U) -> R` diff --git a/src/test/ui/parser/type-parameters-in-field-exprs.stderr b/src/test/ui/parser/type-parameters-in-field-exprs.stderr index dd8a3feb04954..8f32fb0eca106 100644 --- a/src/test/ui/parser/type-parameters-in-field-exprs.stderr +++ b/src/test/ui/parser/type-parameters-in-field-exprs.stderr @@ -1,14 +1,14 @@ error: field expressions may not have generic arguments - --> $DIR/type-parameters-in-field-exprs.rs:13:7 + --> $DIR/type-parameters-in-field-exprs.rs:13:10 | LL | f.x::; - | ^^^^^^^^^^ + | ^^^^^^^ error: field expressions may not have generic arguments - --> $DIR/type-parameters-in-field-exprs.rs:15:7 + --> $DIR/type-parameters-in-field-exprs.rs:15:10 | LL | f.x::<>; - | ^^^^^ + | ^^ error: field expressions may not have generic arguments --> $DIR/type-parameters-in-field-exprs.rs:17:7 diff --git a/src/test/ui/span/macro-ty-params.stderr b/src/test/ui/span/macro-ty-params.stderr index 139247c0388a9..39b3edc67033d 100644 --- a/src/test/ui/span/macro-ty-params.stderr +++ b/src/test/ui/span/macro-ty-params.stderr @@ -1,14 +1,14 @@ error: generic arguments in macro path - --> $DIR/macro-ty-params.rs:10:5 + --> $DIR/macro-ty-params.rs:10:10 | LL | foo::!(); - | ^^^^^^^^ + | ^^^ error: generic arguments in macro path - --> $DIR/macro-ty-params.rs:11:5 + --> $DIR/macro-ty-params.rs:11:10 | LL | foo::<>!(); - | ^^^^^^^ + | ^^ error: unexpected generic arguments in path --> $DIR/macro-ty-params.rs:12:8 @@ -17,10 +17,10 @@ LL | m!(Default<>); | ^^^^^^^^^ error: generic arguments in macro path - --> $DIR/macro-ty-params.rs:12:8 + --> $DIR/macro-ty-params.rs:12:15 | LL | m!(Default<>); - | ^^^^^^^^^ + | ^^ error: aborting due to 4 previous errors From f81734bcaa9688bef78b5ef35c7d134edc0b41f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 16 Sep 2019 11:25:32 -0700 Subject: [PATCH 57/63] ignore musl target in tests to avoid issues with output differences --- src/etc/generate-deriving-span-tests.py | 2 ++ src/test/ui/async-await/issues/issue-62009-1.rs | 2 ++ .../ui/async-await/issues/issue-62009-1.stderr | 12 ++++++------ src/test/ui/closures/closure-move-sync.rs | 2 ++ src/test/ui/closures/closure-move-sync.stderr | 8 ++++---- .../derives-span-Hash-enum-struct-variant.rs | 2 ++ .../derives-span-Hash-enum-struct-variant.stderr | 2 +- src/test/ui/derives/derives-span-Hash-enum.rs | 2 ++ src/test/ui/derives/derives-span-Hash-enum.stderr | 2 +- src/test/ui/derives/derives-span-Hash-struct.rs | 2 ++ .../ui/derives/derives-span-Hash-struct.stderr | 2 +- .../ui/derives/derives-span-Hash-tuple-struct.rs | 2 ++ .../derives/derives-span-Hash-tuple-struct.stderr | 2 +- .../ui/interior-mutability/interior-mutability.rs | 2 ++ .../interior-mutability/interior-mutability.stderr | 4 ++-- src/test/ui/issues/issue-21160.rs | 2 ++ src/test/ui/issues/issue-21160.stderr | 2 +- src/test/ui/no-send-res-ports.rs | 2 ++ src/test/ui/no-send-res-ports.stderr | 6 +++--- .../termination-trait-test-wrong-type.rs | 2 ++ .../termination-trait-test-wrong-type.stderr | 2 +- src/test/ui/traits/trait-suggest-where-clause.rs | 2 ++ .../ui/traits/trait-suggest-where-clause.stderr | 14 +++++++------- 23 files changed, 52 insertions(+), 28 deletions(-) diff --git a/src/etc/generate-deriving-span-tests.py b/src/etc/generate-deriving-span-tests.py index 1c525101c76f6..4af67039fd877 100755 --- a/src/etc/generate-deriving-span-tests.py +++ b/src/etc/generate-deriving-span-tests.py @@ -14,6 +14,8 @@ os.path.join(os.path.dirname(__file__), '../test/ui/derives/')) TEMPLATE = """\ +// ignore-musl +// ^ due to stderr output differences // This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' {error_deriving} diff --git a/src/test/ui/async-await/issues/issue-62009-1.rs b/src/test/ui/async-await/issues/issue-62009-1.rs index 3ee7ab2e9d12f..007ed4efa6981 100644 --- a/src/test/ui/async-await/issues/issue-62009-1.rs +++ b/src/test/ui/async-await/issues/issue-62009-1.rs @@ -1,4 +1,6 @@ // edition:2018 +// ignore-musl +// ^ due to stderr output differences async fn print_dur() {} diff --git a/src/test/ui/async-await/issues/issue-62009-1.stderr b/src/test/ui/async-await/issues/issue-62009-1.stderr index 3d8028635f5a5..f63eaa4c48a97 100644 --- a/src/test/ui/async-await/issues/issue-62009-1.stderr +++ b/src/test/ui/async-await/issues/issue-62009-1.stderr @@ -1,5 +1,5 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/issue-62009-1.rs:6:5 + --> $DIR/issue-62009-1.rs:8:5 | LL | fn main() { | ---- this is not `async` @@ -7,7 +7,7 @@ LL | async { let (); }.await; | ^^^^^^^^^^^^^^^^^^^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/issue-62009-1.rs:8:5 + --> $DIR/issue-62009-1.rs:10:5 | LL | fn main() { | ---- this is not `async` @@ -19,7 +19,7 @@ LL | | }.await; | |___________^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/issue-62009-1.rs:12:5 + --> $DIR/issue-62009-1.rs:14:5 | LL | fn main() { | ---- this is not `async` @@ -27,11 +27,11 @@ LL | fn main() { LL | (|_| 2333).await; | ^^^^^^^^^^^^^^^^ only allowed inside `async` functions and blocks -error[E0277]: the trait bound `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]: std::future::Future` is not satisfied - --> $DIR/issue-62009-1.rs:12:5 +error[E0277]: the trait bound `[closure@$DIR/issue-62009-1.rs:14:5: 14:15]: std::future::Future` is not satisfied + --> $DIR/issue-62009-1.rs:14:5 | LL | (|_| 2333).await; - | ^^^^^^^^^^^^^^^^ the trait `std::future::Future` is not implemented for `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]` + | ^^^^^^^^^^^^^^^^ the trait `std::future::Future` is not implemented for `[closure@$DIR/issue-62009-1.rs:14:5: 14:15]` | ::: $SRC_DIR/libstd/future.rs:LL:COL | diff --git a/src/test/ui/closures/closure-move-sync.rs b/src/test/ui/closures/closure-move-sync.rs index 580cd1af4f303..4cb6358864fca 100644 --- a/src/test/ui/closures/closure-move-sync.rs +++ b/src/test/ui/closures/closure-move-sync.rs @@ -1,3 +1,5 @@ +// ignore-musl +// ^ due to stderr output differences use std::thread; use std::sync::mpsc::channel; diff --git a/src/test/ui/closures/closure-move-sync.stderr b/src/test/ui/closures/closure-move-sync.stderr index aaa5f76233f91..f676df9c559eb 100644 --- a/src/test/ui/closures/closure-move-sync.stderr +++ b/src/test/ui/closures/closure-move-sync.stderr @@ -1,5 +1,5 @@ error[E0277]: `std::sync::mpsc::Receiver<()>` cannot be shared between threads safely - --> $DIR/closure-move-sync.rs:6:13 + --> $DIR/closure-move-sync.rs:8:13 | LL | let t = thread::spawn(|| { | ^^^^^^^^^^^^^ `std::sync::mpsc::Receiver<()>` cannot be shared between threads safely @@ -11,10 +11,10 @@ LL | F: FnOnce() -> T, F: Send + 'static, T: Send + 'static | = help: the trait `std::marker::Sync` is not implemented for `std::sync::mpsc::Receiver<()>` = note: required because of the requirements on the impl of `std::marker::Send` for `&std::sync::mpsc::Receiver<()>` - = note: required because it appears within the type `[closure@$DIR/closure-move-sync.rs:6:27: 9:6 recv:&std::sync::mpsc::Receiver<()>]` + = note: required because it appears within the type `[closure@$DIR/closure-move-sync.rs:8:27: 11:6 recv:&std::sync::mpsc::Receiver<()>]` error[E0277]: `std::sync::mpsc::Sender<()>` cannot be shared between threads safely - --> $DIR/closure-move-sync.rs:18:5 + --> $DIR/closure-move-sync.rs:20:5 | LL | thread::spawn(|| tx.send(()).unwrap()); | ^^^^^^^^^^^^^ `std::sync::mpsc::Sender<()>` cannot be shared between threads safely @@ -26,7 +26,7 @@ LL | F: FnOnce() -> T, F: Send + 'static, T: Send + 'static | = help: the trait `std::marker::Sync` is not implemented for `std::sync::mpsc::Sender<()>` = note: required because of the requirements on the impl of `std::marker::Send` for `&std::sync::mpsc::Sender<()>` - = note: required because it appears within the type `[closure@$DIR/closure-move-sync.rs:18:19: 18:42 tx:&std::sync::mpsc::Sender<()>]` + = note: required because it appears within the type `[closure@$DIR/closure-move-sync.rs:20:19: 20:42 tx:&std::sync::mpsc::Sender<()>]` error: aborting due to 2 previous errors diff --git a/src/test/ui/derives/derives-span-Hash-enum-struct-variant.rs b/src/test/ui/derives/derives-span-Hash-enum-struct-variant.rs index 3018a7b6d03ee..516a15b55bf1d 100644 --- a/src/test/ui/derives/derives-span-Hash-enum-struct-variant.rs +++ b/src/test/ui/derives/derives-span-Hash-enum-struct-variant.rs @@ -1,3 +1,5 @@ +// ignore-musl +// ^ due to stderr output differences // This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' diff --git a/src/test/ui/derives/derives-span-Hash-enum-struct-variant.stderr b/src/test/ui/derives/derives-span-Hash-enum-struct-variant.stderr index 4752ef3713d42..708ebca9fb153 100644 --- a/src/test/ui/derives/derives-span-Hash-enum-struct-variant.stderr +++ b/src/test/ui/derives/derives-span-Hash-enum-struct-variant.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `Error: std::hash::Hash` is not satisfied - --> $DIR/derives-span-Hash-enum-struct-variant.rs:9:6 + --> $DIR/derives-span-Hash-enum-struct-variant.rs:11:6 | LL | x: Error | ^^^^^^^^ the trait `std::hash::Hash` is not implemented for `Error` diff --git a/src/test/ui/derives/derives-span-Hash-enum.rs b/src/test/ui/derives/derives-span-Hash-enum.rs index bb656e5c2fe3c..ba12deaf98137 100644 --- a/src/test/ui/derives/derives-span-Hash-enum.rs +++ b/src/test/ui/derives/derives-span-Hash-enum.rs @@ -1,3 +1,5 @@ +// ignore-musl +// ^ due to stderr output differences // This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' diff --git a/src/test/ui/derives/derives-span-Hash-enum.stderr b/src/test/ui/derives/derives-span-Hash-enum.stderr index efaa679c410be..dc171cbe5dd13 100644 --- a/src/test/ui/derives/derives-span-Hash-enum.stderr +++ b/src/test/ui/derives/derives-span-Hash-enum.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `Error: std::hash::Hash` is not satisfied - --> $DIR/derives-span-Hash-enum.rs:9:6 + --> $DIR/derives-span-Hash-enum.rs:11:6 | LL | Error | ^^^^^ the trait `std::hash::Hash` is not implemented for `Error` diff --git a/src/test/ui/derives/derives-span-Hash-struct.rs b/src/test/ui/derives/derives-span-Hash-struct.rs index fa5e2af6be870..b9e7e04f4cfed 100644 --- a/src/test/ui/derives/derives-span-Hash-struct.rs +++ b/src/test/ui/derives/derives-span-Hash-struct.rs @@ -1,3 +1,5 @@ +// ignore-musl +// ^ due to stderr output differences // This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' diff --git a/src/test/ui/derives/derives-span-Hash-struct.stderr b/src/test/ui/derives/derives-span-Hash-struct.stderr index a92103032ee1f..429449b82bf64 100644 --- a/src/test/ui/derives/derives-span-Hash-struct.stderr +++ b/src/test/ui/derives/derives-span-Hash-struct.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `Error: std::hash::Hash` is not satisfied - --> $DIR/derives-span-Hash-struct.rs:8:5 + --> $DIR/derives-span-Hash-struct.rs:10:5 | LL | x: Error | ^^^^^^^^ the trait `std::hash::Hash` is not implemented for `Error` diff --git a/src/test/ui/derives/derives-span-Hash-tuple-struct.rs b/src/test/ui/derives/derives-span-Hash-tuple-struct.rs index 3822bce1466ea..bb271e60745a5 100644 --- a/src/test/ui/derives/derives-span-Hash-tuple-struct.rs +++ b/src/test/ui/derives/derives-span-Hash-tuple-struct.rs @@ -1,3 +1,5 @@ +// ignore-musl +// ^ due to stderr output differences // This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' diff --git a/src/test/ui/derives/derives-span-Hash-tuple-struct.stderr b/src/test/ui/derives/derives-span-Hash-tuple-struct.stderr index 4af96ada66c28..a6c4c479b24d7 100644 --- a/src/test/ui/derives/derives-span-Hash-tuple-struct.stderr +++ b/src/test/ui/derives/derives-span-Hash-tuple-struct.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `Error: std::hash::Hash` is not satisfied - --> $DIR/derives-span-Hash-tuple-struct.rs:8:5 + --> $DIR/derives-span-Hash-tuple-struct.rs:10:5 | LL | Error | ^^^^^ the trait `std::hash::Hash` is not implemented for `Error` diff --git a/src/test/ui/interior-mutability/interior-mutability.rs b/src/test/ui/interior-mutability/interior-mutability.rs index ddc882cccf390..d75c149a7b682 100644 --- a/src/test/ui/interior-mutability/interior-mutability.rs +++ b/src/test/ui/interior-mutability/interior-mutability.rs @@ -1,3 +1,5 @@ +// ignore-musl +// ^ due to stderr output differences use std::cell::Cell; use std::panic::catch_unwind; fn main() { diff --git a/src/test/ui/interior-mutability/interior-mutability.stderr b/src/test/ui/interior-mutability/interior-mutability.stderr index 1a726be4aa6f4..b76fce2880552 100644 --- a/src/test/ui/interior-mutability/interior-mutability.stderr +++ b/src/test/ui/interior-mutability/interior-mutability.stderr @@ -1,5 +1,5 @@ error[E0277]: the type `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary - --> $DIR/interior-mutability.rs:5:5 + --> $DIR/interior-mutability.rs:7:5 | LL | catch_unwind(|| { x.set(23); }); | ^^^^^^^^^^^^ `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary @@ -12,7 +12,7 @@ LL | pub fn catch_unwind R + UnwindSafe, R>(f: F) -> Result { = help: within `std::cell::Cell`, the trait `std::panic::RefUnwindSafe` is not implemented for `std::cell::UnsafeCell` = note: required because it appears within the type `std::cell::Cell` = note: required because of the requirements on the impl of `std::panic::UnwindSafe` for `&std::cell::Cell` - = note: required because it appears within the type `[closure@$DIR/interior-mutability.rs:5:18: 5:35 x:&std::cell::Cell]` + = note: required because it appears within the type `[closure@$DIR/interior-mutability.rs:7:18: 7:35 x:&std::cell::Cell]` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-21160.rs b/src/test/ui/issues/issue-21160.rs index 46733566cf383..1e441a173e4be 100644 --- a/src/test/ui/issues/issue-21160.rs +++ b/src/test/ui/issues/issue-21160.rs @@ -1,3 +1,5 @@ +// ignore-musl +// ^ due to stderr output differences struct Bar; impl Bar { diff --git a/src/test/ui/issues/issue-21160.stderr b/src/test/ui/issues/issue-21160.stderr index 577baa97d8f9d..9f88fa2fadd4c 100644 --- a/src/test/ui/issues/issue-21160.stderr +++ b/src/test/ui/issues/issue-21160.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `Bar: std::hash::Hash` is not satisfied - --> $DIR/issue-21160.rs:8:12 + --> $DIR/issue-21160.rs:10:12 | LL | struct Foo(Bar); | ^^^ the trait `std::hash::Hash` is not implemented for `Bar` diff --git a/src/test/ui/no-send-res-ports.rs b/src/test/ui/no-send-res-ports.rs index e10f447365ea6..2c8cf0cf4e61c 100644 --- a/src/test/ui/no-send-res-ports.rs +++ b/src/test/ui/no-send-res-ports.rs @@ -1,3 +1,5 @@ +// ignore-musl +// ^ due to stderr output differences use std::thread; use std::rc::Rc; diff --git a/src/test/ui/no-send-res-ports.stderr b/src/test/ui/no-send-res-ports.stderr index 20f88badbefd4..dc186f7c85e94 100644 --- a/src/test/ui/no-send-res-ports.stderr +++ b/src/test/ui/no-send-res-ports.stderr @@ -1,5 +1,5 @@ error[E0277]: `std::rc::Rc<()>` cannot be sent between threads safely - --> $DIR/no-send-res-ports.rs:25:5 + --> $DIR/no-send-res-ports.rs:27:5 | LL | thread::spawn(move|| { | ^^^^^^^^^^^^^ `std::rc::Rc<()>` cannot be sent between threads safely @@ -9,10 +9,10 @@ LL | thread::spawn(move|| { LL | F: FnOnce() -> T, F: Send + 'static, T: Send + 'static | ---- required by this bound in `std::thread::spawn` | - = help: within `[closure@$DIR/no-send-res-ports.rs:25:19: 29:6 x:main::Foo]`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<()>` + = help: within `[closure@$DIR/no-send-res-ports.rs:27:19: 31:6 x:main::Foo]`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<()>` = note: required because it appears within the type `Port<()>` = note: required because it appears within the type `main::Foo` - = note: required because it appears within the type `[closure@$DIR/no-send-res-ports.rs:25:19: 29:6 x:main::Foo]` + = note: required because it appears within the type `[closure@$DIR/no-send-res-ports.rs:27:19: 31:6 x:main::Foo]` error: aborting due to previous error diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs index 193a523aed24b..d5105b40d36f5 100644 --- a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs @@ -1,4 +1,6 @@ // compile-flags: --test +// ignore-musl +// ^ due to stderr output differences use std::num::ParseFloatError; diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr index 983063d19711f..6aa95c308f248 100644 --- a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr @@ -1,5 +1,5 @@ error[E0277]: `main` has invalid return type `std::result::Result` - --> $DIR/termination-trait-test-wrong-type.rs:6:1 + --> $DIR/termination-trait-test-wrong-type.rs:8:1 | LL | / fn can_parse_zero_as_f32() -> Result { LL | | "0".parse() diff --git a/src/test/ui/traits/trait-suggest-where-clause.rs b/src/test/ui/traits/trait-suggest-where-clause.rs index 8405e5ff62e8e..822f0c580e651 100644 --- a/src/test/ui/traits/trait-suggest-where-clause.rs +++ b/src/test/ui/traits/trait-suggest-where-clause.rs @@ -1,3 +1,5 @@ +// ignore-musl +// ^ due to stderr output differences use std::mem; struct Misc(T); diff --git a/src/test/ui/traits/trait-suggest-where-clause.stderr b/src/test/ui/traits/trait-suggest-where-clause.stderr index 0aa5f429334ef..a59306d3cb41f 100644 --- a/src/test/ui/traits/trait-suggest-where-clause.stderr +++ b/src/test/ui/traits/trait-suggest-where-clause.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `U` cannot be known at compilation time - --> $DIR/trait-suggest-where-clause.rs:7:5 + --> $DIR/trait-suggest-where-clause.rs:9:5 | LL | mem::size_of::(); | ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -14,7 +14,7 @@ LL | pub const fn size_of() -> usize { = help: consider adding a `where U: std::marker::Sized` bound error[E0277]: the size for values of type `U` cannot be known at compilation time - --> $DIR/trait-suggest-where-clause.rs:10:5 + --> $DIR/trait-suggest-where-clause.rs:12:5 | LL | mem::size_of::>(); | ^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -30,7 +30,7 @@ LL | pub const fn size_of() -> usize { = note: required because it appears within the type `Misc` error[E0277]: the trait bound `u64: std::convert::From` is not satisfied - --> $DIR/trait-suggest-where-clause.rs:15:5 + --> $DIR/trait-suggest-where-clause.rs:17:5 | LL | >::from; | ^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From` is not implemented for `u64` @@ -39,7 +39,7 @@ LL | >::from; = note: required by `std::convert::From::from` error[E0277]: the trait bound `u64: std::convert::From<::Item>` is not satisfied - --> $DIR/trait-suggest-where-clause.rs:18:5 + --> $DIR/trait-suggest-where-clause.rs:20:5 | LL | ::Item>>::from; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<::Item>` is not implemented for `u64` @@ -48,7 +48,7 @@ LL | ::Item>>::from; = note: required by `std::convert::From::from` error[E0277]: the trait bound `Misc<_>: std::convert::From` is not satisfied - --> $DIR/trait-suggest-where-clause.rs:23:5 + --> $DIR/trait-suggest-where-clause.rs:25:5 | LL | as From>::from; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From` is not implemented for `Misc<_>` @@ -56,7 +56,7 @@ LL | as From>::from; = note: required by `std::convert::From::from` error[E0277]: the size for values of type `[T]` cannot be known at compilation time - --> $DIR/trait-suggest-where-clause.rs:28:5 + --> $DIR/trait-suggest-where-clause.rs:30:5 | LL | mem::size_of::<[T]>(); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -70,7 +70,7 @@ LL | pub const fn size_of() -> usize { = note: to learn more, visit error[E0277]: the size for values of type `[&U]` cannot be known at compilation time - --> $DIR/trait-suggest-where-clause.rs:31:5 + --> $DIR/trait-suggest-where-clause.rs:33:5 | LL | mem::size_of::<[&U]>(); | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time From 4e0437ee8e51c43b76ff2e1a4ea717f18d279f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 18 Sep 2019 13:51:36 -0700 Subject: [PATCH 58/63] Fix rebase --- src/test/ui/hrtb/due-to-where-clause.stderr | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/test/ui/hrtb/due-to-where-clause.stderr b/src/test/ui/hrtb/due-to-where-clause.stderr index e698584bb716f..9fef1e3354399 100644 --- a/src/test/ui/hrtb/due-to-where-clause.stderr +++ b/src/test/ui/hrtb/due-to-where-clause.stderr @@ -2,15 +2,12 @@ error: implementation of `Foo` is not general enough --> $DIR/due-to-where-clause.rs:5:5 | LL | test::(&mut 42); - | ^^^^^^^^^^^^ doesn't satisfy where-clause + | ^^^^^^^^^^^^ implementation of `Foo` is not general enough ... LL | trait Foo<'a> {} | ---------------- trait `Foo` defined here -... -LL | fn test<'a, F>(data: &'a mut u32) where F: for<'b> Foo<'b> {} - | ------------------------------------------------------------- due to a where-clause on `test`... | - = note: ...`FooS<'_>` must implement `Foo<'0>`, for any lifetime `'0`... + = note: `FooS<'_>` must implement `Foo<'0>`, for any lifetime `'0`... = note: ...but `FooS<'_>` actually implements `Foo<'1>`, for some specific lifetime `'1` error: aborting due to previous error From 4be51c879e763fefd31f02766ab967d9943f65c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 20 Sep 2019 11:58:20 -0700 Subject: [PATCH 59/63] Point at type param when it's cause of unfulfilled obligation --- src/librustc_typeck/check/callee.rs | 12 +-- src/librustc_typeck/check/expr.rs | 2 +- src/librustc_typeck/check/mod.rs | 79 ++++++++++++++++--- .../associated-types-eq-hr.stderr | 12 +-- .../extern/extern-types-not-sync-send.stderr | 8 +- .../ui/extern/extern-types-unsized.stderr | 4 +- src/test/ui/hrtb/hrtb-conflate-regions.stderr | 4 +- ...b-exists-forall-trait-contravariant.stderr | 4 +- .../hrtb-exists-forall-trait-covariant.stderr | 4 +- .../hrtb-exists-forall-trait-invariant.stderr | 4 +- src/test/ui/hrtb/hrtb-just-for-static.stderr | 8 +- src/test/ui/hrtb/issue-46989.stderr | 4 +- src/test/ui/issues/issue-1920-1.stderr | 4 +- src/test/ui/issues/issue-1920-2.stderr | 4 +- src/test/ui/issues/issue-1920-3.stderr | 4 +- src/test/ui/kindck/kindck-copy.stderr | 42 +++++----- src/test/ui/kindck/kindck-send-unsafe.stderr | 4 +- .../overlap-marker-trait.stderr | 4 +- .../unboxed-closures-vtable-mismatch.stderr | 2 +- src/test/ui/not-sync.stderr | 24 +++--- src/test/ui/overlap-marker-trait.stderr | 4 +- .../trait-alias-cross-crate.stderr | 8 +- .../traits/trait-suggest-where-clause.stderr | 8 +- src/test/ui/try-operator-on-main.stderr | 4 +- ...efault-trait-impl-constituent-types.stderr | 4 +- ...ck-default-trait-impl-negation-send.stderr | 4 +- ...ck-default-trait-impl-negation-sync.stderr | 4 +- .../typeck-default-trait-impl-negation.stderr | 8 +- ...ypeck-default-trait-impl-send-param.stderr | 4 +- .../ui/unsized/unsized-bare-typaram.stderr | 4 +- 30 files changed, 176 insertions(+), 109 deletions(-) diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index e6999f9e3ac8a..710d847384e6c 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -263,7 +263,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn confirm_builtin_call( &self, - call_expr: &hir::Expr, + call_expr: &'tcx hir::Expr, callee_ty: Ty<'tcx>, arg_exprs: &'tcx [hir::Expr], expected: Expectation<'tcx>, @@ -425,7 +425,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); self.check_argument_types( call_expr.span, - call_expr.span, + call_expr, inputs, &expected_arg_tys[..], arg_exprs, @@ -439,7 +439,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn confirm_deferred_closure_call( &self, - call_expr: &hir::Expr, + call_expr: &'tcx hir::Expr, arg_exprs: &'tcx [hir::Expr], expected: Expectation<'tcx>, fn_sig: ty::FnSig<'tcx>, @@ -458,7 +458,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.check_argument_types( call_expr.span, - call_expr.span, + call_expr, fn_sig.inputs(), &expected_arg_tys, arg_exprs, @@ -472,14 +472,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn confirm_overloaded_call( &self, - call_expr: &hir::Expr, + call_expr: &'tcx hir::Expr, arg_exprs: &'tcx [hir::Expr], expected: Expectation<'tcx>, method_callee: MethodCallee<'tcx>, ) -> Ty<'tcx> { let output_type = self.check_method_argument_types( call_expr.span, - call_expr.span, + call_expr, Ok(method_callee), arg_exprs, TupleArgumentsFlag::TupleArguments, diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs index 1ae50b8cb2883..e34a2c6f61c24 100644 --- a/src/librustc_typeck/check/expr.rs +++ b/src/librustc_typeck/check/expr.rs @@ -796,7 +796,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Call the generic checker. self.check_method_argument_types( span, - expr.span, + expr, method, &args[1..], DontTupleArguments, diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index edea91c717ef7..5fe554de2586f 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3070,12 +3070,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn check_method_argument_types( &self, sp: Span, - expr_sp: Span, + expr: &'tcx hir::Expr, method: Result, ()>, args_no_rcvr: &'tcx [hir::Expr], tuple_arguments: TupleArgumentsFlag, expected: Expectation<'tcx>, ) -> Ty<'tcx> { + let has_error = match method { Ok(method) => { method.substs.references_error() || method.sig.references_error() @@ -3090,8 +3091,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { TupleArguments => vec![self.tcx.intern_tup(&err_inputs[..])], }; - self.check_argument_types(sp, expr_sp, &err_inputs[..], &[], args_no_rcvr, - false, tuple_arguments, None); + self.check_argument_types( + sp, + expr, + &err_inputs[..], + &[], + args_no_rcvr, + false, + tuple_arguments, + None, + ); return self.tcx.types.err; } @@ -3103,9 +3112,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { method.sig.output(), &method.sig.inputs()[1..] ); - self.check_argument_types(sp, expr_sp, &method.sig.inputs()[1..], &expected_arg_tys[..], - args_no_rcvr, method.sig.c_variadic, tuple_arguments, - self.tcx.hir().span_if_local(method.def_id)); + self.check_argument_types( + sp, + expr, + &method.sig.inputs()[1..], + &expected_arg_tys[..], + args_no_rcvr, + method.sig.c_variadic, + tuple_arguments, + self.tcx.hir().span_if_local(method.def_id), + ); method.sig.output() } @@ -3182,7 +3198,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn check_argument_types( &self, sp: Span, - expr_sp: Span, + expr: &'tcx hir::Expr, fn_inputs: &[Ty<'tcx>], expected_arg_tys: &[Ty<'tcx>], args: &'tcx [hir::Expr], @@ -3191,7 +3207,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { def_span: Option, ) { let tcx = self.tcx; - // Grab the argument types, supplying fresh type variables // if the wrong number of arguments were supplied let supplied_arg_count = if tuple_arguments == DontTupleArguments { @@ -3225,7 +3240,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.span_label(def_s, "defined here"); } if sugg_unit { - let sugg_span = tcx.sess.source_map().end_point(expr_sp); + let sugg_span = tcx.sess.source_map().end_point(expr.span); // remove closing `)` from the span let sugg_span = sugg_span.shrink_to_lo(); err.span_suggestion( @@ -3319,6 +3334,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // the call. This helps coercions. if check_closures { self.select_obligations_where_possible(false, |errors| { + self.point_at_type_arg_instead_of_call_if_possible(errors, expr); self.point_at_arg_instead_of_call_if_possible( errors, &final_arg_types[..], @@ -3456,6 +3472,51 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } + /// Given a vec of evaluated `FullfillmentError`s and an `fn` call expression, we walk the + /// `PathSegment`s and resolve their type parameters to see if any of the `FullfillmentError`s + /// were caused by them. If they were, we point at the corresponding type argument's span + /// instead of the `fn` call path span. + fn point_at_type_arg_instead_of_call_if_possible( + &self, + errors: &mut Vec>, + call_expr: &'tcx hir::Expr, + ) { + if let hir::ExprKind::Call(path, _args) = &call_expr.node { + if let hir::ExprKind::Path(qpath) = &path.node { + if let hir::QPath::Resolved(_self, path) = &qpath { + for error in errors { + if let ty::Predicate::Trait(predicate) = error.obligation.predicate { + // If any of the type arguments in this path segment caused the + // `FullfillmentError`, point at its span (#61860). + for segment in &path.segments { + if let Some(args) = &segment.args { + for arg in &args.args { + if let hir::GenericArg::Type(hir_ty) = &arg { + if let hir::TyKind::Path( + hir::QPath::TypeRelative(..), + ) = &hir_ty.node { + // Avoid ICE with associated types. As this is best + // effort only, it's ok to ignore the case. It + // would trigger in `is_send::();` + // from `typeck-default-trait-impl-assoc-type.rs`. + } else { + let ty = AstConv::ast_ty_to_ty(self, hir_ty); + let ty = self.resolve_vars_if_possible(&ty); + if ty == predicate.skip_binder().self_ty() { + error.obligation.cause.span = hir_ty.span; + } + } + } + } + } + } + } + } + } + } + } + } + // AST fragment checking fn check_lit(&self, lit: &hir::Lit, diff --git a/src/test/ui/associated-types/associated-types-eq-hr.stderr b/src/test/ui/associated-types/associated-types-eq-hr.stderr index f560aefd637c0..45b6cc9ba5f98 100644 --- a/src/test/ui/associated-types/associated-types-eq-hr.stderr +++ b/src/test/ui/associated-types/associated-types-eq-hr.stderr @@ -27,7 +27,7 @@ LL | bar::(); found type `&usize` error[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize)>` is not satisfied - --> $DIR/associated-types-eq-hr.rs:91:5 + --> $DIR/associated-types-eq-hr.rs:91:17 | LL | fn tuple_one() | --------- @@ -35,7 +35,7 @@ LL | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'x isize> | ---------------------------------------------------------- required by this bound in `tuple_one` ... LL | tuple_one::(); - | ^^^^^^^^^^^^^^^^^^ the trait `for<'x, 'y> TheTrait<(&'x isize, &'y isize)>` is not implemented for `Tuple` + | ^^^^^ the trait `for<'x, 'y> TheTrait<(&'x isize, &'y isize)>` is not implemented for `Tuple` | = help: the following implementations were found: > @@ -52,7 +52,7 @@ LL | tuple_one::(); | ^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'x, found concrete lifetime error[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize)>` is not satisfied - --> $DIR/associated-types-eq-hr.rs:97:5 + --> $DIR/associated-types-eq-hr.rs:97:17 | LL | fn tuple_two() | --------- @@ -60,7 +60,7 @@ LL | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'y isize> | ---------------------------------------------------------- required by this bound in `tuple_two` ... LL | tuple_two::(); - | ^^^^^^^^^^^^^^^^^^ the trait `for<'x, 'y> TheTrait<(&'x isize, &'y isize)>` is not implemented for `Tuple` + | ^^^^^ the trait `for<'x, 'y> TheTrait<(&'x isize, &'y isize)>` is not implemented for `Tuple` | = help: the following implementations were found: > @@ -77,7 +77,7 @@ LL | tuple_two::(); | ^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'x, found concrete lifetime error[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize)>` is not satisfied - --> $DIR/associated-types-eq-hr.rs:107:5 + --> $DIR/associated-types-eq-hr.rs:107:18 | LL | fn tuple_four() | ---------- @@ -85,7 +85,7 @@ LL | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize)> | ------------------------------------------- required by this bound in `tuple_four` ... LL | tuple_four::(); - | ^^^^^^^^^^^^^^^^^^^ the trait `for<'x, 'y> TheTrait<(&'x isize, &'y isize)>` is not implemented for `Tuple` + | ^^^^^ the trait `for<'x, 'y> TheTrait<(&'x isize, &'y isize)>` is not implemented for `Tuple` | = help: the following implementations were found: > diff --git a/src/test/ui/extern/extern-types-not-sync-send.stderr b/src/test/ui/extern/extern-types-not-sync-send.stderr index 803bd9dbac62c..c395f3875ea0e 100644 --- a/src/test/ui/extern/extern-types-not-sync-send.stderr +++ b/src/test/ui/extern/extern-types-not-sync-send.stderr @@ -1,22 +1,22 @@ error[E0277]: `A` cannot be shared between threads safely - --> $DIR/extern-types-not-sync-send.rs:13:5 + --> $DIR/extern-types-not-sync-send.rs:13:19 | LL | fn assert_sync() { } | ----------- ---- required by this bound in `assert_sync` ... LL | assert_sync::(); - | ^^^^^^^^^^^^^^^^ `A` cannot be shared between threads safely + | ^ `A` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `A` error[E0277]: `A` cannot be sent between threads safely - --> $DIR/extern-types-not-sync-send.rs:16:5 + --> $DIR/extern-types-not-sync-send.rs:16:19 | LL | fn assert_send() { } | ----------- ---- required by this bound in `assert_send` ... LL | assert_send::(); - | ^^^^^^^^^^^^^^^^ `A` cannot be sent between threads safely + | ^ `A` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `A` diff --git a/src/test/ui/extern/extern-types-unsized.stderr b/src/test/ui/extern/extern-types-unsized.stderr index 1f69a4e154eb3..0417186eed346 100644 --- a/src/test/ui/extern/extern-types-unsized.stderr +++ b/src/test/ui/extern/extern-types-unsized.stderr @@ -1,11 +1,11 @@ error[E0277]: the size for values of type `A` cannot be known at compilation time - --> $DIR/extern-types-unsized.rs:22:5 + --> $DIR/extern-types-unsized.rs:22:20 | LL | fn assert_sized() { } | ------------ - required by this bound in `assert_sized` ... LL | assert_sized::(); - | ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `A` = note: to learn more, visit diff --git a/src/test/ui/hrtb/hrtb-conflate-regions.stderr b/src/test/ui/hrtb/hrtb-conflate-regions.stderr index 205fa2b5bc81f..9822b48f4f48f 100644 --- a/src/test/ui/hrtb/hrtb-conflate-regions.stderr +++ b/src/test/ui/hrtb/hrtb-conflate-regions.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `for<'a, 'b> SomeStruct: Foo<(&'a isize, &'b isize)>` is not satisfied - --> $DIR/hrtb-conflate-regions.rs:27:10 + --> $DIR/hrtb-conflate-regions.rs:27:22 | LL | fn want_foo2() | --------- @@ -7,7 +7,7 @@ LL | where T : for<'a,'b> Foo<(&'a isize, &'b isize)> | -------------------------------------- required by this bound in `want_foo2` ... LL | fn b() { want_foo2::(); } - | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a, 'b> Foo<(&'a isize, &'b isize)>` is not implemented for `SomeStruct` + | ^^^^^^^^^^ the trait `for<'a, 'b> Foo<(&'a isize, &'b isize)>` is not implemented for `SomeStruct` | = help: the following implementations were found: > diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr index ceba22234be6a..969d9eda73519 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `(): Trait fn(&'b u32)>` is not satisfied - --> $DIR/hrtb-exists-forall-trait-contravariant.rs:34:5 + --> $DIR/hrtb-exists-forall-trait-contravariant.rs:34:11 | LL | fn foo() | --- @@ -8,7 +8,7 @@ LL | T: Trait fn(&'b u32)>, | -------------------------- required by this bound in `foo` ... LL | foo::<()>(); - | ^^^^^^^^^ the trait `Trait fn(&'b u32)>` is not implemented for `()` + | ^^ the trait `Trait fn(&'b u32)>` is not implemented for `()` | = help: the following implementations were found: <() as Trait> diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.stderr b/src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.stderr index a1cb3b230fea2..dddc2bcce49e5 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.stderr +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `(): Trait fn(fn(&'b u32))>` is not satisfied - --> $DIR/hrtb-exists-forall-trait-covariant.rs:36:5 + --> $DIR/hrtb-exists-forall-trait-covariant.rs:36:11 | LL | fn foo() | --- @@ -8,7 +8,7 @@ LL | T: Trait fn(fn(&'b u32))>, | ------------------------------ required by this bound in `foo` ... LL | foo::<()>(); - | ^^^^^^^^^ the trait `Trait fn(fn(&'b u32))>` is not implemented for `()` + | ^^ the trait `Trait fn(fn(&'b u32))>` is not implemented for `()` | = help: the following implementations were found: <() as Trait> diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr b/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr index 093bee375bb0b..23ef75944d317 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `(): Trait fn(std::cell::Cell<&'b u32>)>` is not satisfied - --> $DIR/hrtb-exists-forall-trait-invariant.rs:28:5 + --> $DIR/hrtb-exists-forall-trait-invariant.rs:28:11 | LL | fn foo() | --- @@ -8,7 +8,7 @@ LL | T: Trait fn(Cell<&'b u32>)>, | -------------------------------- required by this bound in `foo` ... LL | foo::<()>(); - | ^^^^^^^^^ the trait `Trait fn(std::cell::Cell<&'b u32>)>` is not implemented for `()` + | ^^ the trait `Trait fn(std::cell::Cell<&'b u32>)>` is not implemented for `()` | = help: the following implementations were found: <() as Trait)>> diff --git a/src/test/ui/hrtb/hrtb-just-for-static.stderr b/src/test/ui/hrtb/hrtb-just-for-static.stderr index f4cf3555868f2..6ec0beefd60e3 100644 --- a/src/test/ui/hrtb/hrtb-just-for-static.stderr +++ b/src/test/ui/hrtb/hrtb-just-for-static.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `for<'a> StaticInt: Foo<&'a isize>` is not satisfied - --> $DIR/hrtb-just-for-static.rs:24:5 + --> $DIR/hrtb-just-for-static.rs:24:17 | LL | fn want_hrtb() | --------- @@ -7,13 +7,13 @@ LL | where T : for<'a> Foo<&'a isize> | ---------------------- required by this bound in `want_hrtb` ... LL | want_hrtb::() - | ^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Foo<&'a isize>` is not implemented for `StaticInt` + | ^^^^^^^^^ the trait `for<'a> Foo<&'a isize>` is not implemented for `StaticInt` | = help: the following implementations were found: > error[E0277]: the trait bound `for<'a> &'a u32: Foo<&'a isize>` is not satisfied - --> $DIR/hrtb-just-for-static.rs:30:5 + --> $DIR/hrtb-just-for-static.rs:30:17 | LL | fn want_hrtb() | --------- @@ -21,7 +21,7 @@ LL | where T : for<'a> Foo<&'a isize> | ---------------------- required by this bound in `want_hrtb` ... LL | want_hrtb::<&'a u32>() - | ^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Foo<&'a isize>` is not implemented for `&'a u32` + | ^^^^^^^ the trait `for<'a> Foo<&'a isize>` is not implemented for `&'a u32` | = help: the following implementations were found: <&'a u32 as Foo<&'a isize>> diff --git a/src/test/ui/hrtb/issue-46989.stderr b/src/test/ui/hrtb/issue-46989.stderr index 4da3e3ddb7ebd..c818041e59632 100644 --- a/src/test/ui/hrtb/issue-46989.stderr +++ b/src/test/ui/hrtb/issue-46989.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `for<'r> fn(&'r i32): Foo` is not satisfied - --> $DIR/issue-46989.rs:40:5 + --> $DIR/issue-46989.rs:40:18 | LL | fn assert_foo() {} | ---------- --- required by this bound in `assert_foo` ... LL | assert_foo::(); - | ^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `for<'r> fn(&'r i32)` + | ^^^^^^^^ the trait `Foo` is not implemented for `for<'r> fn(&'r i32)` | = help: the following implementations were found: diff --git a/src/test/ui/issues/issue-1920-1.stderr b/src/test/ui/issues/issue-1920-1.stderr index 56f70aa296cb9..089968ede7d0f 100644 --- a/src/test/ui/issues/issue-1920-1.stderr +++ b/src/test/ui/issues/issue-1920-1.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `foo::issue_1920::S: std::clone::Clone` is not satisfied - --> $DIR/issue-1920-1.rs:12:5 + --> $DIR/issue-1920-1.rs:12:20 | LL | fn assert_clone() where T : Clone { } | ------------ ----- required by this bound in `assert_clone` ... LL | assert_clone::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `foo::issue_1920::S` + | ^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `foo::issue_1920::S` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-1920-2.stderr b/src/test/ui/issues/issue-1920-2.stderr index 37027b0579265..eaf34e076c088 100644 --- a/src/test/ui/issues/issue-1920-2.stderr +++ b/src/test/ui/issues/issue-1920-2.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `bar::S: std::clone::Clone` is not satisfied - --> $DIR/issue-1920-2.rs:10:5 + --> $DIR/issue-1920-2.rs:10:20 | LL | fn assert_clone() where T : Clone { } | ------------ ----- required by this bound in `assert_clone` ... LL | assert_clone::(); - | ^^^^^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `bar::S` + | ^^^^^^ the trait `std::clone::Clone` is not implemented for `bar::S` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-1920-3.stderr b/src/test/ui/issues/issue-1920-3.stderr index dbcb3aee11703..0550f5feba5be 100644 --- a/src/test/ui/issues/issue-1920-3.stderr +++ b/src/test/ui/issues/issue-1920-3.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `issue_1920::S: std::clone::Clone` is not satisfied - --> $DIR/issue-1920-3.rs:14:5 + --> $DIR/issue-1920-3.rs:14:20 | LL | fn assert_clone() where T : Clone { } | ------------ ----- required by this bound in `assert_clone` ... LL | assert_clone::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `issue_1920::S` + | ^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `issue_1920::S` error: aborting due to previous error diff --git a/src/test/ui/kindck/kindck-copy.stderr b/src/test/ui/kindck/kindck-copy.stderr index 53b4448a7574f..fee9e2802a6c3 100644 --- a/src/test/ui/kindck/kindck-copy.stderr +++ b/src/test/ui/kindck/kindck-copy.stderr @@ -1,62 +1,68 @@ error[E0277]: the trait bound `&'static mut isize: std::marker::Copy` is not satisfied - --> $DIR/kindck-copy.rs:27:5 + --> $DIR/kindck-copy.rs:27:19 | LL | fn assert_copy() { } | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy::<&'static mut isize>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'static mut isize` + | -^^^^^^^^^^^^^^^^^ + | | + | the trait `std::marker::Copy` is not implemented for `&'static mut isize` + | help: consider removing 1 leading `&`-references | = help: the following implementations were found: error[E0277]: the trait bound `&'a mut isize: std::marker::Copy` is not satisfied - --> $DIR/kindck-copy.rs:28:5 + --> $DIR/kindck-copy.rs:28:19 | LL | fn assert_copy() { } | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy::<&'a mut isize>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'a mut isize` + | -^^^^^^^^^^^^ + | | + | the trait `std::marker::Copy` is not implemented for `&'a mut isize` + | help: consider removing 1 leading `&`-references | = help: the following implementations were found: error[E0277]: the trait bound `std::boxed::Box: std::marker::Copy` is not satisfied - --> $DIR/kindck-copy.rs:31:5 + --> $DIR/kindck-copy.rs:31:19 | LL | fn assert_copy() { } | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy::>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box` + | ^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box` error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied - --> $DIR/kindck-copy.rs:32:5 + --> $DIR/kindck-copy.rs:32:19 | LL | fn assert_copy() { } | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy::(); - | ^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` + | ^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` error[E0277]: the trait bound `std::vec::Vec: std::marker::Copy` is not satisfied - --> $DIR/kindck-copy.rs:33:5 + --> $DIR/kindck-copy.rs:33:19 | LL | fn assert_copy() { } | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy:: >(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::vec::Vec` + | ^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::vec::Vec` error[E0277]: the trait bound `std::boxed::Box<&'a mut isize>: std::marker::Copy` is not satisfied - --> $DIR/kindck-copy.rs:34:5 + --> $DIR/kindck-copy.rs:34:19 | LL | fn assert_copy() { } | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy::>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<&'a mut isize>` + | ^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<&'a mut isize>` error[E0277]: the trait bound `std::boxed::Box: std::marker::Copy` is not satisfied --> $DIR/kindck-copy.rs:42:5 @@ -77,31 +83,31 @@ LL | assert_copy::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box` error[E0277]: the trait bound `&'a mut (dyn Dummy + std::marker::Send + 'a): std::marker::Copy` is not satisfied - --> $DIR/kindck-copy.rs:46:5 + --> $DIR/kindck-copy.rs:46:19 | LL | fn assert_copy() { } | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy::<&'a mut (dyn Dummy + Send)>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'a mut (dyn Dummy + std::marker::Send + 'a)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'a mut (dyn Dummy + std::marker::Send + 'a)` error[E0277]: the trait bound `MyNoncopyStruct: std::marker::Copy` is not satisfied - --> $DIR/kindck-copy.rs:64:5 + --> $DIR/kindck-copy.rs:64:19 | LL | fn assert_copy() { } | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `MyNoncopyStruct` + | ^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `MyNoncopyStruct` error[E0277]: the trait bound `std::rc::Rc: std::marker::Copy` is not satisfied - --> $DIR/kindck-copy.rs:67:5 + --> $DIR/kindck-copy.rs:67:19 | LL | fn assert_copy() { } | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy::>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::rc::Rc` + | ^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::rc::Rc` error: aborting due to 11 previous errors diff --git a/src/test/ui/kindck/kindck-send-unsafe.stderr b/src/test/ui/kindck/kindck-send-unsafe.stderr index a46705ab1755d..05ed51d0f1175 100644 --- a/src/test/ui/kindck/kindck-send-unsafe.stderr +++ b/src/test/ui/kindck/kindck-send-unsafe.stderr @@ -1,11 +1,11 @@ error[E0277]: `*mut &'a isize` cannot be sent between threads safely - --> $DIR/kindck-send-unsafe.rs:6:5 + --> $DIR/kindck-send-unsafe.rs:6:19 | LL | fn assert_send() { } | ----------- ---- required by this bound in `assert_send` ... LL | assert_send::<*mut &'a isize>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*mut &'a isize` cannot be sent between threads safely + | ^^^^^^^^^^^^^^ `*mut &'a isize` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `*mut &'a isize` diff --git a/src/test/ui/marker_trait_attr/overlap-marker-trait.stderr b/src/test/ui/marker_trait_attr/overlap-marker-trait.stderr index be5e649ef8340..4508870746bcb 100644 --- a/src/test/ui/marker_trait_attr/overlap-marker-trait.stderr +++ b/src/test/ui/marker_trait_attr/overlap-marker-trait.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `NotDebugOrDisplay: Marker` is not satisfied - --> $DIR/overlap-marker-trait.rs:27:5 + --> $DIR/overlap-marker-trait.rs:27:17 | LL | fn is_marker() { } | --------- ------ required by this bound in `is_marker` ... LL | is_marker::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Marker` is not implemented for `NotDebugOrDisplay` + | ^^^^^^^^^^^^^^^^^ the trait `Marker` is not implemented for `NotDebugOrDisplay` error: aborting due to previous error diff --git a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr index 6c249f6275181..2daf4781c7e6f 100644 --- a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr +++ b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr @@ -1,5 +1,5 @@ error[E0631]: type mismatch in closure arguments - --> $DIR/unboxed-closures-vtable-mismatch.rs:16:13 + --> $DIR/unboxed-closures-vtable-mismatch.rs:16:24 | LL | fn call_itisize>(y: isize, mut f: F) -> isize { | ------- ------------------------- required by this bound in `call_it` diff --git a/src/test/ui/not-sync.stderr b/src/test/ui/not-sync.stderr index 8871abedd00dd..8bb4ce2e2c773 100644 --- a/src/test/ui/not-sync.stderr +++ b/src/test/ui/not-sync.stderr @@ -1,66 +1,66 @@ error[E0277]: `std::cell::Cell` cannot be shared between threads safely - --> $DIR/not-sync.rs:8:5 + --> $DIR/not-sync.rs:8:12 | LL | fn test() {} | ---- ---- required by this bound in `test` ... LL | test::>(); - | ^^^^^^^^^^^^^^^^^ `std::cell::Cell` cannot be shared between threads safely + | ^^^^^^^^^ `std::cell::Cell` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `std::cell::Cell` error[E0277]: `std::cell::RefCell` cannot be shared between threads safely - --> $DIR/not-sync.rs:10:5 + --> $DIR/not-sync.rs:10:12 | LL | fn test() {} | ---- ---- required by this bound in `test` ... LL | test::>(); - | ^^^^^^^^^^^^^^^^^^^^ `std::cell::RefCell` cannot be shared between threads safely + | ^^^^^^^^^^^^ `std::cell::RefCell` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `std::cell::RefCell` error[E0277]: `std::rc::Rc` cannot be shared between threads safely - --> $DIR/not-sync.rs:13:5 + --> $DIR/not-sync.rs:13:12 | LL | fn test() {} | ---- ---- required by this bound in `test` ... LL | test::>(); - | ^^^^^^^^^^^^^^^ `std::rc::Rc` cannot be shared between threads safely + | ^^^^^^^ `std::rc::Rc` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `std::rc::Rc` error[E0277]: `std::rc::Weak` cannot be shared between threads safely - --> $DIR/not-sync.rs:15:5 + --> $DIR/not-sync.rs:15:12 | LL | fn test() {} | ---- ---- required by this bound in `test` ... LL | test::>(); - | ^^^^^^^^^^^^^^^^^ `std::rc::Weak` cannot be shared between threads safely + | ^^^^^^^^^ `std::rc::Weak` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `std::rc::Weak` error[E0277]: `std::sync::mpsc::Receiver` cannot be shared between threads safely - --> $DIR/not-sync.rs:18:5 + --> $DIR/not-sync.rs:18:12 | LL | fn test() {} | ---- ---- required by this bound in `test` ... LL | test::>(); - | ^^^^^^^^^^^^^^^^^^^^^ `std::sync::mpsc::Receiver` cannot be shared between threads safely + | ^^^^^^^^^^^^^ `std::sync::mpsc::Receiver` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `std::sync::mpsc::Receiver` error[E0277]: `std::sync::mpsc::Sender` cannot be shared between threads safely - --> $DIR/not-sync.rs:20:5 + --> $DIR/not-sync.rs:20:12 | LL | fn test() {} | ---- ---- required by this bound in `test` ... LL | test::>(); - | ^^^^^^^^^^^^^^^^^^^ `std::sync::mpsc::Sender` cannot be shared between threads safely + | ^^^^^^^^^^^ `std::sync::mpsc::Sender` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `std::sync::mpsc::Sender` diff --git a/src/test/ui/overlap-marker-trait.stderr b/src/test/ui/overlap-marker-trait.stderr index daf4e5e69a29b..15ebcd17b0dbc 100644 --- a/src/test/ui/overlap-marker-trait.stderr +++ b/src/test/ui/overlap-marker-trait.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `NotDebugOrDisplay: Marker` is not satisfied - --> $DIR/overlap-marker-trait.rs:30:5 + --> $DIR/overlap-marker-trait.rs:30:17 | LL | fn is_marker() { } | --------- ------ required by this bound in `is_marker` ... LL | is_marker::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Marker` is not implemented for `NotDebugOrDisplay` + | ^^^^^^^^^^^^^^^^^ the trait `Marker` is not implemented for `NotDebugOrDisplay` error: aborting due to previous error diff --git a/src/test/ui/traits/trait-alias/trait-alias-cross-crate.stderr b/src/test/ui/traits/trait-alias/trait-alias-cross-crate.stderr index 10a9506bd0639..cad5c81f5a6ca 100644 --- a/src/test/ui/traits/trait-alias/trait-alias-cross-crate.stderr +++ b/src/test/ui/traits/trait-alias/trait-alias-cross-crate.stderr @@ -1,22 +1,22 @@ error[E0277]: `std::rc::Rc` cannot be sent between threads safely - --> $DIR/trait-alias-cross-crate.rs:14:5 + --> $DIR/trait-alias-cross-crate.rs:14:17 | LL | fn use_alias() {} | --------- -------- required by this bound in `use_alias` ... LL | use_alias::>(); - | ^^^^^^^^^^^^^^^^^^^^ `std::rc::Rc` cannot be sent between threads safely + | ^^^^^^^ `std::rc::Rc` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `std::rc::Rc` error[E0277]: `std::rc::Rc` cannot be shared between threads safely - --> $DIR/trait-alias-cross-crate.rs:14:5 + --> $DIR/trait-alias-cross-crate.rs:14:17 | LL | fn use_alias() {} | --------- -------- required by this bound in `use_alias` ... LL | use_alias::>(); - | ^^^^^^^^^^^^^^^^^^^^ `std::rc::Rc` cannot be shared between threads safely + | ^^^^^^^ `std::rc::Rc` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `std::rc::Rc` diff --git a/src/test/ui/traits/trait-suggest-where-clause.stderr b/src/test/ui/traits/trait-suggest-where-clause.stderr index a59306d3cb41f..d15edaa9c8146 100644 --- a/src/test/ui/traits/trait-suggest-where-clause.stderr +++ b/src/test/ui/traits/trait-suggest-where-clause.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `U` cannot be known at compilation time - --> $DIR/trait-suggest-where-clause.rs:9:5 + --> $DIR/trait-suggest-where-clause.rs:9:20 | LL | mem::size_of::(); - | ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | ^ doesn't have a size known at compile-time | ::: $SRC_DIR/libcore/mem/mod.rs:LL:COL | @@ -56,10 +56,10 @@ LL | as From>::from; = note: required by `std::convert::From::from` error[E0277]: the size for values of type `[T]` cannot be known at compilation time - --> $DIR/trait-suggest-where-clause.rs:30:5 + --> $DIR/trait-suggest-where-clause.rs:30:20 | LL | mem::size_of::<[T]>(); - | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | ^^^ doesn't have a size known at compile-time | ::: $SRC_DIR/libcore/mem/mod.rs:LL:COL | diff --git a/src/test/ui/try-operator-on-main.stderr b/src/test/ui/try-operator-on-main.stderr index de75d3e313d9e..d2f1a04837b86 100644 --- a/src/test/ui/try-operator-on-main.stderr +++ b/src/test/ui/try-operator-on-main.stderr @@ -17,10 +17,10 @@ LL | ()?; = note: required by `std::ops::Try::into_result` error[E0277]: the trait bound `(): std::ops::Try` is not satisfied - --> $DIR/try-operator-on-main.rs:15:5 + --> $DIR/try-operator-on-main.rs:15:25 | LL | try_trait_generic::<()>(); - | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::ops::Try` is not implemented for `()` + | ^^ the trait `std::ops::Try` is not implemented for `()` ... LL | fn try_trait_generic() -> T { | ----------------- --- required by this bound in `try_trait_generic` diff --git a/src/test/ui/typeck/typeck-default-trait-impl-constituent-types.stderr b/src/test/ui/typeck/typeck-default-trait-impl-constituent-types.stderr index e5d275083dfe0..22a2cb3e0ecb8 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-constituent-types.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-constituent-types.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `MyS2: MyTrait` is not satisfied - --> $DIR/typeck-default-trait-impl-constituent-types.rs:20:5 + --> $DIR/typeck-default-trait-impl-constituent-types.rs:20:18 | LL | fn is_mytrait() {} | ---------- ------- required by this bound in `is_mytrait` ... LL | is_mytrait::(); - | ^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `MyS2` + | ^^^^ the trait `MyTrait` is not implemented for `MyS2` | = help: the following implementations were found: diff --git a/src/test/ui/typeck/typeck-default-trait-impl-negation-send.stderr b/src/test/ui/typeck/typeck-default-trait-impl-negation-send.stderr index 2f5be975c6dd7..e30d4dfa1b3c4 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-negation-send.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-negation-send.stderr @@ -1,11 +1,11 @@ error[E0277]: `MyNotSendable` cannot be sent between threads safely - --> $DIR/typeck-default-trait-impl-negation-send.rs:19:5 + --> $DIR/typeck-default-trait-impl-negation-send.rs:19:15 | LL | fn is_send() {} | ------- ---- required by this bound in `is_send` ... LL | is_send::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^ `MyNotSendable` cannot be sent between threads safely + | ^^^^^^^^^^^^^ `MyNotSendable` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `MyNotSendable` diff --git a/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr b/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr index 77e04a75a25c1..4dd8e01cf2d36 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr @@ -1,11 +1,11 @@ error[E0277]: `MyNotSync` cannot be shared between threads safely - --> $DIR/typeck-default-trait-impl-negation-sync.rs:33:5 + --> $DIR/typeck-default-trait-impl-negation-sync.rs:33:15 | LL | fn is_sync() {} | ------- ---- required by this bound in `is_sync` ... LL | is_sync::(); - | ^^^^^^^^^^^^^^^^^^^^ `MyNotSync` cannot be shared between threads safely + | ^^^^^^^^^ `MyNotSync` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `MyNotSync` diff --git a/src/test/ui/typeck/typeck-default-trait-impl-negation.stderr b/src/test/ui/typeck/typeck-default-trait-impl-negation.stderr index 09c05825190e7..4b13fcc885a0d 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-negation.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-negation.stderr @@ -1,23 +1,23 @@ error[E0277]: the trait bound `ThisImplsUnsafeTrait: MyTrait` is not satisfied - --> $DIR/typeck-default-trait-impl-negation.rs:21:5 + --> $DIR/typeck-default-trait-impl-negation.rs:21:19 | LL | fn is_my_trait() {} | ----------- ------- required by this bound in `is_my_trait` ... LL | is_my_trait::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `ThisImplsUnsafeTrait` + | ^^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `ThisImplsUnsafeTrait` | = help: the following implementations were found: error[E0277]: the trait bound `ThisImplsTrait: MyUnsafeTrait` is not satisfied - --> $DIR/typeck-default-trait-impl-negation.rs:24:5 + --> $DIR/typeck-default-trait-impl-negation.rs:24:26 | LL | fn is_my_unsafe_trait() {} | ------------------ ------------- required by this bound in `is_my_unsafe_trait` ... LL | is_my_unsafe_trait::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MyUnsafeTrait` is not implemented for `ThisImplsTrait` + | ^^^^^^^^^^^^^^ the trait `MyUnsafeTrait` is not implemented for `ThisImplsTrait` | = help: the following implementations were found: diff --git a/src/test/ui/typeck/typeck-default-trait-impl-send-param.stderr b/src/test/ui/typeck/typeck-default-trait-impl-send-param.stderr index 46731c0fbb014..b3139083b1ac8 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-send-param.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-send-param.stderr @@ -1,8 +1,8 @@ error[E0277]: `T` cannot be sent between threads safely - --> $DIR/typeck-default-trait-impl-send-param.rs:5:5 + --> $DIR/typeck-default-trait-impl-send-param.rs:5:15 | LL | is_send::() - | ^^^^^^^^^^^^ `T` cannot be sent between threads safely + | ^ `T` cannot be sent between threads safely ... LL | fn is_send() { | ------- ---- required by this bound in `is_send` diff --git a/src/test/ui/unsized/unsized-bare-typaram.stderr b/src/test/ui/unsized/unsized-bare-typaram.stderr index 565d561033722..e56176690a113 100644 --- a/src/test/ui/unsized/unsized-bare-typaram.stderr +++ b/src/test/ui/unsized/unsized-bare-typaram.stderr @@ -1,10 +1,10 @@ error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/unsized-bare-typaram.rs:2:23 + --> $DIR/unsized-bare-typaram.rs:2:29 | LL | fn bar() { } | --- - required by this bound in `bar` LL | fn foo() { bar::() } - | ^^^^^^^^ doesn't have a size known at compile-time + | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` = note: to learn more, visit From d201e278ba6f9e2f8d9046eb983116b839807c98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 20 Sep 2019 14:29:39 -0700 Subject: [PATCH 60/63] review comments --- src/librustc_typeck/check/mod.rs | 39 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 5fe554de2586f..38071a9e74da8 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3481,31 +3481,30 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { errors: &mut Vec>, call_expr: &'tcx hir::Expr, ) { - if let hir::ExprKind::Call(path, _args) = &call_expr.node { + if let hir::ExprKind::Call(path, _) = &call_expr.node { if let hir::ExprKind::Path(qpath) = &path.node { - if let hir::QPath::Resolved(_self, path) = &qpath { + if let hir::QPath::Resolved(_, path) = &qpath { for error in errors { if let ty::Predicate::Trait(predicate) = error.obligation.predicate { // If any of the type arguments in this path segment caused the // `FullfillmentError`, point at its span (#61860). - for segment in &path.segments { - if let Some(args) = &segment.args { - for arg in &args.args { - if let hir::GenericArg::Type(hir_ty) = &arg { - if let hir::TyKind::Path( - hir::QPath::TypeRelative(..), - ) = &hir_ty.node { - // Avoid ICE with associated types. As this is best - // effort only, it's ok to ignore the case. It - // would trigger in `is_send::();` - // from `typeck-default-trait-impl-assoc-type.rs`. - } else { - let ty = AstConv::ast_ty_to_ty(self, hir_ty); - let ty = self.resolve_vars_if_possible(&ty); - if ty == predicate.skip_binder().self_ty() { - error.obligation.cause.span = hir_ty.span; - } - } + for arg in path.segments.iter() + .filter_map(|seg| seg.args.as_ref()) + .flat_map(|a| a.args.iter()) + { + if let hir::GenericArg::Type(hir_ty) = &arg { + if let hir::TyKind::Path( + hir::QPath::TypeRelative(..), + ) = &hir_ty.node { + // Avoid ICE with associated types. As this is best + // effort only, it's ok to ignore the case. It + // would trigger in `is_send::();` + // from `typeck-default-trait-impl-assoc-type.rs`. + } else { + let ty = AstConv::ast_ty_to_ty(self, hir_ty); + let ty = self.resolve_vars_if_possible(&ty); + if ty == predicate.skip_binder().self_ty() { + error.obligation.cause.span = hir_ty.span; } } } From 3ea0d1097945273d6f9091126e67899a2e7e8fb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 20 Sep 2019 15:02:36 -0700 Subject: [PATCH 61/63] hack to avoid incorrect suggestion --- src/librustc/traits/error_reporting.rs | 7 +++++++ src/test/ui/kindck/kindck-copy.stderr | 10 ++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 03f8ac250e925..aff866fa76d5f 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -1055,6 +1055,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { .filter(|c| !c.is_whitespace()) .take_while(|c| *c == '&') .count(); + if let Some('\'') = snippet.chars() + .filter(|c| !c.is_whitespace()) + .skip(refs_number) + .next() + { // Do not suggest removal of borrow from type arguments. + return; + } let mut trait_type = trait_ref.self_ty(); diff --git a/src/test/ui/kindck/kindck-copy.stderr b/src/test/ui/kindck/kindck-copy.stderr index fee9e2802a6c3..3ca9cf7e973db 100644 --- a/src/test/ui/kindck/kindck-copy.stderr +++ b/src/test/ui/kindck/kindck-copy.stderr @@ -5,10 +5,7 @@ LL | fn assert_copy() { } | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy::<&'static mut isize>(); - | -^^^^^^^^^^^^^^^^^ - | | - | the trait `std::marker::Copy` is not implemented for `&'static mut isize` - | help: consider removing 1 leading `&`-references + | ^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'static mut isize` | = help: the following implementations were found: @@ -20,10 +17,7 @@ LL | fn assert_copy() { } | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy::<&'a mut isize>(); - | -^^^^^^^^^^^^ - | | - | the trait `std::marker::Copy` is not implemented for `&'a mut isize` - | help: consider removing 1 leading `&`-references + | ^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'a mut isize` | = help: the following implementations were found: From 7cef8b34959ce5472f1b3d0223ccfc7e8d71df60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 21 Sep 2019 11:39:06 -0700 Subject: [PATCH 62/63] ignore-x86 instead of ignore-musl --- src/etc/generate-deriving-span-tests.py | 2 +- src/test/ui/async-await/issues/issue-62009-1.rs | 2 +- src/test/ui/closures/closure-move-sync.rs | 2 +- src/test/ui/derives/derives-span-Hash-enum-struct-variant.rs | 2 +- src/test/ui/derives/derives-span-Hash-enum.rs | 2 +- src/test/ui/derives/derives-span-Hash-struct.rs | 2 +- src/test/ui/derives/derives-span-Hash-tuple-struct.rs | 2 +- src/test/ui/interior-mutability/interior-mutability.rs | 2 +- src/test/ui/issues/issue-21160.rs | 2 +- src/test/ui/no-send-res-ports.rs | 2 +- .../termination-trait-test-wrong-type.rs | 2 +- src/test/ui/traits/trait-suggest-where-clause.rs | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/etc/generate-deriving-span-tests.py b/src/etc/generate-deriving-span-tests.py index 4af67039fd877..66a3c8e555405 100755 --- a/src/etc/generate-deriving-span-tests.py +++ b/src/etc/generate-deriving-span-tests.py @@ -14,7 +14,7 @@ os.path.join(os.path.dirname(__file__), '../test/ui/derives/')) TEMPLATE = """\ -// ignore-musl +// ignore-x86 // ^ due to stderr output differences // This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' diff --git a/src/test/ui/async-await/issues/issue-62009-1.rs b/src/test/ui/async-await/issues/issue-62009-1.rs index 007ed4efa6981..788474365c9e5 100644 --- a/src/test/ui/async-await/issues/issue-62009-1.rs +++ b/src/test/ui/async-await/issues/issue-62009-1.rs @@ -1,5 +1,5 @@ // edition:2018 -// ignore-musl +// ignore-x86 // ^ due to stderr output differences async fn print_dur() {} diff --git a/src/test/ui/closures/closure-move-sync.rs b/src/test/ui/closures/closure-move-sync.rs index 4cb6358864fca..951a3bcb5f423 100644 --- a/src/test/ui/closures/closure-move-sync.rs +++ b/src/test/ui/closures/closure-move-sync.rs @@ -1,4 +1,4 @@ -// ignore-musl +// ignore-x86 // ^ due to stderr output differences use std::thread; use std::sync::mpsc::channel; diff --git a/src/test/ui/derives/derives-span-Hash-enum-struct-variant.rs b/src/test/ui/derives/derives-span-Hash-enum-struct-variant.rs index 516a15b55bf1d..ed87360a0be9f 100644 --- a/src/test/ui/derives/derives-span-Hash-enum-struct-variant.rs +++ b/src/test/ui/derives/derives-span-Hash-enum-struct-variant.rs @@ -1,4 +1,4 @@ -// ignore-musl +// ignore-x86 // ^ due to stderr output differences // This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' diff --git a/src/test/ui/derives/derives-span-Hash-enum.rs b/src/test/ui/derives/derives-span-Hash-enum.rs index ba12deaf98137..5b3649c9826e6 100644 --- a/src/test/ui/derives/derives-span-Hash-enum.rs +++ b/src/test/ui/derives/derives-span-Hash-enum.rs @@ -1,4 +1,4 @@ -// ignore-musl +// ignore-x86 // ^ due to stderr output differences // This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' diff --git a/src/test/ui/derives/derives-span-Hash-struct.rs b/src/test/ui/derives/derives-span-Hash-struct.rs index b9e7e04f4cfed..ead70861a0ad6 100644 --- a/src/test/ui/derives/derives-span-Hash-struct.rs +++ b/src/test/ui/derives/derives-span-Hash-struct.rs @@ -1,4 +1,4 @@ -// ignore-musl +// ignore-x86 // ^ due to stderr output differences // This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' diff --git a/src/test/ui/derives/derives-span-Hash-tuple-struct.rs b/src/test/ui/derives/derives-span-Hash-tuple-struct.rs index bb271e60745a5..820f13ed18ef2 100644 --- a/src/test/ui/derives/derives-span-Hash-tuple-struct.rs +++ b/src/test/ui/derives/derives-span-Hash-tuple-struct.rs @@ -1,4 +1,4 @@ -// ignore-musl +// ignore-x86 // ^ due to stderr output differences // This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' diff --git a/src/test/ui/interior-mutability/interior-mutability.rs b/src/test/ui/interior-mutability/interior-mutability.rs index d75c149a7b682..6968e3669caec 100644 --- a/src/test/ui/interior-mutability/interior-mutability.rs +++ b/src/test/ui/interior-mutability/interior-mutability.rs @@ -1,4 +1,4 @@ -// ignore-musl +// ignore-x86 // ^ due to stderr output differences use std::cell::Cell; use std::panic::catch_unwind; diff --git a/src/test/ui/issues/issue-21160.rs b/src/test/ui/issues/issue-21160.rs index 1e441a173e4be..dfb39743352fc 100644 --- a/src/test/ui/issues/issue-21160.rs +++ b/src/test/ui/issues/issue-21160.rs @@ -1,4 +1,4 @@ -// ignore-musl +// ignore-x86 // ^ due to stderr output differences struct Bar; diff --git a/src/test/ui/no-send-res-ports.rs b/src/test/ui/no-send-res-ports.rs index 2c8cf0cf4e61c..01fc29713a45d 100644 --- a/src/test/ui/no-send-res-ports.rs +++ b/src/test/ui/no-send-res-ports.rs @@ -1,4 +1,4 @@ -// ignore-musl +// ignore-x86 // ^ due to stderr output differences use std::thread; use std::rc::Rc; diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs index d5105b40d36f5..c27cea302fc40 100644 --- a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs @@ -1,5 +1,5 @@ // compile-flags: --test -// ignore-musl +// ignore-x86 // ^ due to stderr output differences use std::num::ParseFloatError; diff --git a/src/test/ui/traits/trait-suggest-where-clause.rs b/src/test/ui/traits/trait-suggest-where-clause.rs index 822f0c580e651..5ed14a6a86685 100644 --- a/src/test/ui/traits/trait-suggest-where-clause.rs +++ b/src/test/ui/traits/trait-suggest-where-clause.rs @@ -1,4 +1,4 @@ -// ignore-musl +// ignore-x86 // ^ due to stderr output differences use std::mem; From ff75124a377f60ee4bd084ca2569e1530ff52856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 22 Sep 2019 11:54:38 -0700 Subject: [PATCH 63/63] fix nll tests --- .../expect-fn-supply-fn.nll.stderr | 51 +++++++++---------- .../ui/kindck/kindck-send-object1.nll.stderr | 4 +- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr b/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr index 565c60e5216dd..a6b52b258f005 100644 --- a/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr +++ b/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr @@ -1,44 +1,41 @@ error[E0631]: type mismatch in closure arguments --> $DIR/expect-fn-supply-fn.rs:30:5 | -LL | / fn with_closure_expecting_fn_with_free_region(_: F) -LL | | where F: for<'a> FnOnce(fn(&'a u32), &i32) -LL | | { -LL | | } - | |_- required by `with_closure_expecting_fn_with_free_region` +LL | fn with_closure_expecting_fn_with_free_region(_: F) + | ------------------------------------------ +LL | where F: for<'a> FnOnce(fn(&'a u32), &i32) + | ------------------------- required by this bound in `with_closure_expecting_fn_with_free_region` ... -LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {}); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------- found signature of `fn(for<'r> fn(&'r u32), _) -> _` - | | - | expected signature of `fn(fn(&'a u32), &i32) -> _` +LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------- found signature of `fn(for<'r> fn(&'r u32), _) -> _` + | | + | expected signature of `fn(fn(&'a u32), &i32) -> _` error[E0631]: type mismatch in closure arguments --> $DIR/expect-fn-supply-fn.rs:37:5 | -LL | / fn with_closure_expecting_fn_with_bound_region(_: F) -LL | | where F: FnOnce(fn(&u32), &i32) -LL | | { -LL | | } - | |_- required by `with_closure_expecting_fn_with_bound_region` +LL | fn with_closure_expecting_fn_with_bound_region(_: F) + | ------------------------------------------- +LL | where F: FnOnce(fn(&u32), &i32) + | ---------------------- required by this bound in `with_closure_expecting_fn_with_bound_region` ... -LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {}); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------------------- found signature of `fn(fn(&'x u32), _) -> _` - | | - | expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _` +LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------------------- found signature of `fn(fn(&'x u32), _) -> _` + | | + | expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _` error[E0631]: type mismatch in closure arguments --> $DIR/expect-fn-supply-fn.rs:46:5 | -LL | / fn with_closure_expecting_fn_with_bound_region(_: F) -LL | | where F: FnOnce(fn(&u32), &i32) -LL | | { -LL | | } - | |_- required by `with_closure_expecting_fn_with_bound_region` +LL | fn with_closure_expecting_fn_with_bound_region(_: F) + | ------------------------------------------- +LL | where F: FnOnce(fn(&u32), &i32) + | ---------------------- required by this bound in `with_closure_expecting_fn_with_bound_region` ... -LL | with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --------------- found signature of `for<'r> fn(fn(&'r u32), _) -> _` - | | - | expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _` +LL | with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --------------- found signature of `for<'r> fn(fn(&'r u32), _) -> _` + | | + | expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _` error: aborting due to 3 previous errors diff --git a/src/test/ui/kindck/kindck-send-object1.nll.stderr b/src/test/ui/kindck/kindck-send-object1.nll.stderr index c7d18cd8b8bb1..f882e06ed222a 100644 --- a/src/test/ui/kindck/kindck-send-object1.nll.stderr +++ b/src/test/ui/kindck/kindck-send-object1.nll.stderr @@ -2,7 +2,7 @@ error[E0277]: `(dyn Dummy + 'a)` cannot be shared between threads safely --> $DIR/kindck-send-object1.rs:10:5 | LL | fn assert_send() { } - | -------------------------------- required by `assert_send` + | ----------- ---- required by this bound in `assert_send` ... LL | assert_send::<&'a dyn Dummy>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be shared between threads safely @@ -14,7 +14,7 @@ error[E0277]: `(dyn Dummy + 'a)` cannot be sent between threads safely --> $DIR/kindck-send-object1.rs:29:5 | LL | fn assert_send() { } - | -------------------------------- required by `assert_send` + | ----------- ---- required by this bound in `assert_send` ... LL | assert_send::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be sent between threads safely