Skip to content

Rollup of 10 pull requests #76786

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

Merged
merged 28 commits into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8d96cc2
make llvm_asm options more intense
tesuji Sep 13, 2020
b7ce5b4
remove orphaned files
tshepang Sep 13, 2020
c9686cb
Introduce a PartitioningCx struct
wesleywiser Jul 26, 2020
0eac38b
fix syntax error in suggesting generic constraint in trait parameter
iximeow Sep 14, 2020
dd57275
shrink const infer error
lcnr Sep 14, 2020
035f879
improve const infer err
lcnr Sep 14, 2020
b881551
Simplify iter flatten struct doc
pickfire Sep 14, 2020
43709f7
:arrow_up: rust-analyzer
Sep 14, 2020
5112f87
Remove flatten doc intra-doc links
pickfire Sep 14, 2020
1f26a18
Use intra-doc links for `DelaySpanBugEmitted`
camelid Sep 14, 2020
15349ef
Minor improvements to `mir::Constant` docs
camelid Sep 14, 2020
5c1043a
Fix diagram for `DebruijnIndex`
camelid Sep 14, 2020
e1607c8
clean up comment text a bit
iximeow Sep 14, 2020
32efcfc
Include non-JSON output in error display for lint-doc failure.
ehuss Sep 14, 2020
9dad908
Fix generating rustc docs with non-default lib directory.
ehuss Sep 14, 2020
e82be71
document how to use memory addresses as operands
tesuji Sep 14, 2020
87666e5
Prefer asm! over llvm_asm! in core
tesuji Sep 16, 2020
4dc4e9f
Fix black_box bug detected by Amanieu
tesuji Sep 16, 2020
d1b0504
Rollup merge of #76669 - lzutao:core_asm, r=Amanieu
Dylan-DPC Sep 16, 2020
6194d7e
Rollup merge of #76675 - lzutao:asm_doc, r=Amanieu
Dylan-DPC Sep 16, 2020
c8bfbad
Rollup merge of #76681 - tshepang:unused, r=Mark-Simulacrum
Dylan-DPC Sep 16, 2020
2c2f1c2
Rollup merge of #76694 - wesleywiser:partitioning_cx_trait, r=davidtwco
Dylan-DPC Sep 16, 2020
54d7728
Rollup merge of #76695 - iximeow:trait-generic-bound-suggestion, r=es…
Dylan-DPC Sep 16, 2020
3f9e7fc
Rollup merge of #76699 - lcnr:const-infer-err, r=varkor
Dylan-DPC Sep 16, 2020
9524fff
Rollup merge of #76707 - pickfire:patch-4, r=jonas-schievink
Dylan-DPC Sep 16, 2020
7e202fc
Rollup merge of #76710 - rust-lang:rust-analyzer-2020-09-14, r=jonas-…
Dylan-DPC Sep 16, 2020
b25261f
Rollup merge of #76714 - camelid:patch-3, r=jonas-schievink
Dylan-DPC Sep 16, 2020
f631293
Rollup merge of #76717 - ehuss:fix-rustc-book-libdir, r=Mark-Simulacrum
Dylan-DPC Sep 16, 2020
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
Prev Previous commit
Next Next commit
shrink const infer error
  • Loading branch information
lcnr committed Sep 14, 2020
commit dd57275c3e4d52b443090d0d75a9a3443bc5ce5c
15 changes: 9 additions & 6 deletions compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_hir::{Body, Expr, ExprKind, FnRetTy, HirId, Local, Pat};
use rustc_middle::hir::map::Map;
use rustc_middle::ty::print::Print;
use rustc_middle::ty::subst::{GenericArg, GenericArgKind};
use rustc_middle::ty::{self, DefIdTree, Ty};
use rustc_middle::ty::{self, DefIdTree, InferConst, Ty};
use rustc_span::source_map::DesugaringKind;
use rustc_span::symbol::kw;
use rustc_span::Span;
Expand Down Expand Up @@ -569,12 +569,15 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
local_visitor.visit_expr(expr);
}

let span = if let ty::ConstKind::Infer(InferConst::Var(vid)) = ct.val {
self.inner.borrow_mut().const_unification_table().probe_value(vid).origin.span
} else {
local_visitor.target_span
};

let error_code = error_code.into();
let mut err = self.tcx.sess.struct_span_err_with_code(
local_visitor.target_span,
"type annotations needed",
error_code,
);
let mut err =
self.tcx.sess.struct_span_err_with_code(span, "type annotations needed", error_code);

err.note("unable to infer the value of a const parameter");

Expand Down
11 changes: 11 additions & 0 deletions src/test/ui/const-generics/infer/method-chain.full.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0282]: type annotations needed
--> $DIR/method-chain.rs:21:33
|
LL | Foo.bar().bar().bar().bar().baz();
| ^^^
|
= note: unable to infer the value of a const parameter

error: aborting due to previous error

For more information about this error, try `rustc --explain E0282`.
11 changes: 11 additions & 0 deletions src/test/ui/const-generics/infer/method-chain.min.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0282]: type annotations needed
--> $DIR/method-chain.rs:21:33
|
LL | Foo.bar().bar().bar().bar().baz();
| ^^^
|
= note: unable to infer the value of a const parameter

error: aborting due to previous error

For more information about this error, try `rustc --explain E0282`.
22 changes: 22 additions & 0 deletions src/test/ui/const-generics/infer/method-chain.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// revisions: full min

#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]

struct Foo;

impl Foo {
fn bar(self) -> Foo {
Foo
}

fn baz<const N: usize>(self) -> Foo {
println!("baz: {}", N);
Foo
}
}

fn main() {
Foo.bar().bar().bar().bar().baz(); //~ ERROR type annotations needed
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0282]: type annotations needed
--> $DIR/uninferred-consts.rs:14:5
--> $DIR/uninferred-consts.rs:14:9
|
LL | Foo.foo();
| ^^^^^^^^^
| ^^^
|
= note: unable to infer the value of a const parameter

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0282]: type annotations needed
--> $DIR/uninferred-consts.rs:14:5
--> $DIR/uninferred-consts.rs:14:9
|
LL | Foo.foo();
| ^^^^^^^^^
| ^^^
|
= note: unable to infer the value of a const parameter

Expand Down