]> Cypherpunks repositories - gostls13.git/commitdiff
Revert "cmd/vet: lostcancel: suppress the check in the main.main function"
authorBrad Fitzpatrick <bradfitz@golang.org>
Fri, 9 Nov 2018 17:27:39 +0000 (17:27 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 9 Nov 2018 17:37:16 +0000 (17:37 +0000)
This reverts CL 148758 (commit 5e17ce22ece18571597ef9a214cdfcd461894e9c)

Reason for revert: breaks the build.

Change-Id: I6ed15b7b8f6b74d84edab9402ddf7ae87a0d0387
Reviewed-on: https://go-review.googlesource.com/c/148817
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/vet/lostcancel.go
src/cmd/vet/testdata/lostcancel.go

index 496e87a5e04990bec751c32260ec35698fd7d56d..ee0342035fe3729efb3774e0d51f1cea10cd0ef3 100644 (file)
@@ -104,11 +104,6 @@ func checkLostCancel(f *File, node ast.Node) {
        var sig *types.Signature
        switch node := node.(type) {
        case *ast.FuncDecl:
-               if node.Name.Name == "main" && node.Recv == nil && f.file.Name.Name == "main" {
-                       // Returning from main.main terminates the process,
-                       // so there's no need to cancel contexts.
-                       return
-               }
                obj := f.pkg.defs[node.Name]
                if obj == nil {
                        return // type error (e.g. duplicate function declaration)
index 408bed51228760e30a65057ebfab336fcb248580..b7549c00511127819183818ba3895b5c03536ba8 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package main
+package testdata
 
 import (
        "context"
@@ -33,12 +33,6 @@ func _() {
        ctx, _ = context.WithDeadline() // ERROR "the cancel function returned by context.WithDeadline should be called, not discarded, to avoid a context leak"
 }
 
-// Return from main is handled specially.
-// Since the program exits, there's no need to call cancel.
-func main() {
-       var ctx, cancel = context.WithCancel()
-}
-
 func _() {
        ctx, cancel := context.WithCancel()
        defer cancel() // ok