about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-02-02 19:07:07 +0000
committerbors <bors@rust-lang.org>2022-02-02 19:07:07 +0000
commit27f5d830eb11cd7bdc834d6f0d78120976f75443 (patch)
tree2f08e48c477c4a63fdffcdd0fd7b3ae26dcd693d /src
parent7cd14d2f561a61e9838546f133afcf06038d761b (diff)
parent93155c59563a6a9017bc868c41243ffe7dc7fe89 (diff)
downloadrust-27f5d830eb11cd7bdc834d6f0d78120976f75443.tar.gz
rust-27f5d830eb11cd7bdc834d6f0d78120976f75443.zip
Auto merge of #93594 - matthiaskrgr:rollup-lcvhpdv, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #92528 (Make `Fingerprint::combine_commutative` associative)
 - #93221 ([borrowck] Fix help on mutating &self in async fns)
 - #93542 (Prevent lifetime elision in type alias)
 - #93546 (Validate that values in switch int terminator are unique)
 - #93571 (better suggestion for duplicated `where` clause)
 - #93574 (don't suggest adding `let` due to bad assignment expressions inside of `while` loop)
 - #93590 (More let_else adoptions)
 - #93592 (Remove unused dep from rustc_arena)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/clean/mod.rs16
-rw-r--r--src/test/rustdoc/lifetime-name.rs5
-rw-r--r--src/test/ui/borrowck/issue-93093.rs14
-rw-r--r--src/test/ui/borrowck/issue-93093.stderr12
-rw-r--r--src/test/ui/parser/bad-struct-following-where.rs2
-rw-r--r--src/test/ui/parser/bad-struct-following-where.stderr8
-rw-r--r--src/test/ui/parser/duplicate-where-clauses.rs19
-rw-r--r--src/test/ui/parser/duplicate-where-clauses.stderr80
-rw-r--r--src/test/ui/typeck/issue-93486.rs6
-rw-r--r--src/test/ui/typeck/issue-93486.stderr11
10 files changed, 170 insertions, 3 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 7d209accec9..95404b33822 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -1427,15 +1427,25 @@ fn normalize<'tcx>(cx: &mut DocContext<'tcx>, ty: Ty<'_>) -> Option<Ty<'tcx>> {
         return None;
     }
 
+    use crate::rustc_trait_selection::infer::TyCtxtInferExt;
+    use crate::rustc_trait_selection::traits::query::normalize::AtExt;
+    use rustc_middle::traits::ObligationCause;
+
     // Try to normalize `<X as Y>::T` to a type
     let lifted = ty.lift_to_tcx(cx.tcx).unwrap();
-    match cx.tcx.try_normalize_erasing_regions(cx.param_env, lifted) {
+    let normalized = cx.tcx.infer_ctxt().enter(|infcx| {
+        infcx
+            .at(&ObligationCause::dummy(), cx.param_env)
+            .normalize(lifted)
+            .map(|resolved| infcx.resolve_vars_if_possible(resolved.value))
+    });
+    match normalized {
         Ok(normalized_value) => {
-            trace!("normalized {:?} to {:?}", ty, normalized_value);
+            debug!("normalized {:?} to {:?}", ty, normalized_value);
             Some(normalized_value)
         }
         Err(err) => {
-            info!("failed to normalize {:?}: {:?}", ty, err);
+            debug!("failed to normalize {:?}: {:?}", ty, err);
             None
         }
     }
diff --git a/src/test/rustdoc/lifetime-name.rs b/src/test/rustdoc/lifetime-name.rs
new file mode 100644
index 00000000000..5d30a745a61
--- /dev/null
+++ b/src/test/rustdoc/lifetime-name.rs
@@ -0,0 +1,5 @@
+#![crate_name = "foo"]
+
+// @has 'foo/type.Resolutions.html'
+// @has - '//*[@class="rust typedef"]' "pub type Resolutions<'tcx> = &'tcx u8;"
+pub type Resolutions<'tcx> = &'tcx u8;
diff --git a/src/test/ui/borrowck/issue-93093.rs b/src/test/ui/borrowck/issue-93093.rs
new file mode 100644
index 00000000000..f4db5ecafac
--- /dev/null
+++ b/src/test/ui/borrowck/issue-93093.rs
@@ -0,0 +1,14 @@
+// edition:2018
+struct S {
+    foo: usize,
+}
+impl S {
+    async fn bar(&self) { //~ HELP consider changing this to be a mutable reference
+        //~| SUGGESTION &mut self
+        self.foo += 1; //~ ERROR cannot assign to `self.foo`, which is behind a `&` reference [E0594]
+    }
+}
+
+fn main() {
+    S { foo: 1 }.bar();
+}
diff --git a/src/test/ui/borrowck/issue-93093.stderr b/src/test/ui/borrowck/issue-93093.stderr
new file mode 100644
index 00000000000..031128af476
--- /dev/null
+++ b/src/test/ui/borrowck/issue-93093.stderr
@@ -0,0 +1,12 @@
+error[E0594]: cannot assign to `self.foo`, which is behind a `&` reference
+  --> $DIR/issue-93093.rs:8:9
+   |
+LL |     async fn bar(&self) {
+   |                  ----- help: consider changing this to be a mutable reference: `&mut self`
+LL |
+LL |         self.foo += 1;
+   |         ^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0594`.
diff --git a/src/test/ui/parser/bad-struct-following-where.rs b/src/test/ui/parser/bad-struct-following-where.rs
new file mode 100644
index 00000000000..823880b1b42
--- /dev/null
+++ b/src/test/ui/parser/bad-struct-following-where.rs
@@ -0,0 +1,2 @@
+struct A where T: Sized !
+//~^ ERROR expected `{` after struct name, found
diff --git a/src/test/ui/parser/bad-struct-following-where.stderr b/src/test/ui/parser/bad-struct-following-where.stderr
new file mode 100644
index 00000000000..bb79776dc84
--- /dev/null
+++ b/src/test/ui/parser/bad-struct-following-where.stderr
@@ -0,0 +1,8 @@
+error: expected `{` after struct name, found `!`
+  --> $DIR/bad-struct-following-where.rs:1:25
+   |
+LL | struct A where T: Sized !
+   |                         ^ expected `{` after struct name
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/parser/duplicate-where-clauses.rs b/src/test/ui/parser/duplicate-where-clauses.rs
new file mode 100644
index 00000000000..9eb2ffb06f0
--- /dev/null
+++ b/src/test/ui/parser/duplicate-where-clauses.rs
@@ -0,0 +1,19 @@
+struct A where (): Sized where (): Sized {}
+//~^ ERROR cannot define duplicate `where` clauses on an item
+
+fn b() where (): Sized where (): Sized {}
+//~^ ERROR cannot define duplicate `where` clauses on an item
+
+enum C where (): Sized where (): Sized {}
+//~^ ERROR cannot define duplicate `where` clauses on an item
+
+struct D where (): Sized, where (): Sized {}
+//~^ ERROR cannot define duplicate `where` clauses on an item
+
+fn e() where (): Sized, where (): Sized {}
+//~^ ERROR cannot define duplicate `where` clauses on an item
+
+enum F where (): Sized, where (): Sized {}
+//~^ ERROR cannot define duplicate `where` clauses on an item
+
+fn main() {}
diff --git a/src/test/ui/parser/duplicate-where-clauses.stderr b/src/test/ui/parser/duplicate-where-clauses.stderr
new file mode 100644
index 00000000000..8250d4f1e05
--- /dev/null
+++ b/src/test/ui/parser/duplicate-where-clauses.stderr
@@ -0,0 +1,80 @@
+error: cannot define duplicate `where` clauses on an item
+  --> $DIR/duplicate-where-clauses.rs:1:32
+   |
+LL | struct A where (): Sized where (): Sized {}
+   |                -               ^
+   |                |
+   |                previous `where` clause starts here
+   |
+help: consider joining the two `where` clauses into one
+   |
+LL | struct A where (): Sized, (): Sized {}
+   |                         ~
+
+error: cannot define duplicate `where` clauses on an item
+  --> $DIR/duplicate-where-clauses.rs:4:30
+   |
+LL | fn b() where (): Sized where (): Sized {}
+   |              -               ^
+   |              |
+   |              previous `where` clause starts here
+   |
+help: consider joining the two `where` clauses into one
+   |
+LL | fn b() where (): Sized, (): Sized {}
+   |                       ~
+
+error: cannot define duplicate `where` clauses on an item
+  --> $DIR/duplicate-where-clauses.rs:7:30
+   |
+LL | enum C where (): Sized where (): Sized {}
+   |              -               ^
+   |              |
+   |              previous `where` clause starts here
+   |
+help: consider joining the two `where` clauses into one
+   |
+LL | enum C where (): Sized, (): Sized {}
+   |                       ~
+
+error: cannot define duplicate `where` clauses on an item
+  --> $DIR/duplicate-where-clauses.rs:10:33
+   |
+LL | struct D where (): Sized, where (): Sized {}
+   |                -                ^
+   |                |
+   |                previous `where` clause starts here
+   |
+help: consider joining the two `where` clauses into one
+   |
+LL | struct D where (): Sized, (): Sized {}
+   |                         ~
+
+error: cannot define duplicate `where` clauses on an item
+  --> $DIR/duplicate-where-clauses.rs:13:31
+   |
+LL | fn e() where (): Sized, where (): Sized {}
+   |              -                ^
+   |              |
+   |              previous `where` clause starts here
+   |
+help: consider joining the two `where` clauses into one
+   |
+LL | fn e() where (): Sized, (): Sized {}
+   |                       ~
+
+error: cannot define duplicate `where` clauses on an item
+  --> $DIR/duplicate-where-clauses.rs:16:31
+   |
+LL | enum F where (): Sized, where (): Sized {}
+   |              -                ^
+   |              |
+   |              previous `where` clause starts here
+   |
+help: consider joining the two `where` clauses into one
+   |
+LL | enum F where (): Sized, (): Sized {}
+   |                       ~
+
+error: aborting due to 6 previous errors
+
diff --git a/src/test/ui/typeck/issue-93486.rs b/src/test/ui/typeck/issue-93486.rs
new file mode 100644
index 00000000000..f8f98d5c1c7
--- /dev/null
+++ b/src/test/ui/typeck/issue-93486.rs
@@ -0,0 +1,6 @@
+fn main() {
+    while let 1 = 1 {
+        vec![].last_mut().unwrap() = 3_u8;
+        //~^ ERROR invalid left-hand side of assignment
+    }
+}
diff --git a/src/test/ui/typeck/issue-93486.stderr b/src/test/ui/typeck/issue-93486.stderr
new file mode 100644
index 00000000000..70b5b63f1cb
--- /dev/null
+++ b/src/test/ui/typeck/issue-93486.stderr
@@ -0,0 +1,11 @@
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/issue-93486.rs:3:36
+   |
+LL |         vec![].last_mut().unwrap() = 3_u8;
+   |         -------------------------- ^
+   |         |
+   |         cannot assign to this expression
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0070`.