Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d419a5f
Fix pointing at arg when cause is outside of call
VirrageS Dec 1, 2019
e305bf8
Rename tests and add short test description
VirrageS Dec 3, 2019
2d8d813
Update tokio crates to latest versions
mati865 Dec 4, 2019
5dadda1
Teach `compiletest` to ignore platform triples
estebank Dec 15, 2019
f772d87
Ignore i586-unknown-linux-gnu and i586-unknown-musl in tests
estebank Dec 15, 2019
aa0ef5a
Fix handling of wasm import modules and names
alexcrichton Dec 16, 2019
3a19fbf
Add Rvalue::AddressOf to MIR
matthewjasper Dec 23, 2018
35919ac
Start generating AddressOf rvalues in MIR
matthewjasper Apr 20, 2019
5fb797c
Make slice drop shims use AddressOf
matthewjasper Apr 20, 2019
7081c79
Add mir opt test for AddressOf
matthewjasper Apr 20, 2019
7b0cc6a
Check const-propagation of borrows of unsized places
matthewjasper Sep 17, 2019
1593194
Update test now that reference to pointer casts have more checks
matthewjasper Sep 17, 2019
6dcc789
Add more tests for raw_ref_op
matthewjasper Sep 18, 2019
a749116
Fix comment ordering
matthewjasper Dec 2, 2019
44603a5
Reenable static linking of libstdc++ on windows-gnu
mati865 Dec 18, 2019
f059461
Rollup merge of #64588 - matthewjasper:mir-address-of, r=oli-obk
Centril Dec 20, 2019
5fd4689
Rollup merge of #67031 - mati865:tokio-update, r=nikomatsakis
Centril Dec 20, 2019
29f5e5c
Rollup merge of #67334 - estebank:ignore-triple, r=nikomatsakis
Centril Dec 20, 2019
2e246b8
Rollup merge of #67354 - VirrageS:blame-wrong-line, r=estebank
Centril Dec 20, 2019
8e9f09c
Rollup merge of #67363 - alexcrichton:wasm-import-modules, r=eddyb
Centril Dec 20, 2019
8f5e3d7
Rollup merge of #67410 - mati865:mingw_link_fix, r=Mark-Simulacrum
Centril Dec 20, 2019
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
Next Next commit
Fix pointing at arg when cause is outside of call
  • Loading branch information
VirrageS committed Dec 6, 2019
commit d419a5fdaebb36dbf3c600f624c964d9ea651661
65 changes: 37 additions & 28 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3880,36 +3880,45 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
call_sp: Span,
args: &'tcx [hir::Expr],
) {
if !call_sp.desugaring_kind().is_some() {
// We *do not* do this for desugared call spans to keep good diagnostics when involving
// the `?` operator.
for error in errors {
if let ty::Predicate::Trait(predicate) = error.obligation.predicate {
// Collect the argument position for all arguments that could have caused this
// `FulfillmentError`.
let mut referenced_in = final_arg_types.iter()
.map(|(i, checked_ty, _)| (i, checked_ty))
.chain(final_arg_types.iter().map(|(i, _, coerced_ty)| (i, coerced_ty)))
.flat_map(|(i, ty)| {
let ty = self.resolve_vars_if_possible(ty);
// We walk the argument type because the argument's type could have
// been `Option<T>`, but the `FulfillmentError` references `T`.
ty.walk()
.filter(|&ty| ty == predicate.skip_binder().self_ty())
.map(move |_| *i)
})
.collect::<Vec<_>>();
// We *do not* do this for desugared call spans to keep good diagnostics when involving
// the `?` operator.
if call_sp.desugaring_kind().is_some() {
return
}

for error in errors {
// Only if the cause is somewhere inside the expression we want try to point at arg.
// Otherwise, it means that the cause is somewhere else and we should not change
// anything because we can break the correct span.
if !call_sp.contains(error.obligation.cause.span) {
continue
}

if let ty::Predicate::Trait(predicate) = error.obligation.predicate {
// Collect the argument position for all arguments that could have caused this
// `FulfillmentError`.
let mut referenced_in = final_arg_types.iter()
.map(|(i, checked_ty, _)| (i, checked_ty))
.chain(final_arg_types.iter().map(|(i, _, coerced_ty)| (i, coerced_ty)))
.flat_map(|(i, ty)| {
let ty = self.resolve_vars_if_possible(ty);
// We walk the argument type because the argument's type could have
// been `Option<T>`, but the `FulfillmentError` references `T`.
ty.walk()
.filter(|&ty| ty == predicate.skip_binder().self_ty())
.map(move |_| *i)
})
.collect::<Vec<_>>();

// Both checked and coerced types could have matched, thus we need to remove
// duplicates.
referenced_in.dedup();
// Both checked and coerced types could have matched, thus we need to remove
// duplicates.
referenced_in.dedup();

if let (Some(ref_in), None) = (referenced_in.pop(), referenced_in.pop()) {
// We make sure that only *one* argument matches the obligation failure
// and we assign the obligation's span to its expression's.
error.obligation.cause.span = args[ref_in].span;
error.points_at_arg_span = true;
}
if let (Some(ref_in), None) = (referenced_in.pop(), referenced_in.pop()) {
// We make sure that only *one* argument matches the obligation failure
// and we assign the obligation's span to its expression's.
error.obligation.cause.span = args[ref_in].span;
error.points_at_arg_span = true;
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/test/ui/issues/issue-66923.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
fn main() {
let v = vec![1_f64, 2.2_f64];
let mut fft: Vec<Vec<f64>> = vec![];

let x1: &[f64] = &v;
let x2: Vec<f64> = x1.into_iter().collect();
//~^ ERROR a collection of type
fft.push(x2);

let x3 = x1.into_iter().collect::<Vec<f64>>();
//~^ ERROR a collection of type
fft.push(x3);
}
19 changes: 19 additions & 0 deletions src/test/ui/issues/issue-66923.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0277]: a collection of type `std::vec::Vec<f64>` cannot be built from an iterator over elements of type `&f64`
--> $DIR/issue-66923.rs:6:39
|
LL | let x2: Vec<f64> = x1.into_iter().collect();
| ^^^^^^^ a collection of type `std::vec::Vec<f64>` cannot be built from `std::iter::Iterator<Item=&f64>`
|
= help: the trait `std::iter::FromIterator<&f64>` is not implemented for `std::vec::Vec<f64>`

error[E0277]: a collection of type `std::vec::Vec<f64>` cannot be built from an iterator over elements of type `&f64`
--> $DIR/issue-66923.rs:10:29
|
LL | let x3 = x1.into_iter().collect::<Vec<f64>>();
| ^^^^^^^ a collection of type `std::vec::Vec<f64>` cannot be built from `std::iter::Iterator<Item=&f64>`
|
= help: the trait `std::iter::FromIterator<&f64>` is not implemented for `std::vec::Vec<f64>`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.