Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 5 pull requests #94046

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 32 additions & 24 deletions compiler/rustc_typeck/src/check/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2029,34 +2029,42 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err.help("the semantics of slice patterns changed recently; see issue #62254");
}
} else if Autoderef::new(&self.infcx, self.param_env, self.body_id, span, expected_ty, span)
.any(|(ty, _)| matches!(ty.kind(), ty::Slice(..)))
.any(|(ty, _)| matches!(ty.kind(), ty::Slice(..) | ty::Array(..)))
{
if let (Some(span), true) = (ti.span, ti.origin_expr) {
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
let applicability = match self.resolve_vars_if_possible(ti.expected).kind() {
ty::Adt(adt_def, _)
if self.tcx.is_diagnostic_item(sym::Option, adt_def.did)
|| self.tcx.is_diagnostic_item(sym::Result, adt_def.did) =>
{
// Slicing won't work here, but `.as_deref()` might (issue #91328).
err.span_suggestion(
span,
"consider using `as_deref` here",
format!("{}.as_deref()", snippet),
Applicability::MaybeIncorrect,
);
None
}
// FIXME: instead of checking for Vec only, we could check whether the
// type implements `Deref<Target=X>`; see
// https://github.com/rust-lang/rust/pull/91343#discussion_r761466979
ty::Adt(adt_def, _)
if self.tcx.is_diagnostic_item(sym::Vec, adt_def.did) =>
{
Some(Applicability::MachineApplicable)
let applicability = Autoderef::new(
&self.infcx,
self.param_env,
self.body_id,
span,
self.resolve_vars_if_possible(ti.expected),
span,
)
.find_map(|(ty, _)| {
match ty.kind() {
ty::Adt(adt_def, _)
if self.tcx.is_diagnostic_item(sym::Option, adt_def.did)
|| self.tcx.is_diagnostic_item(sym::Result, adt_def.did) =>
{
// Slicing won't work here, but `.as_deref()` might (issue #91328).
err.span_suggestion(
span,
"consider using `as_deref` here",
format!("{}.as_deref()", snippet),
Applicability::MaybeIncorrect,
);
Some(None)
}

ty::Slice(..) | ty::Array(..) => {
Some(Some(Applicability::MachineApplicable))
}

_ => None,
}
_ => Some(Applicability::MaybeIncorrect),
};
})
.unwrap_or(Some(Applicability::MaybeIncorrect));

if let Some(applicability) = applicability {
err.span_suggestion(
Expand Down
2 changes: 1 addition & 1 deletion src/ci/docker/host-x86_64/x86_64-gnu-tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ ENV PATH="/node-v14.4.0-linux-x64/bin:${PATH}"
# https://github.com/puppeteer/puppeteer/issues/375
#
# We also specify the version in case we need to update it to go around cache limitations.
RUN npm install -g browser-ui-test@0.7.1 --unsafe-perm=true
RUN npm install -g browser-ui-test@0.7.2 --unsafe-perm=true

ENV RUST_CONFIGURE_ARGS \
--build=x86_64-unknown-linux-gnu \
Expand Down
2 changes: 1 addition & 1 deletion src/doc/nomicon
15 changes: 14 additions & 1 deletion src/doc/rustdoc/src/command-line-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ the same CSS rules as the official `light` theme.
`--check-theme` flag, it discards all other flags and only performs the CSS rule
comparison operation.

### `--crate-version`: control the crate version
## `--crate-version`: control the crate version

Using this flag looks like this:

Expand Down Expand Up @@ -418,9 +418,22 @@ Rustdoc only supports Rust source code and Markdown input formats. If the
file ends in `.md` or `.markdown`, `rustdoc` treats it as a Markdown file.
Otherwise, it assumes that the input file is Rust.

# Unstable command line arguments

## `--nocapture`

When this flag is used with `--test`, the output (stdout and stderr) of your tests won't be
captured by rustdoc. Instead, the output will be directed to your terminal,
as if you had run the test executable manually. This is especially useful
for debugging your tests!

## `--check`

When this flag is supplied, rustdoc will type check and lint your code, but will not generate any
documentation or run your doctests.

Using this flag looks like:

```bash
rustdoc -Z unstable-options --check src/lib.rs
```
2 changes: 1 addition & 1 deletion src/test/rustdoc-gui/item-info-width.goml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ goto: file://|DOC_PATH|/lib2/struct.Foo.html
size: (1100, 800)
// We check that ".item-info" is bigger than its content.
assert-css: (".item-info", {"width": "790px"})
assert-css: (".item-info .stab", {"width": "339.562px"})
assert-css: (".item-info .stab", {"width": "340px"})
assert-position: (".item-info .stab", {"x": 295})
2 changes: 1 addition & 1 deletion src/test/ui/generic-associated-types/bugs/issue-80626.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// check-fail
// known-bug

// This should pass, but it requires `Sized` to be coinductive.

Expand All @@ -11,7 +12,6 @@ trait Allocator {
enum LinkedList<A: Allocator> {
Head,
Next(A::Allocated<Self>)
//~^ overflow
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0275]: overflow evaluating the requirement `LinkedList<A>: Sized`
--> $DIR/issue-80626.rs:13:10
--> $DIR/issue-80626.rs:14:10
|
LL | Next(A::Allocated<Self>)
| ^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/generic-associated-types/bugs/issue-86218.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// check-fail
// known-bug

// This should pass, but seems to run into a TAIT issue.

Expand All @@ -20,7 +21,6 @@ trait Yay<AdditionalValue> {

impl<'a> Yay<&'a ()> for () {
type InnerStream<'s> = impl Stream<Item = i32> + 's;
//~^ the type
fn foo<'s>() -> Self::InnerStream<'s> { todo!() }
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/generic-associated-types/bugs/issue-86218.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0477]: the type `impl Stream<Item = i32>` does not fulfill the required lifetime
--> $DIR/issue-86218.rs:22:28
--> $DIR/issue-86218.rs:23:28
|
LL | type InnerStream<'s> = impl Stream<Item = i32> + 's;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: type must outlive the lifetime `'s` as defined here as required by this binding
--> $DIR/issue-86218.rs:22:22
--> $DIR/issue-86218.rs:23:22
|
LL | type InnerStream<'s> = impl Stream<Item = i32> + 's;
| ^^
Expand Down
3 changes: 2 additions & 1 deletion src/test/ui/generic-associated-types/bugs/issue-87735.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// check-fail
// known-bug

// This should pass, but we need an extension of implied bounds (probably).

Expand All @@ -23,7 +24,7 @@ struct Foo<T>(T);
#[derive(Debug)]
struct FooRef<'a, U>(&'a [U]);

impl<'b, T, U> AsRef2 for Foo<T> //~ the type parameter
impl<'b, T, U> AsRef2 for Foo<T>
where
// * `for<'b, 'c> T: AsRef2<Output<'b> = &'c [U]>>` does not work
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
--> $DIR/issue-87735.rs:26:13
--> $DIR/issue-87735.rs:27:13
|
LL | impl<'b, T, U> AsRef2 for Foo<T>
| ^ unconstrained type parameter
Expand Down
3 changes: 2 additions & 1 deletion src/test/ui/generic-associated-types/bugs/issue-87748.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// check-fail
// known-bug

// This should pass, but unnormalized input args aren't treated as implied.

Expand All @@ -14,7 +15,7 @@ struct Foo;
impl MyTrait for Foo {
type Assoc<'a, 'b> where 'b: 'a = u32;

fn do_sth(_: u32) {} //~ lifetime bound
fn do_sth(_: u32) {}
// fn do_sth(_: Self::Assoc<'static, 'static>) {}
// fn do_sth(_: Self::Assoc<'_, '_>) {}
}
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/generic-associated-types/bugs/issue-87748.stderr
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
error[E0478]: lifetime bound not satisfied
--> $DIR/issue-87748.rs:17:5
--> $DIR/issue-87748.rs:18:5
|
LL | fn do_sth(_: u32) {}
| ^^^^^^^^^^^^^^^^^
|
note: lifetime parameter instantiated with the anonymous lifetime #2 defined here
--> $DIR/issue-87748.rs:17:5
--> $DIR/issue-87748.rs:18:5
|
LL | fn do_sth(_: u32) {}
| ^^^^^^^^^^^^^^^^^
note: but lifetime parameter must outlive the anonymous lifetime #1 defined here
--> $DIR/issue-87748.rs:17:5
--> $DIR/issue-87748.rs:18:5
|
LL | fn do_sth(_: u32) {}
| ^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/generic-associated-types/bugs/issue-87755.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// check-fail
// known-bug

// This should pass.

Expand All @@ -15,7 +16,6 @@ struct Bar;

impl Foo for Bar {
type Ass = Bar;
//~^ overflow
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0275]: overflow evaluating the requirement `<Bar as Foo>::Ass == _`
--> $DIR/issue-87755.rs:17:16
--> $DIR/issue-87755.rs:18:16
|
LL | type Ass = Bar;
| ^^^
Expand Down
3 changes: 2 additions & 1 deletion src/test/ui/generic-associated-types/bugs/issue-87803.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// check-fail
// known-bug

// This should pass, but using a type alias vs a reference directly
// changes late-bound -> early-bound.
Expand All @@ -18,7 +19,7 @@ impl Scanner for IdScanner {
type Input<'a> = &'a str;
type Token<'a> = &'a str;

fn scan<'a>(&mut self, s : &'a str) -> &'a str { //~ lifetime parameters
fn scan<'a>(&mut self, s : &'a str) -> &'a str {
s
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0195]: lifetime parameters or bounds on method `scan` do not match the trait declaration
--> $DIR/issue-87803.rs:21:12
--> $DIR/issue-87803.rs:22:12
|
LL | fn scan<'a>(&mut self, i : Self::Input<'a>) -> Self::Token<'a>;
| ---- lifetimes in impl do not match this method in trait
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/generic-associated-types/bugs/issue-88382.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// check-fail
// known-bug

// This should pass, but has a missed normalization due to HRTB.

Expand All @@ -25,7 +26,6 @@ fn do_something<I: Iterable>(i: I, mut f: impl for<'a> Fn(&mut I::Iterator<'a>))
fn main() {
do_something(SomeImplementation(), |_| ());
do_something(SomeImplementation(), test);
//~^ type mismatch
}

fn test<'a, I: Iterable>(_: &mut I::Iterator<'a>) {}
4 changes: 2 additions & 2 deletions src/test/ui/generic-associated-types/bugs/issue-88382.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0631]: type mismatch in function arguments
--> $DIR/issue-88382.rs:27:40
--> $DIR/issue-88382.rs:28:40
|
LL | do_something(SomeImplementation(), test);
| ------------ ^^^^ expected signature of `for<'a> fn(&mut <SomeImplementation as Iterable>::Iterator<'a>) -> _`
Expand All @@ -10,7 +10,7 @@ LL | fn test<'a, I: Iterable>(_: &mut I::Iterator<'a>) {}
| ------------------------------------------------- found signature of `for<'r> fn(&'r mut std::iter::Empty<usize>) -> _`
|
note: required by a bound in `do_something`
--> $DIR/issue-88382.rs:21:56
--> $DIR/issue-88382.rs:22:56
|
LL | fn do_something<I: Iterable>(i: I, mut f: impl for<'a> Fn(&mut I::Iterator<'a>)) {
| ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `do_something`
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/generic-associated-types/bugs/issue-88460.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// check-fail
// known-bug

// This should pass, but has a missed normalization due to HRTB.

Expand Down Expand Up @@ -27,5 +28,4 @@ impl Trait for Foo {

fn main() {
test(Foo);
//~^ the trait bound
}
4 changes: 2 additions & 2 deletions src/test/ui/generic-associated-types/bugs/issue-88460.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0277]: the trait bound `for<'a> <_ as Trait>::Assoc<'a>: Marker` is not satisfied
--> $DIR/issue-88460.rs:29:5
--> $DIR/issue-88460.rs:30:5
|
LL | test(Foo);
| ^^^^ the trait `for<'a> Marker` is not implemented for `<_ as Trait>::Assoc<'a>`
|
note: required by a bound in `test`
--> $DIR/issue-88460.rs:16:27
--> $DIR/issue-88460.rs:17:27
|
LL | fn test<T>(value: T)
| ---- required by a bound in this
Expand Down
3 changes: 2 additions & 1 deletion src/test/ui/generic-associated-types/bugs/issue-88526.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// check-fail
// known-bug

// This should pass, but requires more logic.

Expand All @@ -23,7 +24,7 @@ struct TestB<Q, F>
f: F,
}

impl<'q, Q, I, F> A for TestB<Q, F> //~ the type parameter
impl<'q, Q, I, F> A for TestB<Q, F>
where
Q: A<I<'q> = &'q I>,
F: Fn(I),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0207]: the type parameter `I` is not constrained by the impl trait, self type, or predicates
--> $DIR/issue-88526.rs:26:13
--> $DIR/issue-88526.rs:27:13
|
LL | impl<'q, Q, I, F> A for TestB<Q, F>
| ^ unconstrained type parameter
Expand Down
5 changes: 3 additions & 2 deletions src/test/ui/generic-associated-types/bugs/issue-89008.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// check-fail
// edition:2021
// known-bug

// This should pass, but seems to run into a TAIT bug.

Expand Down Expand Up @@ -31,11 +32,11 @@ trait X {
struct Y;

impl X for Y {
type LineStream<'a, Repr> = impl Stream<Item = Repr>; //~ could not find
type LineStream<'a, Repr> = impl Stream<Item = Repr>;

type LineStreamFut<'a, Repr> = impl Future<Output = Self::LineStream<'a, Repr>> ;

fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> { //~ type mismatch
fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {
async {empty()}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/generic-associated-types/bugs/issue-89008.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0271]: type mismatch resolving `<impl Future<Output = [async output]> as Future>::Output == impl Stream<Item = Repr>`
--> $DIR/issue-89008.rs:38:43
--> $DIR/issue-89008.rs:39:43
|
LL | type LineStream<'a, Repr> = impl Stream<Item = Repr>;
| ------------------------ the expected opaque type
Expand All @@ -11,7 +11,7 @@ LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {
found struct `Empty<_>`

error: could not find defining uses
--> $DIR/issue-89008.rs:34:33
--> $DIR/issue-89008.rs:35:33
|
LL | type LineStream<'a, Repr> = impl Stream<Item = Repr>;
| ^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Loading