Skip to content

Commit 7c79013

Browse files
committed
Auto merge of rust-lang#114284 - pietroalbini:pa-1.72.1, r=pietroalbini
Prepare Rust 1.71.1 This PR prepares the Rust 1.71.1 release, which contains: * rust-lang#113802 * rust-lang#113579 * rust-lang#111516 * rust-lang#112517 * rust-lang@67b5990 (from rust-lang#113678) r? `@ghost` cc `@rust-lang/release`
2 parents 8ede3aa + 95ae510 commit 7c79013

File tree

14 files changed

+133
-69
lines changed

14 files changed

+133
-69
lines changed

RELEASES.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
Version 1.71.1 (2023-08-03)
2+
===========================
3+
4+
- [Fix bash completion for users of Rustup](https://github.com/rust-lang/rust/pull/113579)
5+
- [Do not show `suspicious_double_ref_op` lint when calling `borrow()`](https://github.com/rust-lang/rust/pull/112517)
6+
- [Fix ICE: substitute types before checking inlining compatibility](https://github.com/rust-lang/rust/pull/113802)
7+
- [Fix ICE: don't use `can_eq` in `derive(..)` suggestion for missing method](https://github.com/rust-lang/rust/pull/111516)
8+
- [Fix building Rust 1.71.0 from the source tarball](https://github.com/rust-lang/rust/issues/113678)
9+
110
Version 1.71.0 (2023-07-13)
211
==========================
312

compiler/rustc_hir_typeck/src/method/suggest.rs

-14
Original file line numberDiff line numberDiff line change
@@ -2104,20 +2104,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
21042104
| sym::Hash
21052105
| sym::Debug => true,
21062106
_ => false,
2107-
} && match trait_pred.trait_ref.substs.as_slice() {
2108-
// Only suggest deriving if lhs == rhs...
2109-
[lhs, rhs] => {
2110-
if let Some(lhs) = lhs.as_type()
2111-
&& let Some(rhs) = rhs.as_type()
2112-
{
2113-
self.can_eq(self.param_env, lhs, rhs)
2114-
} else {
2115-
false
2116-
}
2117-
},
2118-
// Unary ops can always be derived
2119-
[_] => true,
2120-
_ => false,
21212107
};
21222108
if can_derive {
21232109
let self_name = trait_pred.self_ty().to_string();

compiler/rustc_lint/messages.ftl

+5-7
Original file line numberDiff line numberDiff line change
@@ -463,13 +463,11 @@ lint_requested_level = requested on the command line with `{$level} {$lint_name}
463463
lint_supertrait_as_deref_target = `{$t}` implements `Deref` with supertrait `{$target_principal}` as target
464464
.label = target type is set here
465465
466-
lint_suspicious_double_ref_op =
467-
using `.{$call}()` on a double reference, which returns `{$ty}` instead of {$op ->
468-
*[should_not_happen] [{$op}]
469-
[deref] dereferencing
470-
[borrow] borrowing
471-
[clone] cloning
472-
} the inner type
466+
lint_suspicious_double_ref_clone =
467+
using `.clone()` on a double reference, which returns `{$ty}` instead of cloning the inner type
468+
469+
lint_suspicious_double_ref_deref =
470+
using `.deref()` on a double reference, which returns `{$ty}` instead of dereferencing the inner type
473471
474472
lint_trivial_untranslatable_diag = diagnostic with static strings only
475473

compiler/rustc_lint/src/lints.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -1188,11 +1188,15 @@ pub struct NoopMethodCallDiag<'a> {
11881188
}
11891189

11901190
#[derive(LintDiagnostic)]
1191-
#[diag(lint_suspicious_double_ref_op)]
1192-
pub struct SuspiciousDoubleRefDiag<'a> {
1193-
pub call: Symbol,
1191+
#[diag(lint_suspicious_double_ref_deref)]
1192+
pub struct SuspiciousDoubleRefDerefDiag<'a> {
1193+
pub ty: Ty<'a>,
1194+
}
1195+
1196+
#[derive(LintDiagnostic)]
1197+
#[diag(lint_suspicious_double_ref_clone)]
1198+
pub struct SuspiciousDoubleRefCloneDiag<'a> {
11941199
pub ty: Ty<'a>,
1195-
pub op: &'static str,
11961200
}
11971201

11981202
// pass_by_value.rs

compiler/rustc_lint/src/noop_method_call.rs

+34-28
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use crate::context::LintContext;
2-
use crate::lints::{NoopMethodCallDiag, SuspiciousDoubleRefDiag};
2+
use crate::lints::{
3+
NoopMethodCallDiag, SuspiciousDoubleRefCloneDiag, SuspiciousDoubleRefDerefDiag,
4+
};
35
use crate::LateContext;
46
use crate::LateLintPass;
57
use rustc_hir::def::DefKind;
@@ -76,22 +78,22 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
7678

7779
// We only care about method calls corresponding to the `Clone`, `Deref` and `Borrow`
7880
// traits and ignore any other method call.
79-
let did = match cx.typeck_results().type_dependent_def(expr.hir_id) {
80-
// Verify we are dealing with a method/associated function.
81-
Some((DefKind::AssocFn, did)) => match cx.tcx.trait_of_item(did) {
82-
// Check that we're dealing with a trait method for one of the traits we care about.
83-
Some(trait_id)
84-
if matches!(
85-
cx.tcx.get_diagnostic_name(trait_id),
86-
Some(sym::Borrow | sym::Clone | sym::Deref)
87-
) =>
88-
{
89-
did
90-
}
91-
_ => return,
92-
},
93-
_ => return,
81+
82+
let Some((DefKind::AssocFn, did)) =
83+
cx.typeck_results().type_dependent_def(expr.hir_id)
84+
else {
85+
return;
86+
};
87+
88+
let Some(trait_id) = cx.tcx.trait_of_item(did) else { return };
89+
90+
if !matches!(
91+
cx.tcx.get_diagnostic_name(trait_id),
92+
Some(sym::Borrow | sym::Clone | sym::Deref)
93+
) {
94+
return;
9495
};
96+
9597
let substs = cx
9698
.tcx
9799
.normalize_erasing_regions(cx.param_env, cx.typeck_results().node_substs(expr.hir_id));
@@ -102,13 +104,6 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
102104
// (Re)check that it implements the noop diagnostic.
103105
let Some(name) = cx.tcx.get_diagnostic_name(i.def_id()) else { return };
104106

105-
let op = match name {
106-
sym::noop_method_borrow => "borrow",
107-
sym::noop_method_clone => "clone",
108-
sym::noop_method_deref => "deref",
109-
_ => return,
110-
};
111-
112107
let receiver_ty = cx.typeck_results().expr_ty(receiver);
113108
let expr_ty = cx.typeck_results().expr_ty_adjusted(expr);
114109
let arg_adjustments = cx.typeck_results().expr_adjustments(receiver);
@@ -129,11 +124,22 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
129124
NoopMethodCallDiag { method: call.ident.name, receiver_ty, label: span },
130125
);
131126
} else {
132-
cx.emit_spanned_lint(
133-
SUSPICIOUS_DOUBLE_REF_OP,
134-
span,
135-
SuspiciousDoubleRefDiag { call: call.ident.name, ty: expr_ty, op },
136-
)
127+
match name {
128+
// If `type_of(x) == T` and `x.borrow()` is used to get `&T`,
129+
// then that should be allowed
130+
sym::noop_method_borrow => return,
131+
sym::noop_method_clone => cx.emit_spanned_lint(
132+
SUSPICIOUS_DOUBLE_REF_OP,
133+
span,
134+
SuspiciousDoubleRefCloneDiag { ty: expr_ty },
135+
),
136+
sym::noop_method_deref => cx.emit_spanned_lint(
137+
SUSPICIOUS_DOUBLE_REF_OP,
138+
span,
139+
SuspiciousDoubleRefDerefDiag { ty: expr_ty },
140+
),
141+
_ => return,
142+
}
137143
}
138144
}
139145
}

compiler/rustc_mir_transform/src/inline.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,10 @@ impl<'tcx> Inliner<'tcx> {
437437
validation: Ok(()),
438438
};
439439

440+
for var_debug_info in callee_body.var_debug_info.iter() {
441+
checker.visit_var_debug_info(var_debug_info);
442+
}
443+
440444
// Traverse the MIR manually so we can account for the effects of inlining on the CFG.
441445
let mut work_list = vec![START_BLOCK];
442446
let mut visited = BitSet::new_empty(callee_body.basic_blocks.len());
@@ -845,7 +849,16 @@ impl<'tcx> Visitor<'tcx> for CostChecker<'_, 'tcx> {
845849
let parent = Place { local, projection: self.tcx.mk_place_elems(proj_base) };
846850
let parent_ty = parent.ty(&self.callee_body.local_decls, self.tcx);
847851
let check_equal = |this: &mut Self, f_ty| {
848-
if !util::is_equal_up_to_subtyping(this.tcx, this.param_env, ty, f_ty) {
852+
// Fast path if there is nothing to substitute.
853+
if ty == f_ty {
854+
return;
855+
}
856+
let ty = this.instance.subst_mir(this.tcx, ty::EarlyBinder(&ty));
857+
let f_ty = this.instance.subst_mir(this.tcx, ty::EarlyBinder(&f_ty));
858+
if ty == f_ty {
859+
return;
860+
}
861+
if !util::is_subtype(this.tcx, this.param_env, ty, f_ty) {
849862
trace!(?ty, ?f_ty);
850863
this.validation = Err("failed to normalize projection type");
851864
return;

src/bootstrap/dist.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1071,11 +1071,7 @@ impl Step for Cargo {
10711071

10721072
tarball.add_file(&cargo, "bin", 0o755);
10731073
tarball.add_file(etc.join("_cargo"), "share/zsh/site-functions", 0o644);
1074-
tarball.add_renamed_file(
1075-
etc.join("cargo.bashcomp.sh"),
1076-
"src/etc/bash_completion.d",
1077-
"cargo",
1078-
);
1074+
tarball.add_renamed_file(etc.join("cargo.bashcomp.sh"), "etc/bash_completion.d", "cargo");
10791075
tarball.add_dir(etc.join("man"), "share/man/man1");
10801076
tarball.add_legal_and_readme_to("share/doc/cargo");
10811077

src/tools/lint-docs/src/groups.rs

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ impl<'a> LintExtractor<'a> {
3939
fn collect_groups(&self) -> Result<LintGroups, Box<dyn Error>> {
4040
let mut result = BTreeMap::new();
4141
let mut cmd = Command::new(self.rustc_path);
42-
cmd.env_remove("LD_LIBRARY_PATH");
4342
cmd.arg("-Whelp");
4443
let output = cmd.output().map_err(|e| format!("failed to run command {:?}\n{}", cmd, e))?;
4544
if !output.status.success() {

src/tools/lint-docs/src/lib.rs

-6
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,6 @@ impl<'a> LintExtractor<'a> {
403403
fs::write(&tempfile, source)
404404
.map_err(|e| format!("failed to write {}: {}", tempfile.display(), e))?;
405405
let mut cmd = Command::new(self.rustc_path);
406-
// NOTE: bootstrap sets `LD_LIBRARY_PATH` for building lint-docs itself.
407-
// Unfortunately, lint-docs is a bootstrap tool while rustc is built from source,
408-
// and sometimes the paths conflict. In particular, when using `download-rustc`,
409-
// the LLVM versions can differ between `ci-llvm` and `ci-rustc-sysroot`.
410-
// Unset LD_LIBRARY_PATH here so it doesn't interfere with running the compiler.
411-
cmd.env_remove("LD_LIBRARY_PATH");
412406
if options.contains(&"edition2015") {
413407
cmd.arg("--edition=2015");
414408
} else {

src/version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.71.0
1+
1.71.1

tests/ui/issues/issue-62375.stderr

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ note: an implementation of `PartialEq<fn(()) -> A {A::Value}>` might be missing
1111
|
1212
LL | enum A {
1313
| ^^^^^^ must implement `PartialEq<fn(()) -> A {A::Value}>`
14-
note: the trait `PartialEq` must be implemented
15-
--> $SRC_DIR/core/src/cmp.rs:LL:COL
14+
help: consider annotating `A` with `#[derive(PartialEq)]`
15+
|
16+
LL + #[derive(PartialEq)]
17+
LL | enum A {
18+
|
1619
help: use parentheses to construct this tuple variant
1720
|
1821
LL | a == A::Value(/* () */);

tests/ui/lint/issue-112489.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// check-pass
2+
use std::borrow::Borrow;
3+
4+
struct S;
5+
6+
trait T: Sized {
7+
fn foo(self) {}
8+
}
9+
10+
impl T for S {}
11+
impl T for &S {}
12+
13+
fn main() {
14+
let s = S;
15+
s.borrow().foo();
16+
s.foo();
17+
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
pub struct A;
2+
3+
fn main() {
4+
match () {
5+
_ => match A::partial_cmp() {},
6+
//~^ ERROR the function or associated item `partial_cmp` exists for struct `A`, but its trait bounds were not satisfied
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
error[E0599]: the function or associated item `partial_cmp` exists for struct `A`, but its trait bounds were not satisfied
2+
--> $DIR/derive-sugg-arg-arity.rs:5:23
3+
|
4+
LL | pub struct A;
5+
| ------------
6+
| |
7+
| function or associated item `partial_cmp` not found for this struct
8+
| doesn't satisfy `A: Iterator`
9+
| doesn't satisfy `A: PartialOrd<_>`
10+
...
11+
LL | _ => match A::partial_cmp() {},
12+
| ^^^^^^^^^^^ function or associated item cannot be called on `A` due to unsatisfied trait bounds
13+
|
14+
= note: the following trait bounds were not satisfied:
15+
`A: PartialOrd<_>`
16+
which is required by `&A: PartialOrd<&_>`
17+
`A: PartialOrd<_>`
18+
which is required by `&mut A: PartialOrd<&mut _>`
19+
`A: Iterator`
20+
which is required by `&mut A: Iterator`
21+
note: the trait `Iterator` must be implemented
22+
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
23+
help: consider annotating `A` with `#[derive(PartialEq, PartialOrd)]`
24+
|
25+
LL + #[derive(PartialEq, PartialOrd)]
26+
LL | pub struct A;
27+
|
28+
29+
error: aborting due to previous error
30+
31+
For more information about this error, try `rustc --explain E0599`.

0 commit comments

Comments
 (0)